public static AreApproximatelyEqual ( double value1, double value2 ) : bool | ||
value1 | double | |
value2 | double | |
Результат | bool |
// (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)); }