Ask Your Question
1

eigenvalues vs roots of characteristic polynomial

asked 2015-12-17 14:58:59 +0200

Laurent B gravatar image

updated 2015-12-19 23:34:55 +0200

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)]
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-12-17 22:39:08 +0200

tmonteil gravatar image

updated 2015-12-17 22:41:53 +0200

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.

edit flag offensive delete link more

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 ( 2015-12-19 20:38:09 +0200 )edit
0

answered 2015-12-19 23:39:59 +0200

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.

edit flag offensive delete link more

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: 2015-12-17 14:58:59 +0200

Seen: 1,786 times

Last updated: Dec 19 '15