hornerform - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

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\cdot {t}^{4}+b\cdot {t}^{3}+c\cdot {t}^{2}+d\cdot t+e$
 ${f}{≔}{t}{↦}{a}{\cdot }{{t}}^{{4}}{+}{b}{\cdot }{{t}}^{{3}}{+}{c}{\cdot }{{t}}^{{2}}{+}{d}{\cdot }{t}{+}{e}$ (1)
 > $\mathrm{hornerform}\left(f\right)$
 ${t}{↦}{e}{+}\left({d}{+}\left({c}{+}\left({a}{\cdot }{t}{+}{b}\right){\cdot }{t}\right){\cdot }{t}\right){\cdot }{t}$ (2)
 > $s≔\mathrm{taylor}\left(\mathrm{exp}\left(x\right),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}}{+}{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{{x}}{{120}}\right){}{x}\right){}{x}\right){}{x}\right){}{x}$ (4)
 > $r≔\mathrm{pade}\left(\mathrm{exp}\left(ax\right),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)