Ask Your Question

Error in computation of eigenvalues in Sage

asked 2015-08-10 11:04:26 +0200

komondie gravatar image

updated 2015-08-10 18:02:30 +0200

vdelecroix gravatar image

Dear all,

I am trying to compute the eigenvalues of the following matrix

J = matrix


Unfortunately am getting the following error.

Traceback (click to the left of this block for traceback)
TypeError: ECL says: Error executing code in Maxima: part: fell off the

When I try with numerical values however, I get eigenvalues. My problem involves a matrix with characters and I want to know the nature of the eigenvalues so that I may draw certain conclusions. What should I do in order to compute my eigenvalues without an error. Thank you for support.

edit retag flag offensive close merge delete


What are Q1, omega, A1, etc...? If you do not give full information about your code we can surely not help you.

vdelecroix gravatar imagevdelecroix ( 2015-08-10 13:57:22 +0200 )edit

Q1 to Q4, omega,sigma,A1 to A3 and mu_v are characters in the matrix and the rest of the columns are zeros. and they are declared as follows


komondie gravatar imagekomondie ( 2015-08-10 16:54:52 +0200 )edit

you forgot gamma ;-)

vdelecroix gravatar imagevdelecroix ( 2015-08-10 18:05:43 +0200 )edit

Am is in the variable,,,,I forgot. I am sorry for the typo error.

komondie gravatar imagekomondie ( 2015-08-10 18:57:24 +0200 )edit

2 Answers

Sort by » oldest newest most voted

answered 2015-08-10 18:16:29 +0200

vdelecroix gravatar image


It seems that Sage is not able to solve your equation symbolically. However, you can compute the characteristic polynomial and try to analyze it

R = ZZ['x,sigma,gamma,omega,Q1,Q2,Q3,Q4,A1,A2,A3,mu_v']
J = matrix(R,[[-Q1,0,0,0,omega,0,0,0,0,-A1],
p = J.charpoly().subs(R('x'))

As you can notice I did not use symbolic variables but polynomial variables that are more powerful (and more predictable). In particular, the factorization with p.factor() takes place in Z[x,sigma,gamma,Q1,...]`.

The answer of the above code shows two small factors

x + mu_v
(-x^2 - x*Q1 - x*Q4 - Q1*Q4 + omega*A2)^2

and a big factor of degree 5. The small factors give you already three eigenvalues (five if counted with multiplicity). The big factor is quite complicated and I doubt there would be any formula.


edit flag offensive delete link more


Thank you so much. This one is working except for the p.factor and is giving the following error


Traceback (click to the left of this block for traceback) ... NotImplementedError: Factorization of multivariate polynomials over non-fields is not implemented.

How do I correct the error please. Thank you

komondie gravatar imagekomondie ( 2015-08-11 12:13:02 +0200 )edit

replace ZZ by QQ in R = ZZ['x,sigma,gamma,omega,Q1,Q2,Q3,Q4,A1,A2,A3,mu_v'] to be able to factor polynomials in several variable

FrédéricC gravatar imageFrédéricC ( 2015-08-11 18:50:38 +0200 )edit

answered 2015-08-10 18:26:47 +0200

nbruin gravatar image

This seems to be a bug in maxima, which should be reported. A little googling shows this error has happened before but not with a very clear input matrix. This script in maxima leads straight to a (hopefully debuggable) error:

M: matrix([-d, 0, 0, 0, v, 0, 0, 0, 0, -a], [0, -e, 0, 0, 0, v, 0, 0, 0, a], [0, w, f, 0, 0, 0, v, 0, 0, 0], [0, 0, t, -d, 0, 0, 0, v, 0, 0], [b, 0, 0, 0, -g, 0, 0, 0, 0, 0], [0, b, 0, 0, 0, -g, 0, 0, 0, 0], [0, 0, b, 0, 0, 0, -g, 0, 0, 0], [0, 0, 0, b, 0, 0, 0, -g, 0, 0], [0, 0, -c, 0, 0, 0, 0, 0, -u, 0], [0, 0, c, 0, 0, 0, 0, 0, 0, -u]);

As a workaround, you can use:

sage: maxima_calculus(M.charpoly()).factor()

which shows you that the characteristic polynomial is of the form linearquadratic^2quintic

sage: M.charpoly().roots()
[(-1/2*Q1 - 1/2*Q4 - 1/2*sqrt(Q1^2 - 2*Q1*Q4 + Q4^2 + 4*A2*omega), 2),
 (-1/2*Q1 - 1/2*Q4 + 1/2*sqrt(Q1^2 - 2*Q1*Q4 + Q4^2 + 4*A2*omega), 2),
 (-mu_v, 1)]

gives you 3 eigenvalues. The eigenvalue corresponding to the quintic factor is not reported here, likely because maxima (which is used for this if I'm not mistaken) doesn't have access to the means to express that eigenvalue properly.

edit flag offensive delete link more


@nbruin did you report the error?

vdelecroix gravatar imagevdelecroix ( 2015-08-10 19:48:45 +0200 )edit

I think the bug was already found and reported with an earlier example: []

nbruin gravatar imagenbruin ( 2015-08-10 21:16:42 +0200 )edit

I did report the error but unfortunately I have not received any response.

komondie gravatar imagekomondie ( 2015-08-11 12:05:38 +0200 )edit

See the bug report. Apparently this issue has been resolved in the current maxima version. Once we upgrade maxima in sage we should be OK (of course, you will still not get all eigenvalues symbolically because maxima's representation for such expressions wouldn't allow a convenient expression for a root of a rather arbitrary degree 5 polynomial)

nbruin gravatar imagenbruin ( 2015-08-11 19:29:56 +0200 )edit

Did verify with the current version of maxima. The result is:

"eigenvalues: solve is unable to find some of the roots of the characteristic polynomial." [[-(sqrt(4A2omega+Q4^2-2Q1Q4+Q1^2)+Q4+Q1)/2,(sqrt(4A2omega+Q4^2-2Q1Q4+Q1^2)-Q4-Q1)/2,-mu_v],[2,2,1]]

gunterkoenigsmann gravatar imagegunterkoenigsmann ( 2015-11-01 04:16:09 +0200 )edit

Your Answer

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

Add Answer

Question Tools


Asked: 2015-08-10 11:04:26 +0200

Seen: 354 times

Last updated: Aug 10 '15