Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've defined three symbolic abstract matrices X, M and S as shown below.

In[1]:= $Assumptions = { 
Element[X, Matrices[{k, 1}]],
Element[M, Matrices[{k, 1}]],
Element[S, Matrices[{k, k}, Reals, Symmetric[{1, 2}]]]

In[7]:= prodA = TensorTranspose[X].S.M;
        prodB = TensorTranspose[M].S.X;

In[12]:= TensorReduce[prodA + prodB]
Out[12]= TensorTranspose[M, {2, 1}].S.X + TensorTranspose[X, {2, 1}].S.M

Since the S is a square and symmetric matrix, the production results prodA and prodB should be equal. How can I let the output reflect that? I need the output show something like 2TensorTranspose[X].S.M.

share|improve this question
up vote 0 down vote accepted

You can replace Matrices[{k, 1}] to Vectors[k]

$Assumptions = {Element[X, Vectors[k]], Element[M, Vectors[k]], 
   Element[S, Matrices[{k, k}, Reals, Symmetric[{1, 2}]]]};

prodA = X.S.M; (* vector not needed to be transposed *)
prodB = M.S.X;

TensorReduce[prodA + prodB]
2 M.S.X

TensorReduce can't simplify Matrices[{k, 1}] because your relation is not true for general dimensions:

u = RandomReal[1.0, {10, 2}];
v = RandomReal[1.0, {10, 2}];
m = (# + Transpose[#]) &@RandomReal[1.0, {10, 10}];

Transpose[u].m.v // MatrixForm
Transpose[v].m.u // MatrixForm

enter image description here

enter image description here

share|improve this answer
Exactly, using Vector declaration solves the problem. You're absolutely right! Thank you! – Qi Qi Oct 14 '13 at 12:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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