convert/mathorner - Maple Help

Home : Support : Online Help : Programming : Data Types : Conversion : convert/mathorner

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}{rr}{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){&*}{x}\right){&*}{x}\right){&*}{x}\right){&*}{x}$ (3)
 > $\mathrm{subs}\left(x=A,\right)$
 ${-}{56}{+}\left({87}{+}\left({-}{94}{+}\left({-}{55}{+}\left({22}{-}{7}{}\left[\begin{array}{rr}{1}& {-}{3}\\ {4}& {7}\end{array}\right]\right){&*}\left[\begin{array}{rr}{1}& {-}{3}\\ {4}& {7}\end{array}\right]\right){&*}\left[\begin{array}{rr}{1}& {-}{3}\\ {4}& {7}\end{array}\right]\right){&*}\left[\begin{array}{rr}{1}& {-}{3}\\ {4}& {7}\end{array}\right]\right){&*}\left[\begin{array}{rr}{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}{rr}{14717}& {12681}\\ {-}{16908}& {-}{10645}\end{array}\right]$ (5)
 > $\mathrm{eval}\left(,\left[x=A,\mathrm{&*}=\mathrm{.}\right]\right)$
 $\left[\begin{array}{rr}{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{%A}}}^{{5}}{+}{22}{}{{\mathrm{%A}}}^{{4}}{-}{55}{}{{\mathrm{%A}}}^{{3}}{-}{94}{}{{\mathrm{%A}}}^{{2}}{+}{87}{}{\mathrm{%A}}{-}{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{%A}}\right){.}{\mathrm{%A}}\right){.}{\mathrm{%A}}\right){.}{\mathrm{%A}}\right){.}{\mathrm{%A}}$ (8)
 > $\mathrm{value}\left(\right)$
 $\left[\begin{array}{rr}{14717}& {12681}\\ {-}{16908}& {-}{10645}\end{array}\right]$ (9)