On 11/16/11 9:20 AM, Andres Cimmarusti wrote:
> Dear all,
>
> First of all thank you for all your answers. I managed to solve the
> problem using allroots as you pointed out. However I don't have
> eigenvectors now. Here are a few responses on your comments
>
>> Of course, lapack has a version for complex matrixes, but no one has hooked
>> that up for maxima. It's not difficult to do, but will take a little bit of
>> time. I cannot do that until later next week at the earliest.
> That would really make my day and I think it would be useful for other
> users. I suppose I can use lapack directly without using maxima, but
> the reason for using maxima in the first place, is that before doing
> numerical solutions, there's a decent bit of algebra involved.
I have checked in support for lapack zgeev, which computes the
eigenvalues and (optionally) the eigenvectors of a general complex
matrix. Here is an example of the usage:
(%i1) load(lapack);
;; Loading
#P"/Volumes/share2/src/sourceforge/maxima/share/lapack/lapack.system".
[snip]
(%o1) /Volumes/share2/src/sourceforge/maxima/share/lapack/lapack.mac
(%i2) display2d:false;
Evaluation took 0.0000 seconds (0.0000 elapsed) using 32 bytes.
(%o2) false
(%i3) A:matrix([-3.97-5.04*%i, -4.11+3.7*%i, -.34+1.01*%i, 1.29-.86*%i],
[.34-1.5*%i, 1.52-.43*%i,1.88-5.38*%i, 3.36+.65*%i], [3.31-3.85*%i,
2.5+3.45*%i, .88-1.08*%i, .64-1.48*%i], [-1.1+.82*%i, 1.81-1.59*%i,
3.25+1.33*%i, 1.57-3.44*%i]);
Evaluation took 0.0000 seconds (0.0000 elapsed) using 4.836 KB.
(%o3) matrix([-5.04*%i-3.97,3.7*%i-4.11,1.01*%i-0.34,1.29-0.86*%i],
[0.34-1.5*%i,1.52-0.43*%i,1.88-5.38*%i,0.65*%i+3.36],
[3.31-3.85*%i,3.45*%i+2.5,0.88-1.08*%i,0.64-1.48*%i],
[0.82*%i-1.1,1.81-1.59*%i,1.33*%i+3.25,1.57-3.44*%i])
(%i4) zgeev(A, true);
Evaluation took 0.0100 seconds (0.0100 elapsed) using 891.227 KB.
(%o4) [[-6.999843371570387*%i-6.000425342949248,
2.006027162316514*%i-5.000033457596964,
7.998194516208248-.9963650913928996*%i,
3.002264284337972-3.999818699353223*%i],
matrix([.8457221269095605,.1732346317429521*%i-.3865491118384048,
.2668960805541836*%i-.1729741214922218,
-.1782180414203164*%i-.03561357879442444],
[.3036074022088088*%i-.01772275253765543,
.4528809670358095*%i-.3539288131601223,.6924232122846427,
.2666323741075225*%i+.1263742620790907],
[.3114528298152489*%i+.08752124466951977,.6123700548961366,
.4959799871283028*%i+.3324022684534099,
.01293256133328227-.2965682030735418*%i],
[-.2905979861233139*%i-.05614722089937191,
-.3283626113415364*%i-0.0859283582589069,
.2503883898017165-.01465500310353839*%i,.8898240137592393]),
false]
(%i5) expand(A . col(%o4[2],1) - %o4[1][1] * col(%o4[2],1));
Evaluation took 0.0000 seconds (0.0000 elapsed) using 39.758 KB.
(%o5) matrix([4.662936703425657e-15-2.442490654175344e-15*%i],
[1.970645868709653e-15-2.664535259100376e-15*%i],
[-3.441691376337985e-15*%i-1.332267629550188e-15],
[-1.332267629550188e-15*%i-1.110223024625157e-15])
%o5 shows that at least the first eigenvalue and eigenvector are truly
an eigenvalue and eigenvector of the matrix A.
Note that it takes quite a long time to compile and load lapack now.
Perhaps it is worthwhile to separate that out into two parts: one for
real matrices and one for complex matrices. The lapack routine for
real eigenvalues has been around for a bit and only recently have you
asked for complex matrices. I take this to mean that most people have
been working with real matrices.
Ray