Compute the value of a polynomial via the Horner scheme.
Usage
horner(p, x)
Arguments
p
Numeric vector representing a polynomial.
x
Numeric scalar or vector at which to evaluate the polynomial.
Value
Returns a list with two elements, list(y=..., dy=...) where the
first list elements returns the values of the polynomial, the second the
values of its derivative at the point(s) x.
Details
Utilizes the Horner scheme to evaluate the polynomial and its first
derivative at the same time.
The polynomial p = p_1*x^n + p_2*x^{n-1} + ... + p_n*x + p_{n+1}
is hereby represented by the vector p_1, p_2, ..., p_n, p_{n+1},
i.e. from highest to lowest coefficient.
References
Quarteroni, A., and Saleri, F. (2006) Scientific Computing with Matlab
and Octave. Second Edition, Springer-Verlag, Berlin Heidelberg.