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.


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

  • $\begingroup$ Exactly, using Vector declaration solves the problem. You're absolutely right! Thank you! $\endgroup$
    – Qi Qi
    Oct 14 '13 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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