Processing math: 100%
Ask Your Question
1

eigenvalues vs roots of characteristic polynomial

asked 9 years ago

Laurent B gravatar image

updated 9 years ago

slelievre gravatar image

Hi,

Sorry if this is a stupid question but I am struggling to make Sage compute the exact eigenvalues of a matrix. I am also confused that when I ask for the roots of the characteristic polynomial Sage answers with complex roots... I am new to Sage so please forgive me :)

Here is my worksheet:

sage: A = matrix([[1, 1, 2], [1, -2, 0], [2, 0, 1]])
sage: A
[ 1  1  2]
[ 1 -2  0]
[ 2  0  1]
sage: A.eigenvalues()
[-2.439311671683875?, -0.6611203141265045?, 3.100431985810380?]
sage: x = var('x')
sage: H = A.charpoly()
sage: H
x^3 - 8*x - 5
sage: H.roots()
[]
sage: (x^3-8*x-5).roots()
[(-1/2*(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3)*(I*sqrt(3) + 1) + 1/3*(4*I*sqrt(3) - 4)/(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3),
  1),
 (-1/2*(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3)*(-I*sqrt(3) + 1) + 1/3*(-4*I*sqrt(3) - 4)/(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3),
  1),
 ((1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3) + 8/3/(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3),
  1)]
Preview: (hide)

2 Answers

Sort by » oldest newest most voted
0

answered 9 years ago

tmonteil gravatar image

updated 9 years ago

If you type A.eigenvalues? you will get the documentation of this method that says " If the eigenvalues are roots of polynomials in QQ, then QQbar elements are returned that represent each separate root." which means that you will get the eigenvalues as algebraic numbers.

sage: [r.parent() for r in A.eigenvalues()]
[Algebraic Field, Algebraic Field, Algebraic Field]

Now, when you write H=A.charpoly() you define a polynomial over the integers:

sage: H=A.charpoly()
sage: H.parent()
Univariate Polynomial Ring in x over Integer Ring

In particular, the roots will be provided in this ring, and there is no integer root for this polynomial. If you want the algebraic roots, you can write:

sage: H.roots(ring=QQbar)
[(-2.439311671683875?, 1), (-0.6611203141265045?, 1), (3.100431985810380?, 1)]

You can check that the two lists are equal :

sage: H.roots(ring=QQbar, multiplicities=False) == A.eigenvalues()
True

As for your last polynomial, you define it over the symbolic, which explains why you get the roots as symbolic expressions.

Preview: (hide)
link

Comments

Thanks for your help; and as I suspected the only problem was my own ignorance. Is there any way to ask Sage to give the roots in radicals form instead of decimal notation ?

Laurent B gravatar imageLaurent B ( 9 years ago )
0

answered 9 years ago

slelievre gravatar image

Here is an illustration of getting radical expressions for the eigenvalues.

sage: A = matrix([[1, 1, 2], [1, -2, 0], [2, 0, 1]])
sage: a, b, c = A.eigenvalues()
sage: a, b, c
(-2.439311671683875?, -0.6611203141265045?, 3.100431985810380?)
sage: a.radical_expression()
-1/2*(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3)*(-I*sqrt(3) + 1) + 1/3*(-4*I*sqrt(3) - 4)/(1/18*I*sqrt(1373)*sqrt(3) + 5/2)^(1/3)

Note that they are not nice radical expressions.

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 9 years ago

Seen: 2,372 times

Last updated: Dec 19 '15