Evaluate a Polynomial

Usage

poly.value(p, x, nam = as.character(x))

Arguments

p An object of class polynomial
x A numeric vector of x-values
nam An optional names vector for the result

Description

Given an object of class polynomial, evaluate the polynomial represented at a vector of x-values.

The horner scheme is used to evaluate the polynomial, but numerical difficulties can still arise, expecially with high degree polynomials.

The argument x may also be another polynomial, in which case a polynomial substitution is done and the result is another polynomial.

Value

A vector of polynomial values.

See Also

as.function.polynomial

Examples

pr <- poly.from.zeros(1:5)
poly.value(pr, 0:6)
##     0 1 2 3 4 5   6 
##  -120 0 0 0 0 0 120
prf <- as.function(pr)
prf(0:6, nam = NULL)
## [1] -120    0    0    0    0    0  120


[Package Contents]