Evaluate Polynomials
Evaluate one or several univariate polynomials at several locations,
i.e. compute coef[1] + coef[2]*x + ... + coef[p+1]* x^p
(in the simplest case where x
is scalar and coef
a vector).
polyn.eval(coef, x)
coef |
numeric vector or matrix. If a vector, |
x |
numeric vector or array. Either |
The stable “Horner rule” is used for evaluation in any case.
numeric vector or array, depending on input dimensionalities, see above.
Martin Maechler, ages ago.
For much more sophisticated handling of polynomials, use the
polynom package, see, e.g., predict.polynomial
.
For multivariate polynomials (and also for nice interface to the
orthopolynom package), consider the mpoly package.
polyn.eval(c(1,-2,1), x = 0:3)# (x - 1)^2 polyn.eval(c(0, 24, -50, 35, -10, 1), x = matrix(0:5, 2,3))# 5 zeros! (cf <- rbind(diag(3), c(1,-2,1))) polyn.eval(cf, 0:5)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.