Function Repository Resource:

# MatrixPolynomial

Evaluate a matrix polynomial

Contributed by: Jan Mangaldan
 ResourceFunction["MatrixPolynomial"][p,m] gives the matrix generated by the polynomial function p at the matrix argument m. ResourceFunction["MatrixPolynomial"][p,m,v] gives the matrix generated by the polynomial function p at the matrix argument m, applied to the vector v.

## Details

ResourceFunction["MatrixPolynomial"][p,m] effectively evaluates the polynomial function p with ordinary powers replaced by matrix powers.
ResourceFunction["MatrixPolynomial"][{c0,c1,,cn},m] with scalar ci takes the polynomial function to be .
ResourceFunction["MatrixPolynomial"] works only on square matrices.
ResourceFunction["MatrixPolynomial"] can be used on SparseArray objects.

## Examples

### Basic Examples (1)

Compute a matrix polynomial, specifying the polynomial as a pure function:

 In[1]:=
 Out[1]=

### Scope (5)

Evaluate a matrix polynomial with a machine-precision matrix:

 In[2]:=
 Out[2]=

The polynomial can be specified as a list of coefficients:

 In[3]:=
 Out[3]=

Evaluate a matrix polynomial with a complex matrix:

 In[4]:=
 Out[4]=

Evaluate a matrix polynomial with an arbitrary-precision matrix:

 In[5]:=
 Out[5]=

Evaluating a matrix polynomial with a large machine-precision matrix is efficient:

 In[6]:=
 Out[7]=

Directly applying the matrix polynomial to a single vector is even more efficient:

 In[8]:=
 Out[9]=

Compute a matrix polynomial applied to a vector for a sparse matrix:

 In[10]:=
 Out[12]=

### Applications (2)

Evaluate a matrix rational function:

 In[13]:=
 Out[13]=
 In[14]:=
 Out[17]=

Compare with the result of MatrixFunction:

 In[18]:=
 Out[18]=

### Properties and Relations (2)

MatrixPolynomial is more efficient than MatrixFunction:

 In[19]:=
 Out[19]=
 In[20]:=
 Out[20]=

If m is diagonalizable with m=v.d.v-1 and the eigenvectors are well conditioned, then p(m)=v.p(d).v-1:

 In[21]:=
 Out[23]=
 In[24]:=
 Out[24]=

### Neat Examples (1)

Demonstrate the Cayley–Hamilton theorem:

 In[25]:=
 Out[25]=
 In[26]:=
 Out[26]=

## Version History

• 1.0.0 – 08 March 2021