# Error in computation of eigenvalues in Sage

Dear all,

I am trying to compute the eigenvalues of the following matrix

J = matrix
([[-Q1,0,0,0,omega,0,0,0,0,-A1],[0,-Q2,0,0,0,omega,0,0,0,A1],[0,gamma,Q3,0,0,0,omega,0,0,0],[0,0,sigma,-Q1,0,0,0,omega,0,0],[A2,0,0,0,-Q4,0,0,0,0,0],[0,A2,0,0,0,-Q4,0,0,0,0],[0,0,A2,0,0,0,-Q4,0,0,0],[0,0,0,A2,0,0,0,-Q4,0,0],[0,0,-A3,0,0,0,0,0,-mu_v,0],[0,0,A3,0,0,0,0,0,0,-mu_v]])
J

J.eigenvalues()


Unfortunately am getting the following error.

*#0:
eigenvalues(mat=matrix([-_SAGE_VAR_Q1,0,0,0,_SAGE_VAR_omega,0,0,0,0,-_SA\
GE_VAR_A1],[0,-_SAGE_VAR_Q2,0,0,0,_SAGE_VAR_...)
Traceback (click to the left of this block for traceback)
...
TypeError: ECL says: Error executing code in Maxima: part: fell off the
end.*


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 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.

( 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

var('sigma,omega,Q1,Q2,Q3,Q4,A1,A2,A3,mu_v')

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

you forgot gamma ;-)

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

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

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

Sort by » oldest newest most voted

Hello,

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']
R.inject_variables()
J = matrix(R,[[-Q1,0,0,0,omega,0,0,0,0,-A1],
[0,-Q2,0,0,0,omega,0,0,0,A1],
[0,gamma,Q3,0,0,0,omega,0,0,0],
[0,0,sigma,-Q1,0,0,0,omega,0,0],
[A2,0,0,0,-Q4,0,0,0,0,0],
[0,A2,0,0,0,-Q4,0,0,0,0],
[0,0,A2,0,0,0,-Q4,0,0,0],
[0,0,0,A2,0,0,0,-Q4,0,0],
[0,0,-A3,0,0,0,0,0,-mu_v,0],
[0,0,A3,0,0,0,0,0,0,-mu_v]])
p = J.charpoly().subs(R('x'))
p.factor()


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.

Vincent

more

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

p.factor()

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

( 2015-08-11 12:13:02 +0200 )edit
1

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

( 2015-08-11 18:50:38 +0200 )edit

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]);
eigenvalues(M);


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.

more

@nbruin did you report the error?

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

I think the bug was already found and reported with an earlier example: [https://sourceforge.net/p/maxima/bugs...]

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

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

( 2015-08-11 12:05:38 +0200 )edit
1

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)

( 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]]

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