type/MatrixPolynomialObject - Maple Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : type/MatrixPolynomialObject

convert/MatrixPolynomialObject

convert a matrix polynomial or scalar polynomial to a standard internal representation

type/MatrixPolynomialObject

test for a MatrixPolynomialObject

 Calling Sequence convert(p, MatrixPolynomialObject, x) convert(values, MatrixPolynomialObject, nodes) type(expr, MatrixPolynomialObject, x)

Parameters

 p - polynomial expressed in any of a number of polynomial bases x - name; the variable for the polynomial values - list of values of the (matrix or scalar) polynomial p at the (distinct) nodes nodes - list of algebraic expressions representing distinct scalar nodes expr - arbitrary Maple object

Description

 • The convert(p, MatrixPolynomialObject, x) function converts the (matrix or scalar) polynomial p into a standard representation, a Record. This allows systematic (conventional) access to the polynomial properties, such as Degree, in a manner independent of the polynomial basis.  The bases understood by MatrixPolynomialObject include:

 and most others understood by the OrthogonalSeries package.  This routine is used internally by LinearAlgebra[CompanionMatrix].
 • If the input polynomial p contains more than one basis, then this (heuristic) conversion will fail.
 • The type(expr, MatrixPolynomialObject) function checks whether expr is a Record of the type returned by convert(...,MatrixPolynomialObject).
 • A MatrixPolynomialObject record has the following fields:
 Basis - the name of the basis used; either PowerBasis or any of the supported basis names listed above.
 BasisParameters - a list of the parameters of the particular basis; e.g. for LagrangeBasis or NewtonBasis these are the nodes; for BernsteinBasis these are the degree n and the left and right ends a and b of the interval.
 Coefficient - a procedure to return a specific coefficient matrix. It takes as argument a nonnegative integer less or equal to Degree and returns a Matrix.
 Degree - a nonnegative integer; the degree of the polynomial (in the LagrangeBasis or BernsteinBasis case, an upper bound on the degree).
 Dimension - a positive integer; the matrix dimension $s$ of the matrix polynomial ($s=1$ if the original polynomial is a scalar polynomial).
 IsMonic - a procedure without arguments returning true or false, depending on whether the polynomial is known to be monic (not relevant for Lagrange or Bernstein bases).
 OutputOptions - a list of output options for the coefficient Matrices (see MatrixOptions).
 Value - a procedure to evaluate the polynomial at any point. It takes as an argument the point (an algebraic expression) and returns a Matrix.
 Variable - a name; the original variable used to define the polynomial (which may be unspecified in the LagrangeBasis case).

Examples

 > $p≔\mathrm{add}\left(\frac{k+1}{k+2}\mathrm{ChebyshevT}\left(k,x\right),k=0..5\right)$
 ${p}{≔}\frac{{\mathrm{ChebyshevT}}{}\left({0}{,}{x}\right)}{{2}}{+}\frac{{2}{}{\mathrm{ChebyshevT}}{}\left({1}{,}{x}\right)}{{3}}{+}\frac{{3}{}{\mathrm{ChebyshevT}}{}\left({2}{,}{x}\right)}{{4}}{+}\frac{{4}{}{\mathrm{ChebyshevT}}{}\left({3}{,}{x}\right)}{{5}}{+}\frac{{5}{}{\mathrm{ChebyshevT}}{}\left({4}{,}{x}\right)}{{6}}{+}\frac{{6}{}{\mathrm{ChebyshevT}}{}\left({5}{,}{x}\right)}{{7}}$ (1)
 > $P≔\mathrm{convert}\left(p,\mathrm{MatrixPolynomialObject},x\right)$
 ${P}{≔}{\mathrm{Record}}{}\left({\mathrm{Value}}{=}{{\mathrm{Default}}}_{{\mathrm{value}}}{,}{\mathrm{Variable}}{=}{x}{,}{\mathrm{Degree}}{=}{5}{,}{\mathrm{Coefficient}}{=}{\mathrm{coe}}{,}{\mathrm{Dimension}}{=}\left[{1}{,}{1}\right]{,}{\mathrm{Basis}}{=}{\mathrm{ChebyshevT}}{,}{\mathrm{BasisParameters}}{=}\left[\right]{,}{\mathrm{IsMonic}}{=}{\mathrm{mon}}{,}{\mathrm{OutputOptions}}{=}\left[{\mathrm{shape}}{=}\left[\right]{,}{\mathrm{storage}}{=}{\mathrm{rectangular}}{,}{\mathrm{order}}{=}{\mathrm{Fortran_order}}{,}{\mathrm{fill}}{=}{0}{,}{\mathrm{attributes}}{=}\left[\right]\right]\right)$ (2)
 > $P:-\mathrm{Degree}$
 ${5}$ (3)
 > $P:-\mathrm{Dimension}$
 $\left[{1}{,}{1}\right]$ (4)
 > $P:-\mathrm{Value}\left(0.3\right)$
 $\left[\begin{array}{c}{0.5949161905}\end{array}\right]$ (5)

