Search code examples
matrixwolfram-mathematicatranspose

matrices multiplication in mathematica


i am doing matrices multiplication in Mathematica 0.12 note book using next code

 Xo1 = ({
     {1, y, 2 x, 2 x y}
    }).( {
     {q11},
     {q12},
     {q13},
     {q14}
    } );
Xo2 = ( {
     {0, x^2, 0, x^3}
    } ).( {
     {q21},
     {q22},
     {q23},
     {q24}
    } );
Xo3 = ( {
      {0, x, 0, x^2}
     } ).( {
      {q11},
      {q12},
      {q13},
      {q14}
     } ) + ( {
     {2 x, 2 x y, 3 x^2, 3 x^2 y}
     } ).( {
      {q21},
      {q22},
      {q23},
      {q24}
     } );
Xo = ( {
    {Xo1},
    {Xo2},
    {Xo3}
   } );
Q = ( {
    {Q11, Q12, Q13},
    {Q21, Q22, Q23},
    {Q31, Q32, Q33}
   } );
MatrixForm[Q.Xo]

which give me reasonable result but when i do the operation with transpose Xo :

 MatrixForm[Xo[Transpose].Q]

it give next error "Tensors incompatible shapes".
can any one help me with this code ?


Solution

  • In Mathematica your second vector is assumed to be vertical.

    Xo1 = {1, y, 2 x, 2 x y}.{q11, q12, q13, q14};
    Xo2 = {0, x^2, 0, x^3}.{q21, q22, q23, q24};
    Xo3 = {0, x, 0, x^2}.{q11, q12, q13, q14} +
       {2 x, 2 x y, 3 x^2, 3 x^2 y}.{q21, q22, q23, q24};
    Xo = {Xo1, Xo2, Xo3};
    Q = {{Q11, Q12, Q13}, {Q21, Q22, Q23}, {Q31, Q32, Q33}};
    MatrixForm[Q.Xo]