I have this matrix
a = {{2, -2, -4}, {-2, 5, -2}, {-4, -2, 2}}
I then solved an equation with one missing entry. The equation is of the form
Inverse[p].a.p == q
where p is the 3×3 matrix with the missing entry (x5) and q is a given 3×3 matrix.
Solve[Inverse[( {
{1/Sqrt[5], 4/(3 Sqrt[5]), -2/3},
{-2/Sqrt[5], 2/(3 Sqrt[5]), -2/6},
{0, x5, -2/3}
} )].a.( {
{1/Sqrt[5], 4/(3 Sqrt[5]), -2/3},
{-2/Sqrt[5], 2/(3 Sqrt[5]), -2/6},
{0, x5, -2/3}
} ) == ( {
{6, 0, 0},
{0, 6, 0},
{0, 0, -3}
} )]
Mathematica can solve this easily and I get x5 -> -(Sqrt[5]/3) as the result.
However if I check it, the result ist very weird:
In[2]:= Inverse[( {
{1/Sqrt[5], 4/(3 Sqrt[5]), -2/3},
{-2/Sqrt[5], 2/(3 Sqrt[5]), -2/6},
{0, -Sqrt[5]/3, -2/3}
} )].a.( {
{1/Sqrt[5], 4/(3 Sqrt[5]), -2/3},
{-2/Sqrt[5], 2/(3 Sqrt[5]), -2/6},
{0, -Sqrt[5]/3, -2/3}
} )
Out[2]= {{6/5 - (2 (-(2/Sqrt[5]) - 2 Sqrt[5]))/Sqrt[5],
8/5 + (2 (-(2/Sqrt[5]) - 2 Sqrt[5]))/(3 Sqrt[5]), -(4/Sqrt[5]) +
1/3 (2/Sqrt[5] + 2 Sqrt[5])}, {-((
2 (-(8/(3 Sqrt[5])) + (4 Sqrt[5])/3))/Sqrt[5]) + (
4/(3 Sqrt[5]) + (4 Sqrt[5])/3)/Sqrt[5],
10/3 + (2 (-(8/(3 Sqrt[5])) + (4 Sqrt[5])/3))/(3 Sqrt[5]) + (
4 (4/(3 Sqrt[5]) + (4 Sqrt[5])/3))/(3 Sqrt[5]), (4 Sqrt[5])/3 +
1/3 (8/(3 Sqrt[5]) - (4 Sqrt[5])/3) -
2/3 (4/(3 Sqrt[5]) + (4 Sqrt[5])/3)}, {0, 0, -3}}
the expected result should be
( {
{6, 0, 0},
{0, 6, 0},
{0, 0, -3}
} )
like in the equation. If I calculate this by hand I get this result. What am I missing here?
Just
SimplifyorExpandthe results.Here is an example:
Expandwould work too in place ofSimplify. Expressions in terms of roots and fractions can often be written in several ways, and it’s not immediately obvious if two expression are equivalent just by looking at them. You have to explicitly ask Mathematica to transform them, for exampleexpr = 13/(2 Sqrt[3]) - 4/3andTogether[expr].What is quite strange though, is that
Solvedoes not work if you use the standard syntax and give variables explicitly:Can anyone explain why?
NSolveworks as expected.