Mathematica doesn't evaluate/simplify arithmetic expression in its output

0

I have two matrices, A := {{1, 2, -4}, {2, -2, -2}, {-4, -2, 1}} and V := {{-2/3, 1/Sqrt[2], -1/(3 Sqrt[2])}, {-1/3, 0, (2 Sqrt[2])/3}, {2/3, 1/Sqrt[2], 1/(3 Sqrt[2])}}. I was interested in whether Transpose[V].A.V was a diagonal matrix with 6, -3, -3.

However the output I got is the following:

When I saw that, I immediately thought I calculated something wrong on paper, but on closer inspection, most of those numbers are a complicated way of writing 0 or -3! In fact, Simplify[%] gives the expected format, and Transpose[V].A.V == DiagonalMatrix[{6, -3, -3}] is True.

Usually such mere numerical expressions are evaluated/simplified, why weren't they now?

jcora

Posted 2019-06-11T18:16:18.657

Reputation: 103

Question was closed 2019-06-17T12:14:35.133

See a simpler example in the help to Dot. I think that behavior is intended. It does not make great inconvenience for users. – user64494 – 2019-06-11T18:52:41.803

1A simpler example: Sqrt[2] - 1/Sqrt[2] is returned unmodified, and a simplification gives 1/Sqrt[2]. Only a restricted set of ultrafast simplifications is done automatically: for example, 2+3 is auto-simplified to 5. The system designer (WR) has to draw the line somewhere and leave more complex simplifications to the explicit invocation of Simplify or even FullSimplify. Apparently the line is drawn in a way that does not simplify/merge square roots by default. Maybe as computers get more powerful, the line will shift. – Roman – 2019-06-11T20:15:06.330

@Roman post as answer please. I was looking for an explanation/confirmation, I know how to call simplify myself – jcora – 2019-06-12T17:39:33.423

Answers

1

A simpler example:

Sqrt[2] - 1/Sqrt[2]
(*    -(1/Sqrt[2]) + Sqrt[2]    *)

is returned unmodified, and a simplification gives

Simplify[%]
(*    1/Sqrt[2]    *)

Only a restricted set of ultrafast simplifications is done automatically: for example, 2 + 3 is auto-simplified to 5. The system designer (WR) has to draw the line somewhere and leave more complex simplifications to the explicit invocation of Simplify or even FullSimplify. Apparently the line is drawn in a way that does not simplify/merge square roots by default. Maybe as computers get more powerful, the line will shift.

Roman

Posted 2019-06-11T18:16:18.657

Reputation: 25 509

1

Transpose[V].A.V // FullSimplify
(*{{6, 0, 0}, {0, -3, 0}, {0, 0, -3}}*)

Ulrich Neumann

Posted 2019-06-11T18:16:18.657

Reputation: 25 490