13
$\begingroup$

I have the matrix $\begin{bmatrix}0.45 & 0.40 \\ 0.55 & 0.60 \end{bmatrix}$.

I believe $\begin{bmatrix}\frac{10}{17} \\ \frac{55}{68}\end{bmatrix}$ is an eigenvector for this matrix corresponding to the eigenvalue $1$, and that $\begin{bmatrix}-\sqrt{2} \\ \sqrt{2}\end{bmatrix}$ is an eigenvector for this matrix corresponding to the eigenvalue $0.05$.

However, Wolfram Alpha tells me this matrix is, in fact, not diagonalizable (a.k.a. "defective"):

I'm really confused... which one is in fact defective -- Wolfram Alpha, or the matrix?
Or is it my understanding of diagonalizability that's, uh, defective?

$\endgroup$
  • $\begingroup$ I think you are correct. $\endgroup$ – Daryl Oct 30 '12 at 2:53
  • 1
    $\begingroup$ Yes. I get the characteristic polynomial as $\lambda^2-1.05\lambda+0.05$, which has two distinct roots. Thus, for a $2\times2$ matrix, it is diagonalisable. $\endgroup$ – Daryl Oct 30 '12 at 2:56
  • 1
    $\begingroup$ @wj32: I'm curious what the bug is... I can't imagine what kind of an AI bug can cause something like this haha. $\endgroup$ – Mehrdad Oct 30 '12 at 3:51
  • 1
    $\begingroup$ @Mehrdad: Numerical linear algebra can always be a bit weird compared to exact algebra. Whenever you use decimal points, Wolfram|Alpha/Mathematica automatically goes into "approximate" mode. $\endgroup$ – wj32 Oct 30 '12 at 3:56
  • 1
    $\begingroup$ They have decided to simply remove the part that says it's not diagonalizable, which fixes the problem for that input, but still leaves it contradictory when you ask it if the matrix is diagonalizable. I'll report this separately. $\endgroup$ – Mark S. Jul 22 '17 at 12:45
13
$\begingroup$

I agree with all the comments. Namely,

  1. The matrix is clearly diagonalizable,
  2. The rationalized version works correctly, and
  3. Numerical linear algebra can be tricky and surprising.

In spite of points 2 and 3, I'd still call this a bug. Alpha is intended to guess the users intent. While clearly very hard, I don't think that interpreting numbers like $0.55$ as $55/100$ is too far out there. Even failing that, a small perturbation of the elements of the matrix don't change the fact that the matrix is diagonalizable.

Fortunately, there is an easy work around. Just enter:

diagonalize rationalize {{0.45,0.4},{0.55,0.6}}

enter image description here

$\endgroup$
  • $\begingroup$ Cool trick with rationalize, thanks! $\endgroup$ – Mehrdad Oct 30 '12 at 6:53
8
$\begingroup$

This is a combination of numerical linear algebra being hard, bad error handling, and confusing output

1: Numerical linear algebra is hard

This problem is ill-conditioned as far as Mathematica is concerned. As has been mentioned in the comments, Mathematica (and it's wolfram-alpha cousin) automatically enters numerical approximation mode when you give it decimals. It assumes you have provided it with the data to the highest precision you can assert, and cannot tolerate imprecisions that exceed this implicitly provided precision threshold.

In your case, one of the entries has only a single digit of precision. Since the condition number is 23, you are expecting to lose $\log_{10}(23)>1$ decimal digits in precision, which exceeds the available precision.

This is hardly unique to your data. Trying to have Wolfram-Alpha diagonalize $$\begin{pmatrix}1.0&0.0\\0.0&1.0\end{pmatrix},$$ using the decimal points in particular, results in the same issue.

The algorithm therefore detects the system is ill-conditioned, and starts having problems.

2: Bad Error Handling

Rather than tell you that the problem is ill-conditioned and therefore prone to issues, it spits out that first message: "not diagonalizable." It should have said something to the effect of "problem is ill-conditioned; answers may not be accurate."

3: Confusing Output

Ah, but keep reading! Wolfram-alpha didn't give up when it saw it was ill-conditioned and started spouting nonsense about it being non-diagonalizable. It then did the next-best thing it felt it could do: provide a Jordan decomposition, which turns out to be precisely the diagonalization you want. Wolfram-alpha just doesn't trust that the decomposition is all that reliable.

4: Hidden Secret Bug/Interface shortcoming

Of course, there's a second problem. Intuitively you might think "okay, I'll just throw in some trailing zeros for more precision, problem solved!" Unfortunately, this doesn't work. Nor does trying to multiply the matrix by an arbitrary non-zero constant. From what I can gather, the algorithms Wolfram-Alpha (and essentially Mathematica) uses will effectively transform the entries back to the ill-conditioned 1 digit of precision situation, and then transform them back after it gets an answer (if any). Normally this is a worthwhile thing to do, as it guarantees that the numbers occupy the range that the algorithm and system can expect to handle the most efficiently. Here it just becomes a headache. I've yet to find a way that gets Wolfram-Alpha to interpret something like .4 as being accurate to, say, 32 decimal places.

$\endgroup$
  • 2
    $\begingroup$ Not the most elegant solution but one could possibly enter $0.4$ as 2^^0.011001100110011001101. Apparently diagonalize {{ 45/100,2^^0.011001100110011001101 },{55/100,6/10}} does not complain about the non-diagonalizability of the input. $\endgroup$ – Luca Citi May 17 '17 at 16:12
  • $\begingroup$ @LucaCiti That's amusing. The output is a little difficult to interpret, but you're right, it does not encounter the precision issue. $\endgroup$ – zibadawa timmy May 17 '17 at 17:24

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.