polynEval | R Documentation |
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
.
polynEval(coef, x)
coef |
numeric vector. If a vector, |
x |
numeric vector or array. |
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.
numeric vector or array, with the same dimensions as x
,
containing the polynomial values p(x)
.
For a much more sophisticated treatment of polynomials, use the
polynom
package (for example, evaluation can be done via
predict.polynomial
).
polynEval(c(1,-2,1), x = -2:7) # (x - 1)^2
polynEval(c(0, 24, -50, 35, -10, 1),
x = matrix(0:5, 2,3)) # 5 zeros!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.