Lagrange basis.

 > $\mathrm{nodes}≔\left[-1,-\frac{1}{3},\frac{1}{3},1\right]$
 ${\mathrm{nodes}}{≔}\left[{-1}{,}{-}\frac{{1}}{{3}}{,}\frac{{1}}{{3}}{,}{1}\right]$ (6)
 > $\mathrm{values}≔\left[-1,1,-1,1\right]$
 ${\mathrm{values}}{≔}\left[{-1}{,}{1}{,}{-1}{,}{1}\right]$ (7)
 > $P≔\mathrm{convert}\left(\mathrm{values},\mathrm{MatrixPolynomialObject},\mathrm{nodes}\right)$
 ${P}{≔}{\mathrm{Record}}{}\left({\mathrm{Value}}{=}{{\mathrm{Default}}}_{{\mathrm{value}}}{,}{\mathrm{Variable}}{=}{\mathrm{_X1}}{,}{\mathrm{Degree}}{=}{3}{,}{\mathrm{Coefficient}}{=}{\mathrm{coe}}{,}{\mathrm{Dimension}}{=}\left[{1}{,}{1}\right]{,}{\mathrm{Basis}}{=}{\mathrm{LagrangeBasis}}{,}{\mathrm{BasisParameters}}{=}\left[\left[{-1}{,}{-}\frac{{1}}{{3}}{,}\frac{{1}}{{3}}{,}{1}\right]\right]{,}{\mathrm{IsMonic}}{=}{\mathrm{mon}}{,}{\mathrm{OutputOptions}}{=}\left[{\mathrm{shape}}{=}\left[\right]{,}{\mathrm{storage}}{=}{\mathrm{rectangular}}{,}{\mathrm{order}}{=}{\mathrm{Fortran_order}}{,}{\mathrm{fill}}{=}{0}{,}{\mathrm{attributes}}{=}\left[\right]\right]\right)$ (8)
 > $P:-\mathrm{Degree}$
 ${3}$ (9)
 > $P:-\mathrm{Value}\left(0.3\right)$
 $\left[\begin{array}{c}{-0.9284999999}\end{array}\right]$ (10)
 > $\mathrm{pinterp}≔\mathrm{CurveFitting}:-\mathrm{PolynomialInterpolation}\left(\mathrm{nodes},\mathrm{values},t,\mathrm{form}=\mathrm{Lagrange}\right)$
 ${\mathrm{pinterp}}{≔}\frac{{9}{}\left({t}{+}\frac{{1}}{{3}}\right){}\left({t}{-}\frac{{1}}{{3}}\right){}\left({t}{-}{1}\right)}{{16}}{+}\frac{{27}{}\left({t}{+}{1}\right){}\left({t}{-}\frac{{1}}{{3}}\right){}\left({t}{-}{1}\right)}{{16}}{+}\frac{{27}{}\left({t}{+}{1}\right){}\left({t}{+}\frac{{1}}{{3}}\right){}\left({t}{-}{1}\right)}{{16}}{+}\frac{{9}{}\left({t}{+}{1}\right){}\left({t}{+}\frac{{1}}{{3}}\right){}\left({t}{-}\frac{{1}}{{3}}\right)}{{16}}$ (11)
 > $\mathrm{normal}\left(\frac{\mathrm{pinterp}}{P:-\mathrm{Value}\left(t\right)\left[1,1\right]}\right)$
 ${1}$ (12)

