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

convert/mathorner

convert a polynomial to Matrix Horner form

 Calling Sequence convert( poly, mathorner ) convert( poly, mathorner, var )

Parameters

 poly - polynomial var - (optional) variable

Description

 • convert/mathorner writes the polynomial poly in the name var in horner or nested'' form.
 • If there is only one indeterminate in poly then it is not necessary to specify the third argument var.
 • Horner form allows you to evaluate polynomials of Matrices in the most efficient manner. For a polynomial of degree n there will be n adds and n multiplications needed to evaluate the Horner form.

Examples

 > $p≔-56-7{x}^{5}+22{x}^{4}-55{x}^{3}-94{x}^{2}+87x$
 ${p}{≔}{-}{7}{}{{x}}^{{5}}{+}{22}{}{{x}}^{{4}}{-}{55}{}{{x}}^{{3}}{-}{94}{}{{x}}^{{2}}{+}{87}{}{x}{-}{56}$ (1)
 > $A≔\mathrm{Matrix}\left(\left[\left[1,-3\right],\left[4,7\right]\right]\right)$
 ${A}{≔}\left[\begin{array}{cc}{1}& {-3}\\ {4}& {7}\end{array}\right]$ (2)
 > $\mathrm{convert}\left(p,\mathrm{mathorner}\right)$
 ${-}{56}{+}\left({87}{+}\left({-}{94}{+}\left({-}{55}{+}\left({22}{-}{7}{}{x}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{&*}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{x}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{&*}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{x}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{&*}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{x}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{&*}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{x}$ (3)
 > $\mathrm{subs}\left(x=A,\right)$
 ${-}{56}{+}\left({87}{+}\left({-}{94}{+}\left({-}{55}{+}\left({22}{-}{7}{}\left[\begin{array}{cc}{1}& {-3}\\ {4}& {7}\end{array}\right]\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{&*}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left[\begin{array}{cc}{1}& {-3}\\ {4}& {7}\end{array}\right]\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{&*}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left[\begin{array}{cc}{1}& {-3}\\ {4}& {7}\end{array}\right]\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{&*}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left[\begin{array}{cc}{1}& {-3}\\ {4}& {7}\end{array}\right]\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{&*}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left[\begin{array}{cc}{1}& {-3}\\ {4}& {7}\end{array}\right]$ (4)
 > $\genfrac{}{}{0}{}{\phantom{\mathrm{&*}=\mathrm{.}}}{}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}|\phantom{\rule[-0.0ex]{0.1em}{0.0ex}}\genfrac{}{}{0}{}{\phantom{}}{\mathrm{&*}=\mathrm{.}}$
 $\left[\begin{array}{cc}{14717}& {12681}\\ {-16908}& {-10645}\end{array}\right]$ (5)
 > $\mathrm{eval}\left(,\left[x=A,\mathrm{&*}=\mathrm{.}\right]\right)$
 $\left[\begin{array}{cc}{14717}& {12681}\\ {-16908}& {-10645}\end{array}\right]$ (6)
 > $P≔\genfrac{}{}{0}{}{p}{\phantom{x=\mathrm{%A}}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}|\phantom{\rule[-0.0ex]{0.1em}{0.0ex}}\genfrac{}{}{0}{}{\phantom{p}}{x=\mathrm{%A}}$
 ${P}{≔}{-}{7}{}{{\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%A}}\right]\right)}^{{5}}{+}{22}{}{{\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%A}}\right]\right)}^{{4}}{-}{55}{}{{\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%A}}\right]\right)}^{{3}}{-}{94}{}{{\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%A}}\right]\right)}^{{2}}{+}{87}{}{\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%A}}\right]\right){-}{56}$ (7)
 > $\genfrac{}{}{0}{}{\mathrm{convert}\left(P,\mathrm{mathorner},\mathrm{%A}\right)}{\phantom{\mathrm{&*}=\mathrm{.}}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}|\phantom{\rule[-0.0ex]{0.1em}{0.0ex}}\genfrac{}{}{0}{}{\phantom{\mathrm{convert}\left(P,\mathrm{mathorner},\mathrm{%A}\right)}}{\mathrm{&*}=\mathrm{.}}$
 ${-}{56}{+}\left({87}{+}\left({-}{94}{+}\left({-}{55}{+}\left({22}{-}{7}{}{\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%A}}\right]\right)\right){·}{\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%A}}\right]\right)\right){·}{\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%A}}\right]\right)\right){·}{\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%A}}\right]\right)\right){·}{\mathrm{Typesetting}}{:-}{\mathrm{_Hold}}{}\left(\left[{\mathrm{%A}}\right]\right)$ (8)
 > $\mathrm{value}\left(\right)$
 $\left[\begin{array}{cc}{14717}& {12681}\\ {-16908}& {-10645}\end{array}\right]$ (9)