Evaluate a univariate polynomial at x (typically a vector), that is,
compute, for a given vector of coefficients coef, the polynomial
coef[1] + coef[2]*x + ... + coef[p+1]*x^p.
Usage
polynEval(coef, x)
Value
numeric vector or array, with the same dimensions as x,
containing the polynomial values \(p(x)\).
Arguments
coef
numeric vector. If a vector, x can be an
array and the result matches x.
x
numeric vector or array.
Details
The stable Horner rule is used for evaluation.
Using the C code speeds up the already fast R code available in
polyn.eval() in package sfsmisc.
See Also
For a much more sophisticated treatment of polynomials, use the
polynom package (for example, evaluation can be done via
predict.polynomial).