# How can I get Mathematica to recognize equality of symbolic matrix expressions?

I have two matrix expressions:

X.Transpose[T].Transpose[X]


and

X.T.Transpose[X]


I want Mathematica to recognize that these expressions are equal. Is it possible to do that?

• Answer probably depends on how you plan to use this known relation. Can you clarify the use case? – kirma Aug 27 '13 at 9:52
• I am confused. Why are these equal? x = RandomReal[1, {4, 4}]; t = RandomReal[1, {4, 4}]; z0 = x.Transpose[t].Transpose[x]; z1 = x.t.Transpose[x]; z1 - z0 gives !Mathematica graphics should this not be all zeros if they are equal? – Nasser Aug 27 '13 at 11:01
• Isn't this the same question as this? – István Zachar Aug 27 '13 at 11:33
• @Nasser I don't think that the OP means they are equal in general, but more in a $Assumptions kind of way. – sebhofer Aug 27 '13 at 11:46 • @Nasser Huh, but that's how $Assumptions are usually used for, no? The only question is if it will be helpful for the OP, as kirma pointed out... – sebhofer Aug 27 '13 at 11:52

We can easily verify the assumption that your matrices are equal is wrong, e.g. let's take two 2 x 2 matrices:

A = {{10, 5}, {2, 2}};
B = {{1, 0}, {1, 6}};


now we have

A.B.Transpose[A] == A.Transpose[B].Transpose[A]

False


However a simple fact in linear algebra says that the former matrix is equal to the latter one transposed.

TraditionalForm[ X.T.Transpose[X] == Transpose[X.Transpose[T].Transpose[X]] ] Now we can exploit new tensor capabilities in Mathematica 9, first assume that X and T are n x m matrices:

$Assumptions = (X | T) ∈ Matrices[{n, m}];  then we can use e.g. TensorReduce: TensorReduce[ X.T.Transpose[X] == Transpose[ X.Transpose[T].Transpose[X]] ]  True  • @sebhofer Most of this site users know well this simple identity in linear algebra. I demonstrated that his "theorem" is not true by providing a simple example. Then I showed what kind of identity he could assumed and next solved that problem. My answer is clear enough even for first-year student. – Artes Aug 27 '13 at 12:29 • With considerable effort, I could interpret OP asking how to provide assumption that T is symmetric. If this is the case, formulation of the question is not very direct. – kirma Aug 27 '13 at 13:00 • I was wrong, sorry... I thought one could construct an example where T-Transpose@T is in the null-space of X, but this is not possible. I should have thought further first. Sorry for the fuzz! – sebhofer Aug 27 '13 at 13:04 • @kirma If you want such an assumption use $Assumptions = G ∈ Matrices[{n, n}, Complexes, Symmetric[{1, 2}]]. Then TensorReduce[G - Transpose[G]] yields 0. If your interpretation would be the case one should have assumed Det[X] != 0 as well. – Artes Aug 27 '13 at 14:11

Clearly your expressions are the same only when the matrix T is symmetric. With this assumption, Mathematica can prove your expressions are equal using:

TensorReduce[
X.Transpose[T].Transpose[X] == X.T.Transpose[X],
Assumptions -> X ∈ Matrices[{n, n}] && T ∈ Matrices[{n,n}, Symmetric[{1,2}]]
]


True