AreApproximatelyEqual() public static method

public static AreApproximatelyEqual ( double value1, double value2 ) : bool
value1 double
value2 double
return bool
Example #1
0
        // (a * x + b) ^ n
        public static IEnumerable <Summand> RaiseLineToPowerWithBinomialExpansion(double a, double b, int n)
        {
            if (n == 0)
            {
                return(new List <Summand>
                {
                    new Summand
                    {
                        Coefficient = 1.0
                    }
                });
            }

            if (MathHelper.AreApproximatelyEqual(b, 0))
            {
                return(new List <Summand>
                {
                    new Summand
                    {
                        PolynomialDegree = n,
                        Coefficient = MathHelper.FastPow(a, n)
                    }
                });
            }

            var returned = Enumerable.Range(0, n + 1).Select(k => new Summand
            {
                PolynomialDegree = k,
                Coefficient      = MathHelper.BinomialCoefficient(n, k) * MathHelper.FastPow(a, k) * MathHelper.FastPow(b, n - k)
            });

            return(returned);
        }
 public bool Equals(Summand x, Summand y)
 {
     return(x.LittleODegree == y.LittleODegree &&
            MathHelper.AreApproximatelyEqual(x.PolynomialDegree, y.PolynomialDegree));
 }