/ Home
S-Archive Download Script
polyval Value of a Polynomial
DESCRIPTION
Returns the value of a polynomial.
 
USAGE
polyval(x,a)
 
REQUIRED ARGUMENTS
x   numeric vector. Missing values (NAs) are allowed.
a   vector or array holding the coefficents of the polynomial. Missing values (NAs) are allowed but will produce an entirely missing result.
 
VALUE
Vector of the same length as x
 
DETAILS
In principle, the value of polyval is equal to A[1] + A[2]*X + ... + A[N]*X^(N-1) where N = length(A), but the computation is organized an a recursive fashion which is more efficient and more stable than direct evaluatoin.
 
EXAMPLES
> x <- rnorm(20)
> a <- c(1,2,3,4)
> polyval(x,a)
 [1]  14.6136513 -11.4897179  -3.5272496   6.1085425   0.6780125
 [6]  -1.7608330  -0.5657570   1.3621185   1.0216200   4.0967765
[11]   0.6476629   5.3475723  -3.0715256  -4.4792673   9.3470453
[16] -19.7379201  27.8330092   0.4423658   6.5494973   6.8296527

 

S-Archive Download Script

Gordon Smyth. Copyright © 1996-2016. Last modified: 10 February 2004