horner {cmna} | R Documentation |

## Horner's rule

### Description

Use Horner's rule to evaluate a polynomial

### Usage

```
horner(x, coefs)
rhorner(x, coefs)
naivepoly(x, coefs)
betterpoly(x, coefs)
```

### Arguments

`x` |
a vector of x values to evaluate the polynomial |

`coefs` |
vector of coefficients of x |

### Details

This function implements Horner's rule for fast polynomial
evaluation. The implementation expects `x`

to be a vector of x
values at which to evaluate the polynomial. The parameter `coefs`

is a vector of coefficients of *x*. The vector order is such
that the first element is the constant term, the second element is
the coefficient of *x*, the so forth to the highest degreed
term. Terms with a 0 coefficient should have a 0 element in the
vector.

The function `rhorner`

implements the the Horner algorithm
recursively.

The function `naivepoly`

implements a polynomial evaluator using
the straightforward algebraic approach.

The function `betterpoly`

implements a polynomial evaluator using
the straightforward algebraic approach with cached *x* terms.

### Value

the value of the function at `x`

### See Also

Other algebra:
`bilinear()`

,
`cubicspline()`

,
`division`

,
`fibonacci()`

,
`isPrime()`

,
`linterp()`

,
`nthroot()`

,
`polyinterp()`

,
`pwiselinterp()`

,
`quadratic()`

### Examples

```
b <- c(2, 10, 11)
x <- 5
horner(x, b)
b <- c(-1, 0, 1)
x <- c(1, 2, 3, 4)
horner(x, b)
rhorner(x, b)
```

*cmna*version 1.0.5 Index]