5
$\begingroup$

I know Mathematica is not very good with symbolic manipulation of matrix expressions, but I was surprised to find that it can't reduce the following expression:

$Assumptions = G ∈ Matrices[{n, n}, Reals, Symmetric[{1, 2}]]
(* G ∈ Matrices[{n, n}, Reals, Symmetric[{1, 2}]] *)

TensorReduce[G.G - G.Transpose[G]]
(* -G.Transpose[G, {2, 1}] + MatrixPower[G, 2] *)

For real symmetric matrices, Transpose operation is an identity map. How do I this expression in this case?

$\endgroup$
4
  • 1
    $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – Michael E2
    Jan 26, 2015 at 15:05
  • 2
    $\begingroup$ Others will appreciate it if the code can be copied, pasted directly into Mathematica, and executed. The In/Out tags make that difficult. If you set the option SetOptions[$FrontEnd, ExportMultipleCellsOptions -> {"IncludeCellLabels" -> False}], then they won't be copied from your notebook. Note using $FrontEnd sets it for all sessions. Use $FrontEndSession if you just want to set it for your current session. Generally people put output inside comments (*...*) so that it won't affect execution when pasted. $\endgroup$
    – Michael E2
    Jan 26, 2015 at 15:06
  • $\begingroup$ @MichaelE2 Thanks for the tips. :) $\endgroup$
    – Memming
    Jan 26, 2015 at 15:25
  • 1
    $\begingroup$ If you aren't really interested in tensor algebra, then you may as well just go the simple route: Transpose[G] ^= G. With this, G.G-G.Transpose[G] directly evaluates to 0. $\endgroup$
    – Jens
    Jan 26, 2015 at 18:43

2 Answers 2

3
$\begingroup$

You should use \[TensorProduct] and TensorTranspose instead the usual . and Transposematrix operations.

TensorReduce[G\[TensorProduct]G - G\[TensorProduct]TensorTranspose[G]]

returns 0

$\endgroup$
1
  • $\begingroup$ Thx, but I'm not trying to do tensor product. . is for Hadamard product. It also doesn't work for simple matrix multiplication... $\endgroup$
    – Memming
    Jan 26, 2015 at 18:11
2
$\begingroup$

This works as expected in M10.3+:

$Assumptions = G \[Element] Matrices[{n, n}, Reals, Symmetric[{1, 2}]];

TensorReduce[G.G - G.Transpose[G]]

0

$\endgroup$
2
  • $\begingroup$ Was it a bug that is fixed in 10.3? $\endgroup$ Sep 12, 2017 at 6:43
  • 1
    $\begingroup$ @AlexeyPopkov I think it's more of a new feature than a bug fix. $\endgroup$
    – Carl Woll
    Sep 12, 2017 at 15:01

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.