R: Evaluating a Polynomial

polyval {pracma} | R Documentation

## Evaluating a Polynomial

### Description

Evaluate polynomial given as a numeric vector.

### Usage

      polyval(p, x)

### Arguments

`p` | vector representing a polynomial
`x` | vector of values where to evaluate the polynomial

### Details

Evaluate the polynomial given by `p` at the values specified by the elements of `x`. If `x` is a matrix, the polynomial will be evaluated at each element and a matrix returned.

### Value

vector of values

### See Also

`poly`, `roots`

### Examples

      # Evaluate 3 x^2 + 2 x + 1 at x = 5, 7, and 9
      p = c(3, 2, 1);
      polyval(p, c(5, 7, 9))  # 86  162  262

[Package pracma version 2.0.4 Index]