# horner: Horner's method In freealg: The Free Algebra

 horner R Documentation

## Horner's method

### Description

Horner's method for multivariate polynomials

### Usage

horner(P,v)


### Arguments

 P Free algebra polynomial v Numeric vector of coefficients

### Details

This function is (almost) the same as mvp::horner().

Given a polynomial

\mjdeqn

p(x) = a_0 +a_1+a_2x^2+\cdots + a_nx^nomitted; see latex

it is possible to express p(x) in the algebraically equivalent form

\mjdeqn

p(x) = a_0 + x\left(a_1+x\left(a_2+\cdots + x\left(a_n-1 +xa_n \right)\cdots\right)\right)omitted; see PDF

which is much more efficient for evaluation, as it requires only n multiplications and n additions, and this is optimal. Function horner() will take a freealg object for its first argument.

### Author(s)

Robin K. S. Hankin

### Examples


horner("x",  1:4)  # note constant term is 1.

horner("x+y",1:3) # note presence of xy and yx terms

horner("1+x+xyX",1:3)


freealg documentation built on Aug. 28, 2022, 9:05 a.m.