37
$\begingroup$

Bug introduced in 7.0.1 or earlier and fixed in 10.0.0


I have a fairly simple $3\times3$ complex matrix, $$ M=\left( \begin{array}{ccc} \frac{7}{2}-\frac{i}{2} & -1+i & \frac{1}{2}+\frac{5 i}{2} \\ -1+i & 5+i & -1+i \\ \frac{1}{2}+\frac{5 i}{2} & -1+i & \frac{7}{2}-\frac{i}{2} \\ \end{array} \right) $$ Solving for the eigenvalues and eigenvectors:

mat = {{7/2 - I/2, -1 + I, 1/2 + 5 I/2}, {-1 + I, 
    5 + I, -1 + I}, {1/2 + 5 I/2, -1 + I, 7/2 - I/2}}; 
{vals, vecs} = Eigensystem[mat]

gives (Mathematica 9.0.1)

\begin{array}{ccc} 6 & 3+3 i & 3-3 i \\ \{1,-2,1\} & \left\{\frac{17}{13}+\frac{6 i}{13},0,1\right\} & \{-1,0,1\} \\ \end{array}

But that 2nd eigenvector is not right; it should be $(1,1,1)$. Is there a bug, or am I being incredibly obtuse?

$\endgroup$
7
  • 3
    $\begingroup$ Pretty shocking, this one. Are you going to report it to Wolfram? http://www.wolfram.com/support/contact/email/?topic=Feedback $\endgroup$
    – Jens
    Aug 13, 2013 at 6:03
  • 2
    $\begingroup$ Yup, this is clearly a bug as can be confirmed with the following: M.Transpose[{Eigenvectors[M][[2]]}] == Eigenvalues[M][[2]] Transpose[{Eigenvectors[M][[2]]}]. Which gives False indicating that this is not a true eigenvalue equation. Indeed replacing this eigenvector with {1,1,1} satisfies the equation. $\endgroup$
    – RunnyKine
    Aug 13, 2013 at 6:12
  • 3
    $\begingroup$ I've pasted the matrix to WolframAlpha. It also gives the wrong answer. $\endgroup$
    – luyuwuli
    Aug 13, 2013 at 6:30
  • 2
    $\begingroup$ Thanks for the confirmation. It's nice to know I'm not crazy. I've reported it to Wolfram. $\endgroup$
    – gilonik
    Aug 13, 2013 at 6:58
  • 1
    $\begingroup$ This has been fixed for a future release. $\endgroup$ Aug 19, 2013 at 16:31

2 Answers 2

20
$\begingroup$

This bug has been fixed in V10

mat = {{7/2 - I/2, -1 + I, 1/2 + 5 I/2}, {-1 + I, 
    5 + I, -1 + I}, {1/2 + 5 I/2, -1 + I, 7/2 - I/2}};

Eigensystem[mat]

Gives:

{{6, 3 + 3 I, 3 - 3 I}, {{1, -2, 1}, {1, 1, 1}, {-1, 0, 1}}}

\begin{array}{ccc} 6 & 3+3 i & 3-3 i \\ \{1,-2,1\} & \left\{1,1,1\right\} & \{-1,0,1\} \\ \end{array}

$\endgroup$
14
$\begingroup$

This appears to be a genuine bug with exact arithmetic in Eigensystem. Here is a comparison to the same calculation with real numbers, for which I use the matrix mat//N:

mat = {{7/2 - I/2, -1 + I, 1/2 + 5 I/2}, {-1 + I, 
    5 + I, -1 + I}, {1/2 + 5 I/2, -1 + I, 7/2 - I/2}};

{vals, vecs} = Eigensystem[mat]

(*
==> {{6, 3 + 3 I, 
  3 - 3 I}, {{1, -2, 1}, {17/13 + (6 I)/13, 0, 1}, {-1, 0, 1}}}
*)

{numericvals, numericvecs} = Eigensystem[mat // N] // Chop

(*
==> {{6., 3. - 3. I, 
  3. + 3. I}, {{-0.408248, 0.816497, -0.408248}, {-0.707107, 0, 
   0.707107}, {0.57735, 0.57735, 0.57735}}}
*)

The results are not equivalent, and I can test which of them gives correct eigenvalues as follows:

Table[Chop[mat.vecs[[i]] - vals[[i]] vecs[[i]]], {i, 3}]

(*
==> {{0, 0, 0}, {36/13 - (24 I)/13, -(36/13) + (24 I)/13, 0}, {0,
   0, 0}}
*)

Table[
 Chop[N[mat].numericvecs[[i]] - 
   numericvals[[i]] numericvecs[[i]]], {i, 3}]

(* ==> {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}} *)

Clearly, the floating-point result is correct and the exact arithmetic result (using mat without N) is incorrect.

This then also indicates how to work around this bug: use only numerical matrices with N[...].

$\endgroup$
2
  • $\begingroup$ It's good to know that the numerical result is correct. I'm saved. $\endgroup$ Mar 13, 2014 at 3:54
  • $\begingroup$ @xslittlegrass Sadly, the "future version" that was supposed to fix this bug hasn't materialized yet... $\endgroup$
    – Jens
    Mar 13, 2014 at 4:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.