By the way, Maxima can symbolically find the eigenvectors of your matrix:
(%i1) mm :
matrix([1,-1,0,0,0,0,0],[-1,3,-1,0,-1,0,0],[0,-1,3,-1,0,-1,0],[0,0,-1,3,0,0,
-1],[0,-1,0,0,3,-1,0],[0,0,-1,0,-1,4,-1],[0,0,0,-1,0,-1,4])$
(%i2) % - z * identfor(%)$
Triangularize mm - z * I
(%i3) m : ptriangularize(%,z)$
The eigenvalues are the zeros of the last diagonal entry of m; let's find
double float approximations to them
(%i4) p : last(last(m));
(%o4)
(841*z^7)/27-(5887*z^6)/9+(149698*z^5)/27-(656821*z^4)/27+(1583603*z^3)/27-(2037743*z^2)/27+(1227019*z)/27-236321/27
(%i5) e : allroots(p);
(%o5)
[z=0.34196379221283,z=1.182773529427571,z=2.283105468648623,z=3.091176583511703,z=
3.766334843915194,z=4.416178959413278,z=5.918466822870803]
Tell Maxima that p vanishes:
(%i6) algebraic : true$
(%i7) tellrat(p)$
Find the nullspace of m; these give the eigenvectors of mm.
(%i33) ns : nullspace(m);
Proviso: notequal(3-z,0)
(%o33)
span(matrix([136242*z^6-2338821*z^5+15259104*z^4-47480337*z^3+71935776*z^2-47230560*z+9060093],
...])
Here z is any eigenvalue of mm. This isn't a good thing to do, but let's
try pasting in the
double float values for the eigenvalues and construct a matrix of the
eigenvectors--I'll
normalize each column:
(%i38) v : lreduce('addcol,makelist(block([w : first(subst(ei, ns))], w /
sqrt(w.w)),ei, e));
(%o38)
matrix([-0.73980021292004,0.55478655642707,-0.251328394792,-0.19701943775753,
...])
(%i39) load("diag")$
And let's check:
(%i40) mm . v - v . diag(map('rhs,e));
(%o40)
matrix([3.8857805861880479*10^-15,4.1411318818518339
*10^-14,-1.5504264538890311*10^-12, ...
A much better way is to use a numerical method from the start:
(%i44) eigens_by_jacobi(mm, 'bigfloatfield), fpprec : 18;
(%o44) [[3.41963792212829723b-1,5.91846682287041054b0,1.1827735294275732
b0,3.76633484391190218b0,
2.28310546864854545b0,3.09117658351302932b0,4.4161789594157096b0],
matrix([7.39800212920038619b-1,-5.20772876894392075b-2,-5.54786556427101463
b-1, ...])
Barton
-----maxima-bounces at math.utexas.edu wrote: -----
>I am probably doing something silly and don't realise it but here goes...
>
>I am trying to find the eigen values and eigen vectors of a matrix, but
>maxima keeps giving me an error (run on win XP in wxMaxima)
>
>
>(%i37)E:
>matrix([1,-1,0,0,0,0,0],[-1,3,-1,0,-1,0,0],[0,-1,3,-1,0,-1,0],[0,0,-1,3,0,
>0,-1],[0,
> -1,0,0,3,-1,0],[0,0,-1,0,-1,4,-1],[0,0,0,-1,0,-1,4]);
>
>(%o37)
>matrix([1,-1,0,0,0,0,0],[-1,3,-1,0,-1,0,0],[0,-1,3,-1,0,-1,0],[0,0,-1,3,0,
>0,-1],[0,-1,0,0,3,-1,0],[0,0,-1,0,-1,4,-1],[0,0,0,-1,0,-1,4])
>
>
>(%i38) eigenvalues(E);
>
>solve is unable to find the roots of the characteristic polynomial.