Bernstein Basis: note that the zeros of p are the eigenvalues of the companion matrix pencil of p.

 > $N≔4$
 ${N}{≔}{4}$ (13)
 > $p≔\mathrm{add}\left(\frac{{k}^{3}}{k+1}\mathrm{BernsteinBasis}\left(k,N,0,1,x\right),k=0..N\right)$
 ${p}{≔}\frac{{\mathrm{BernsteinBasis}}{}\left({1}{,}{4}{,}{0}{,}{1}{,}{x}\right)}{{2}}{+}\frac{{8}{}{\mathrm{BernsteinBasis}}{}\left({2}{,}{4}{,}{0}{,}{1}{,}{x}\right)}{{3}}{+}\frac{{27}{}{\mathrm{BernsteinBasis}}{}\left({3}{,}{4}{,}{0}{,}{1}{,}{x}\right)}{{4}}{+}\frac{{64}{}{\mathrm{BernsteinBasis}}{}\left({4}{,}{4}{,}{0}{,}{1}{,}{x}\right)}{{5}}$ (14)
 > $P≔\mathrm{convert}\left(p,\mathrm{MatrixPolynomialObject},x\right)$
 ${P}{≔}{\mathrm{Record}}{}\left({\mathrm{Value}}{=}{{\mathrm{Default}}}_{{\mathrm{value}}}{,}{\mathrm{Variable}}{=}{x}{,}{\mathrm{Degree}}{=}{4}{,}{\mathrm{Coefficient}}{=}{\mathrm{coe}}{,}{\mathrm{Dimension}}{=}\left[{1}{,}{1}\right]{,}{\mathrm{Basis}}{=}{\mathrm{BernsteinBasis}}{,}{\mathrm{BasisParameters}}{=}\left[{4}{,}{0}{,}{1}\right]{,}{\mathrm{IsMonic}}{=}{\mathrm{mon}}{,}{\mathrm{OutputOptions}}{=}\left[{\mathrm{shape}}{=}\left[\right]{,}{\mathrm{storage}}{=}{\mathrm{rectangular}}{,}{\mathrm{order}}{=}{\mathrm{Fortran_order}}{,}{\mathrm{fill}}{=}{0}{,}{\mathrm{attributes}}{=}\left[\right]\right]\right)$ (15)
 > $\mathrm{type}\left(P,\mathrm{MatrixPolynomialObject}\right)$
 ${\mathrm{true}}$ (16)
 > $\mathrm{Digits}≔\mathrm{trunc}\left(\mathrm{evalhf}\left(\mathrm{Digits}\right)\right)$
 ${\mathrm{Digits}}{≔}{15}$ (17)
 > $P:-\mathrm{Value}\left(0.3\right)$
 $\left[\begin{array}{c}{1.52538000000000}\end{array}\right]$ (18)
 > $\mathrm{C0},\mathrm{C1}≔\mathrm{LinearAlgebra}\left[\mathrm{CompanionMatrix}\right]\left(P,x\right)$
 ${\mathrm{C0}}{,}{\mathrm{C1}}{≔}\left[\begin{array}{cccc}{0}& {0}& {0}& {0}\\ {1}& {0}& {0}& {-}\frac{{1}}{{2}}\\ {0}& {1}& {0}& {-}\frac{{8}}{{3}}\\ {0}& {0}& {1}& {-}\frac{{27}}{{4}}\end{array}\right]{,}\left[\begin{array}{cccc}{4}& {0}& {0}& {0}\\ {1}& \frac{{3}}{{2}}& {0}& {-}\frac{{1}}{{2}}\\ {0}& {1}& \frac{{2}}{{3}}& {-}\frac{{8}}{{3}}\\ {0}& {0}& {1}& {-}\frac{{71}}{{20}}\end{array}\right]$ (19)
 > $E≔\mathrm{LinearAlgebra}\left[\mathrm{Eigenvalues}\right]\left(\mathrm{evalf}\left(\mathrm{C0}\right),\mathrm{evalf}\left(\mathrm{C1}\right)\right)$
 ${E}{≔}\left[\begin{array}{c}{10.0659400730377}{+}{0.}{}{I}\\ {-4.86159366800340}{+}{0.}{}{I}\\ {-0.204346405034140}{+}{0.}{}{I}\\ {0.}{+}{0.}{}{I}\end{array}\right]$ (20)
 > $\mathrm{map}\left(t→{P:-\mathrm{Value}\left(t\right)}_{1,1},E\right)$
 $\left[\begin{array}{c}{-1.05501385405660}{×}{{10}}^{{-10}}\\ {-1.00044417195022}{×}{{10}}^{{-11}}\\ {-1.11022302462516}{×}{{10}}^{{-16}}\\ {0.}\end{array}\right]$ (21)

