6.27.19 Evaluating a polynomial: horner
The horner command uses Horner’s method to evaluate
polynomials.
-
horner takes two arguments:
-
P, a polynomial given by its symbolic expression
or by the list of its coefficients.
- a, a number.
- horner(P,a) returns the value P(a),
computed using Horner’s method.
Example.
Input:
horner(x^2-2*x+1,2)
or:
horner([1,-2,1],2)
Output:
1