next | previous | forward | backward | up | top | index | toc | Macaulay2 website
DeterminantalRepresentations :: companionMatrix

companionMatrix -- companion matrix of a univariate polynomial

Synopsis

Description

For a monic univariate polynomial $f$ of degree $d$, this method returns the companion matrix $C(f)$, which is a $d\times d$ matrix whose characteristic polynomial is $f$. Explicitly, $C(f)$ has entries $1$ on the first subdiagonal (the diagonal below the main diagonal), negative coefficients of $f$ in the last column (other than the leading coefficient of $1$), and $0$ elsewhere.

If $f$ is not monic, then this method returns the companion matrix of the normalized monic polynomial $(1/a_n)f$, where $a_n$ is the leading coefficient of $f$.

i1 : R = CC[x]

o1 = R

o1 : PolynomialRing
i2 : eigenvalues companionMatrix(9*x^2 - 1)

o2 = {.333333 }
     {-.333333}

o2 : VerticalList
i3 : f = x^10 + sum(10, i -> random(i, R))
-- warning: experimental computation over inexact field begun
--          results not reliable (one warning given per session)

      10                          9                          8             
o3 = x   + (.741046 + .108386*ii)x  + (.127435 + .254482*ii)x  + (.362835 +
     ------------------------------------------------------------------------
                 7                           6                          5  
     .706096*ii)x  + (.0741835 + .808694*ii)x  + (.909047 + .314897*ii)x  +
     ------------------------------------------------------------------------
                            4                         3              
     (.461944 + .775187*ii)x  + (.89189 + .231053*ii)x  + (.0258884 +
     ------------------------------------------------------------------------
                 2
     .714827*ii)x  + (.29398 + .632944*ii)x + .892712 + .673395*ii

o3 : R
i4 : C = companionMatrix f

o4 = | 0 0 0 0 0 0 0 0 0 -.892712-.673395ii  |
     | 1 0 0 0 0 0 0 0 0 -.29398-.632944ii   |
     | 0 1 0 0 0 0 0 0 0 -.0258884-.714827ii |
     | 0 0 1 0 0 0 0 0 0 -.89189-.231053ii   |
     | 0 0 0 1 0 0 0 0 0 -.461944-.775187ii  |
     | 0 0 0 0 1 0 0 0 0 -.909047-.314897ii  |
     | 0 0 0 0 0 1 0 0 0 -.0741835-.808694ii |
     | 0 0 0 0 0 0 1 0 0 -.362835-.706096ii  |
     | 0 0 0 0 0 0 0 1 0 -.127435-.254482ii  |
     | 0 0 0 0 0 0 0 0 1 -.741046-.108386ii  |

                10          10
o4 : Matrix CC     <--- CC
              53          53
i5 : clean(1e-10, f - det(x*id_(R^10) - C))

o5 = 0

o5 : R
i6 : all(eigenvalues C, z -> clean(1e-10, sub(f, R_0 => z)) == 0)

o6 = true

Ways to use companionMatrix :

For the programmer

The object companionMatrix is a method function.