A matrix polynomial example.

 > $\mathrm{A0},\mathrm{A1},\mathrm{A2}≔\mathrm{LinearAlgebra}\left[\mathrm{RandomMatrix}\right]\left(3,3\right),\mathrm{LinearAlgebra}\left[\mathrm{RandomMatrix}\right]\left(3,3\right),\mathrm{LinearAlgebra}\left[\mathrm{RandomMatrix}\right]\left(3,3\right)$
 ${\mathrm{A0}}{,}{\mathrm{A1}}{,}{\mathrm{A2}}{≔}\left[\begin{array}{ccc}{-74}& {8}& {29}\\ {-4}& {69}& {44}\\ {27}& {99}& {92}\end{array}\right]{,}\left[\begin{array}{ccc}{-98}& {27}& {-72}\\ {-77}& {-93}& {-2}\\ {57}& {-76}& {-32}\end{array}\right]{,}\left[\begin{array}{ccc}{-9}& {45}& {-18}\\ {-50}& {-81}& {87}\\ {-22}& {-38}& {33}\end{array}\right]$ (22)
 > $\mathrm{nodes}≔\left[-1,0,1\right]$
 ${\mathrm{nodes}}{≔}\left[{-1}{,}{0}{,}{1}\right]$ (23)
 > $P≔\mathrm{convert}\left(\left[\mathrm{A0},\mathrm{A1},\mathrm{A2}\right],\mathrm{MatrixPolynomialObject},\mathrm{nodes}\right)$
 ${P}{≔}{\mathrm{Record}}{}\left({\mathrm{Value}}{=}{{\mathrm{Default}}}_{{\mathrm{value}}}{,}{\mathrm{Variable}}{=}{\mathrm{_X4}}{,}{\mathrm{Degree}}{=}{2}{,}{\mathrm{Coefficient}}{=}{\mathrm{coe}}{,}{\mathrm{Dimension}}{=}\left[{3}{,}{3}\right]{,}{\mathrm{Basis}}{=}{\mathrm{LagrangeBasis}}{,}{\mathrm{BasisParameters}}{=}\left[\left[{-1}{,}{0}{,}{1}\right]\right]{,}{\mathrm{IsMonic}}{=}{\mathrm{mon}}{,}{\mathrm{OutputOptions}}{=}\left[{\mathrm{shape}}{=}\left[\right]{,}{\mathrm{storage}}{=}{\mathrm{rectangular}}{,}{\mathrm{order}}{=}{\mathrm{Fortran_order}}{,}{\mathrm{fill}}{=}{0}{,}{\mathrm{attributes}}{=}\left[\right]\right]\right)$ (24)
 > $P:-\mathrm{Value}\left(0.3\right)$
 $\left[\begin{array}{ccc}{-83.1649999999999}& {32.5050000000000}& {-72.0749999999999}\\ {-79.3999999999999}& {-107.670000000000}& {10.5250000000000}\\ {44.7449999999999}& {-86.9649999999999}& {-32.3450000000000}\end{array}\right]$ (25)
 > $\mathrm{C0},\mathrm{C1}≔\mathrm{LinearAlgebra}\left[\mathrm{CompanionMatrix}\right]\left(P,\mathrm{dummy}\right)$
 ${\mathrm{C0}}{,}{\mathrm{C1}}{≔}\begin{array}{c}\left[\begin{array}{ccccccccccc}{1}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {74}& {\dots }\\ {0}& {1}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {-8}& {\dots }\\ {0}& {0}& {1}& {0}& {0}& {0}& {0}& {0}& {0}& {-29}& {\dots }\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {98}& {\dots }\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {-27}& {\dots }\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {72}& {\dots }\\ {0}& {0}& {0}& {0}& {0}& {0}& {-1}& {0}& {0}& {9}& {\dots }\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {-1}& {0}& {-45}& {\dots }\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {-1}& {18}& {\dots }\\ \frac{{1}}{{2}}& {0}& {0}& {-1}& {0}& {0}& \frac{{1}}{{2}}& {0}& {0}& {0}& {\dots }\\ {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {}\end{array}\right]\\ \hfill {\text{12 × 12 Matrix}}\end{array}{,}\begin{array}{c}\left[\begin{array}{ccccccccccc}{-1}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {\dots }\\ {0}& {-1}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {\dots }\\ {0}& {0}& {-1}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {\dots }\\ {0}& {0}& {0}& {-1}& {0}& {0}& {0}& {0}& {0}& {0}& {\dots }\\ {0}& {0}& {0}& {0}& {-1}& {0}& {0}& {0}& {0}& {0}& {\dots }\\ {0}& {0}& {0}& {0}& {0}& {-1}& {0}& {0}& {0}& {0}& {\dots }\\ {0}& {0}& {0}& {0}& {0}& {0}& {-1}& {0}& {0}& {0}& {\dots }\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {-1}& {0}& {0}& {\dots }\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {-1}& {0}& {\dots }\\ {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {0}& {\dots }\\ {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {⋮}& {}\end{array}\right]\\ \hfill {\text{12 × 12 Matrix}}\end{array}$ (26)

 See Also