Function Repository Resource:

CompanionMatrix

Source Notebook

Compute the Frobenius companion matrix of a polynomial

Contributed by: Arnoud Buzing

ResourceFunction["CompanionMatrix"][poly,x]

gives the Frobenius companion matrix of the polynomial poly with respect to x.

Details

The Frobenius companion matrix of a given polynomial is a sparse upper Hessenberg matrix whose characteristic polynomial is a constant multiple of the original polynomial.
There are different conventions for the companion matrix where the coefficients of the polynomial may be in the first row or last column. Alternatively, the lower Hessenberg matrix puts coefficients in the last row or first column.
The roots of polynomials are often computed by finding the eigenvalues of the companion matrix.

Examples

Basic Examples (2) 

Compute the companion matrix of a polynomial:

In[1]:=
ResourceFunction["CompanionMatrix"][11 + 7 x + 5 x^2 + 3 x^3 + x^4, x] // MatrixForm
Out[1]=

The characteristic polynomial is the same as the original polynomial:

In[2]:=
CharacteristicPolynomial[%, x]
Out[2]=

Properties and Relations (2) 

Define a polynomial:

In[3]:=
poly = 5 + 4 x + 3 x^2 + 2 x^3 + x^4 + x^5
Out[3]=

CompanionMatrix is a special case of the resource function GeneralizedFiedlerMatrix:

In[4]:=
ResourceFunction["CompanionMatrix"][poly, x] // MatrixForm
Out[4]=
In[5]:=
With[{n = Exponent[poly, x]}, ResourceFunction["GeneralizedFiedlerMatrix"][Range[n, 1, -1], poly, x]] // MatrixForm
Out[5]=

Publisher

Arnoud Buzing

Requirements

Wolfram Language 12.3 (May 2021) or above

Version History

  • 1.0.0 – 01 December 2023

Related Resources

License Information