How to calculate the Eigenvector of a symbolic matrix in Maple?

1k Views Asked by At

I am rather new to using maple so I'm not super familiar with the syntax and sometimes get confused with some of my output. With that said, I am trying to derive some equations symbolically that can later be computed in Fortran. This requires that I find the Eigenvectors of a symbolic $5\times5$ matrix. I computed the eigenvalues with little problem, however, I cannot seem to compute the Eigenvectors with Maple (not sure if its a syntax issue or what). Here is my code where I am trying to determine the Eigenvectors of $A$. Any help and advice is appreciated.

E := [q2, q2^2/q1+(gamma-1)*(q5-(1/2)*q2^2/q1-    (1/2)*q3^2/q1-(1/2)*q4^2/q1), q2*q3/q1, q4*q2/q1, q5*q2/q1+q2*(gamma-1)*(q5-(1/2)*q2^2/q1-(1/2)*q3^2/q1-(1/2)*q4^2/q1)/q1, q6*q2/q1]

F := [q3, q2*q3/q1, q3^2/q1+(gamma-1)*(q5-(1/2)*q2^2/q1-(1/2)*q3^2/q1-(1/2)*q4^2/q1), q4*q3/q1, q5*q3/q1+q3*(gamma-1)*(q5-(1/2)*q2^2/q1-(1/2)*q3^2/q1-(1/2)*q4^2/q1)/q1, q6*q3/q1]

G := [q4, q4*q2/q1, q4*q3/q1, q4^2/q1+(gamma-1)*(q5-(1/2)*q2^2/q1-(1/2)*q3^2/q1-(1/2)*q4^2/q1), q5*q4/q1+q4*(gamma-1)*(q5-(1/2)*q2^2/q1-(1/2)*q3^2/q1-(1/2)*q4^2/q1)/q1, q6*q4/q1]

U := [q1, q2, q3, q4, q5, q6]

Ebar := expand(E*xi_x+F*xi_y+G*xi_z)

with(VectorCalculus);
A := subs(q1 = rho, q2 = rho*u, q3 = rho*v, q4 = rho*w, q5 = rho*e, q6 = rho*nu, Jacobian(Ebar, U))

A := subs(e = P/((gamma-1)*rho)+(1/2)*u^2+(1/2)*v^2+(1/2)*w^2, A)

A := subs(P = rho*c^2/gamma, A)

A := simplify(A)

with(LinearAlgebra);
EigA := simplify(Eigenvalues(A));

with(LinearAlgebra)
EigenVectorA = Eigenvectors[A]

I have tried specifying which eigenvalue to take the eigenvector with respect to also with different synaxes but none seem to work. I am not claiming the last line of code should be correct, but am looking for how to make it correct. Sorry if I left out any information and thank you so much for your suggestions.

1

There are 1 best solutions below

0
On BEST ANSWER

You have Eigenvectors[A] which is a typo. It should be Eigenvectors(A). But unfortunately that seems to take too long.

But instead we can first compute the eigenvalues, and then we can find the eigenvectors associated with each eigenvalue by computing the nullspace (kernel) of the characteristic matrix where lambda takes on the value of that eigenvalue.

restart;

local gamma;

E := [q2,
  q2^2/q1+(gamma-1)*(q5-(1/2)*q2^2/q1-(1/2)*q3^2/q1-(1/2)*q4^2/q1),
  q2*q3/q1, q4*q2/q1,
  q5*q2/q1+q2*(gamma-1)*(q5-(1/2)*q2^2/q1-(1/2)*q3^2/q1-(1/2)*q4^2/q1)/q1,
  q6*q2/q1]:

F := [q3, q2*q3/q1,
  q3^2/q1+(gamma-1)*(q5-(1/2)*q2^2/q1-(1/2)*q3^2/q1-(1/2)*q4^2/q1),
  q4*q3/q1,
  q5*q3/q1+q3*(gamma-1)*(q5-(1/2)*q2^2/q1-(1/2)*q3^2/q1-(1/2)*q4^2/q1)/q1,
  q6*q3/q1]:

G := [q4, q4*q2/q1, q4*q3/q1,
  q4^2/q1+(gamma-1)*(q5-(1/2)*q2^2/q1-(1/2)*q3^2/q1-(1/2)*q4^2/q1),
  q5*q4/q1+q4*(gamma-1)*(q5-(1/2)*q2^2/q1-(1/2)*q3^2/q1-(1/2)*q4^2/q1)/q1,
  q6*q4/q1]:

Ebar := expand(E*xi_x+F*xi_y+G*xi_z):
U := [q1, q2, q3, q4, q5, q6]:
A := subs(q1 = rho, q2 = rho*u, q3 = rho*v, q4 = rho*w, q5 = rho*e,
          q6 = rho*nu, VectorCalculus:-Jacobian(Ebar, U)):
A := subs(e = P/((gamma-1)*rho)+(1/2)*u^2+(1/2)*v^2+(1/2)*w^2, A):
A := subs(P = rho*c^2/gamma, A):
A := simplify(A):

with(LinearAlgebra):

evalsA:=LinearAlgebra:-Eigenvalues(A);
DetK:=Determinant(CharacteristicMatrix(A,K)):

for ii from 1 to 3 do
    evecsA[ii]:=simplify(NullSpace(eval(CharacteristicMatrix(A,K),
                                   K=evalsA[ii])));
end do:

The eigenvectors associated with each eigenvalue evalsA[ii] (ii=1..3) are in each corresponding set assigned to evecsA[ii]. Note that one of the eigenvalues has a multiplicity of four, and four eigenvectors associated with it.

You can check that the associated eigenvalues and eigenvectors satisfy the definition as follows:

for ii from 1 to 3 do
  seq( simplify( A.evecsA[ii][jj] - evalsA[ii]*evecsA[ii][jj] ),
       jj=1..nops(evecsA[ii]) );
end do;