public static IEnumerable <FunctionTerm> BernsteinPolynomialBasis(int length) { if (length < 0) { throw new ArgumentOutOfRangeException("length"); } ValueTerm variable = Variable("x"); int degree = length - 1; return (( from index in Enumerable.Range(0, length) select Product ( Constant(Scalars.BinomialCoefficient(degree, index)), Exponentiation(variable, Constant(index)), Exponentiation(Difference(Constant(1), variable), Constant(degree - index)) ) .Abstract(variable) ) .ToArray()); }