Ask Your Question
1

Error in computation of eigenvalues in Sage

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

komondie gravatar image

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

vdelecroix gravatar image

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 flag offensive close merge delete

Comments

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 +0100 )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')

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

you forgot gamma ;-)

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

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

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

2 Answers

Sort by » oldest newest most voted
1

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

vdelecroix gravatar image

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

edit flag offensive delete link more

Comments

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

komondie gravatar imagekomondie ( 2015-08-11 12:13:02 +0100 )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

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

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

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]);
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.

edit flag offensive delete link more

Comments

@nbruin did you report the error?

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

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

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

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

komondie gravatar imagekomondie ( 2015-08-11 12:05:38 +0100 )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)

nbruin gravatar imagenbruin ( 2015-08-11 19:29:56 +0100 )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 +0100 )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

Stats

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

Seen: 442 times

Last updated: Aug 10 '15