Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Eigenvalues, eigenvectors, matrix ranks, determinants, and all that stuff

  • To: mathgroup at
  • Subject: [mg125484] Eigenvalues, eigenvectors, matrix ranks, determinants, and all that stuff
  • From: Konstantin <kparchevsky at>
  • Date: Thu, 15 Mar 2012 00:31:40 -0500 (EST)
  • Delivered-to:

I was calculating eigenvalues and eigenvectors of a square matrix and
found odd behaviour of Mathematica and, possibly, serious bug. I need
to calculate eigenvalues and eigenvectors of 8x8 square matrix A1:

u       rho        0      0      0      0
0                      0
0        u          0      0   1/rho   0     By/(4 pi rho)   Bz/(4 pi
0        0          u      0      0      0    -Bx/(4 pi rho)
0        0          0      u      0      0             0              -
Bx/(4 pi rho)
0   rho cs^2   0      0      u      0
0                      0
0        0          0      0      0      u
0                      0
0       By       -Bx    0      0      0
u                      0
0       Bz         0    -Bx    0      0
0                      u

Very often algebraic manipulations in Mathematica do not produce
expected result just because we and the program have different defaul
assumptions about type of variables. So I tried to specify EVERYTHING
about my variables explicitly ( @ means "belongs to", != means "not
equal" )

$Assumptions = u@Reals && u!=0 && Bx@Reals && By@Reals && Bz@Reals &&
Bx!=0 && By!=0 && Bz!=0 && rho>0 && cs>0;

Calculate eigenfalues.
Output> {u, u, u - Bx/(2 Sqrt[pi rho]), u + Bx/(2 Sqrt[pi rho]), ...

Other four eigenvalues are too big and not important for the
discussion. Physical meaning of the eigenvalues are velocities of
waves. I want them to have fixed sign, so each eigenvalue corresponds
to the wave, traveling in the fixed (positive or negative) direction.
The problem is that magnetic field Bx can be either positive or
negative. I do not want the sign of eigenvalues depends on the sign of
the magnetic field.  I want my eigenvalues look like this:

{u, u, u - Abs[Bx]/(2 Sqrt[pi rho]), u + Abs[Bx]/(2 Sqrt[pi rho]), ...

and I want to have corresponding eigenvectors. It is easy to verify,
that these values really are eigenvalues, so we are good for now.
Command Eigenvalues[ ... ] cannot help. Well, I am a big boy and know
how to do this "manually". Following the definition of eigenvectors I
wrote a system (A - lam * I) v = 0

Tmp = ( A1 - (u + Abs[Bx]/(2 Sqrt[pi rho]))
DiagonalMatrix[{1,1,1,1,1,1,1,1}] )  .  V5
eqns = {Tmp[[1,1]]==0, Tmp[[2,1]]==0, Tmp[[3,1]]==0, Tmp[[4,1]]==0,
Tmp[[5,1]]==0, Tmp[[6,1]]==0, Tmp[[7,1]]==0, Tmp[[8,1]]==0};
Solve[eqns, {V1,V2,V3,V4,V5,V6,V7,V8}]
Output> {{V1->0, V2->0, V3->0, V4->0, V5->0, V6->0, V7->0, V8->0, }}

Mathematica returns A TRIVIAL SOLUTION. By the way, if I replace
Abs[Bx] by By in the equation for Tpm, Mathematica returns non-trivial
solution. I decided to check the rank of the matrix

MatrixRank[ A1 - (u + Abs[Bx]/(2 Sqrt[pi rho]))
DiagonalMatrix[{1,1,1,1,1,1,1,1}] ]
Output> 8

WOW!!!! It thinks, that the matrix has full rank. In other words ALL
columns and rows ARE LINEARLY INDEPENDENT. If this were true, than the
homogeneous system of linear equations must have only trivial
solution. But we know this cannot be true. I checked the determinant:

Det[ A1 - (u + Abs[Bx]/(2 Sqrt[pi rho]))
DiagonalMatrix[{1,1,1,1,1,1,1,1}] ]
Output>  0

Can anybody explain me how square matrix with linear independent
columns and rows can have zero determinant? This is definetely a bug.
And this bug seriously affects the ability of Mathematica to solve
systems of linear equations. I tried to isolate the problem.

I tried to isolate the problem. Interestingly, the zero result for the
determinant is obtained only after full simplification of pretty long
expression. This gave me a clue.Run the next script on the
"clean" (just started) Mathematica

$Assumptions=a@Reals && a!=0;
a^2/Abs[a] == Abs[a]
Output>   a^2/Abs[a] == Abs[a]

Thats it!  It did not turn this equality into True, because it does
not understand, that the left and the right sides are the same. This
means, that Mathematica considers this as real equality, not identity,
that affects the ability to calculate matrix rank correctly. ONLY
AFTER full simplification it returns True. I do not know details how
MatrixRank[] works. If it does not do full simplification on the
intermediate step, the command cannot correctly distinguish equation
from identity, that causes errors in rank determination.

Is there any work around to find this eigenvector instead of "manual"
eliminating variables in eqns?

Thank you.

  • Prev by Date: Re: Message using FindFit with LevenbergMarquardt Method
  • Next by Date: yg = \frac{{d(yv)}}{{dt}}, how to solve this differential equation.
  • Previous by thread: Re: partial transpose
  • Next by thread: Re: Eigenvalues, eigenvectors, matrix ranks, determinants, and all that stuff