2
$\begingroup$

I have this matrix:

h = {
{e1, 2, x},
{2, 2, x},
{x, x, 2}
};

I want to calculate the eigenvalues and then set x equal to zero:

FullSimplify[Eigenvalues[h, Cubics -> True] /. x -> 0]

The first eigenvalue is:

    1/3 (4 + e1 + (
   16 + (-4 + e1) e1)/(-44 + e1 (30 + (-6 + e1) e1) + 
     6 Sqrt[3] Sqrt[-20 - (-4 + e1) e1])^(
   1/3) + (-44 + e1 (30 + (-6 + e1) e1) + 
     6 Sqrt[3] Sqrt[-20 - (-4 + e1) e1])^(1/3))

What I get above is different if first I set x equal to zero.

h = {
{e1, 2, x},
{2, 2, x},
{x, x, 2}
};
x = 0;
Eigenvalues[h, Cubics -> True]

Returns:

    {2, 1/2 (2 + e1 - Sqrt[4 - 4 e1 + e1^2 + 4 v^2]), 
 1/2 (2 + e1 + Sqrt[4 - 4 e1 + e1^2 + 4 v^2])}
$\endgroup$

1 Answer 1

2
$\begingroup$

The two cases are mathematically different.

Case 1:

h = {
{e1, 2, x},
{2, 2, x},
{x, x, 2}
};

Eigenvalues[h, Cubics -> True] /. x -> 0

The value of x is substituted after the Eigenvalues are computed. Mathematica computes assuming x is not zero, along with other symbols, as maybe required for the algorithm.

Case 2:

h = {
{e1, 2, x},
{2, 2, x},
{x, x, 2}
};
x = 0;

Eigenvalues[h, Cubics -> True]

The matrix changes and is qualitatively different from that of Case 1.

However, the two results are the same. You are not able to see it because Mathematica is not able to Simplify the expression in Case 1. If you substitute some random value of e1 and check you will notice that the third element of Case 1 matches with the first element of Case 2 (which is the constant value 2).

Also, if you substitute some other value of x your answers would match visibly.

A note of precaution in general (may not be applicable for this):

You should know the mathematical assumptions Mathematica takes into account in implementing its algorithm. For example you may do Solve[y/x==0,y] and get y=0 as the solution. However, Mathematica assumes that x is not equal to 0. So in this case if you were to substitute the value of x after you solve it will still be y=0. However, if you substitute before using Solve you will get an error.

Edit: As mentioned in the comment for this answer---The values of Case 1 may not correspond to the same index element in Case 2 always and depends on the value of e2 substituted. However, the three values would match. Also note that the CharacteristicPolynomial for the two cases are the same.

$\endgroup$
5
  • 4
    $\begingroup$ There is a bit more to it than this. In the second case the first eigenvalue is 2 (independent of e1). If one substitutes a value for e1 then one eigenvalue in the first case will also be 2. But which one will depend on the substituted value. The point is that the two ensembles of eigenvalues agree, as they should. But they need not match up individually. $\endgroup$ Commented Dec 8, 2015 at 14:55
  • $\begingroup$ I don't think it depends on the substituted value. For the said problem the value 2 will always match with the third element of Case 1, no matter what value of e1 is substituted. However, it might not be so for some other problem. It will be helpful to understand if you could give an example or mathematical reasoning. $\endgroup$
    – Marvin
    Commented Dec 8, 2015 at 14:59
  • $\begingroup$ I wasn't actually making that up. In[174]:= evals1 = FullSimplify[Eigenvalues[h, Cubics -> True] /. x -> 0]; evals2 = Eigenvalues[h /. x -> 0, Cubics -> True]; SeedRandom[1111]; Chop[N[{evals1, evals2} /. e1 -> RandomReal[]]] Chop[N[{evals1, evals2} /. e1 -> RandomReal[] - 3*I]] Out[177]= {{3.25784305164, -1.18004698185, 2.}, {2., -1.18004698185, 3.25784305164}} Out[178]= {{2.92269893956 - 0.841588865026 I, 2., -0.366433003266 - 2.15841113497 I}, {2., -0.366433003266 - 2.15841113497 I, 2.92269893956 - 0.841588865026 I}} $\endgroup$ Commented Dec 8, 2015 at 15:05
  • $\begingroup$ Interesting! I did not imagine that and was sincerely intrigued when you pointed out. I shall edit the answer accordingly. $\endgroup$
    – Marvin
    Commented Dec 8, 2015 at 15:09
  • 3
    $\begingroup$ More importantly (as far as your note of precaution), Mathematica by default assumes that symbols appearing in mathematical expressions are complex, which often leads to these kinds of problems (although clearly that's not the problem in this case). $\endgroup$
    – march
    Commented Dec 8, 2015 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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