R: Evaluate Polynomials

polynEval {copula} | R Documentation

## Evaluate Polynomials

### Description

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)

### 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.

### Value

numeric vector or array, with the same dimensions as `x`, containing the polynomial values p(x).

### See Also

For a much more sophisticated treatment of polynomials, use the `polynom` package (for example, evaluation can be done via `predict.polynomial`).

### Examples

    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!

[Package copula version 1.0-1 Index]