numapprox - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Mathematics : Numerical Computations : Approximations : numapprox Package : numapprox/hornerform

numapprox

 hornerform
 convert a polynomial to Horner form

 Calling Sequence hornerform(r) hornerform(r, x)

Parameters

 r - procedure or expression representing a polynomial or rational function x - (optional) variable name appearing in r, if r is an expression

Description

 • This procedure converts a given polynomial r into Horner form, also known as nested multiplication form. This is a form which minimizes the number of arithmetic operations required to evaluate the polynomial.
 • If r is a rational function (i.e. a quotient of polynomials) then the numerator and denominator are each converted into Horner form.
 • If the second argument x is present then the first argument must be a polynomial (or rational expression) in the variable x. If the second argument is omitted then either r is an operator such that $r\left(y\right)$ yields a polynomial (or rational expression) in y, or else r is an expression with exactly one indeterminate (determined via indets).
 • Note that for the purpose of evaluating a polynomial efficiently, the Horner form minimizes the number of arithmetic operations for a general polynomial. Specifically, the cost of evaluating a polynomial of degree n in Horner form is: n multiplications and n additions.
 • The command with(numapprox,hornerform) allows the use of the abbreviated form of this command.

Examples

 > $\mathrm{with}\left(\mathrm{numapprox}\right):$
 > $f≔t→a{t}^{4}+b{t}^{3}+c{t}^{2}+dt+e$
 ${f}{≔}{t}{→}{a}{}{{t}}^{{4}}{+}{b}{}{{t}}^{{3}}{+}{c}{}{{t}}^{{2}}{+}{d}{}{t}{+}{e}$ (1)
 > $\mathrm{hornerform}\left(f\right)$
 ${t}{→}{e}{+}\left({d}{+}\left({c}{+}\left({a}{}{t}{+}{b}\right){}{t}\right){}{t}\right){}{t}$ (2)
 > $s≔\mathrm{taylor}\left({ⅇ}^{x},x\right)$
 ${s}{≔}{1}{+}{x}{+}\frac{{1}}{{2}}{}{{x}}^{{2}}{+}\frac{{1}}{{6}}{}{{x}}^{{3}}{+}\frac{{1}}{{24}}{}{{x}}^{{4}}{+}\frac{{1}}{{120}}{}{{x}}^{{5}}{+}{\mathrm{O}}\left({{x}}^{{6}}\right)$ (3)
 > $\mathrm{hornerform}\left(s\right)$
 ${1}{+}\left({1}{+}\left(\frac{{1}}{{2}}{+}\left(\frac{{1}}{{6}}{+}\left(\frac{{1}}{{24}}{+}\frac{{1}}{{120}}{}{x}\right){}{x}\right){}{x}\right){}{x}\right){}{x}$ (4)
 > $r≔\mathrm{pade}\left({ⅇ}^{ax},x,\left[3,3\right]\right)$
 ${r}{≔}\frac{{{a}}^{{3}}{}{{x}}^{{3}}{+}{12}{}{{a}}^{{2}}{}{{x}}^{{2}}{+}{60}{}{a}{}{x}{+}{120}}{{-}{{a}}^{{3}}{}{{x}}^{{3}}{+}{12}{}{{a}}^{{2}}{}{{x}}^{{2}}{-}{60}{}{a}{}{x}{+}{120}}$ (5)
 > $\mathrm{hornerform}\left(r,x\right)$
 $\frac{{120}{+}\left({60}{}{a}{+}\left({{a}}^{{3}}{}{x}{+}{12}{}{{a}}^{{2}}\right){}{x}\right){}{x}}{{120}{+}\left({-}{60}{}{a}{+}\left({-}{{a}}^{{3}}{}{x}{+}{12}{}{{a}}^{{2}}\right){}{x}\right){}{x}}$ (6)

 See Also

## Was this information helpful?

 Please add your Comment (Optional) E-mail Address (Optional) What is ? This question helps us to combat spam