Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I need to perform a dot product on a large number of 2 x 2 matrices that I have defined to differ by even/odd subscripts (Ex: D-odd=x but D-even=y). The $\Pi$ function will not work because it does not perform dot products. Does anyone know how I can carry out this large series of matrix multiplications. Thanks

share|improve this question
1  
Could you please show your starting code? It's hard to have nothing to start from. –  Vitaliy Kaurov Dec 2 '12 at 6:01
    
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 FAQs! 3) When you see good Q&A, 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, remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign –  chris Dec 2 '12 at 11:09
add comment

2 Answers 2

If you have a list of matrices, you can apply a dot multiplication to all the matrices by changing the Head of the list to Dot. To illustrate this, I'll first define a set of matrices symbolically:

matrixList = With[{numberOfMatrices = 2},
  Table[Array[Subsuperscript["M", Row[{#1, #2}], i] &, {2, 2}], {i, 
    numberOfMatrices}]
  ]

$\left\{\left( \begin{array}{cc} \text{M}_{11}^1 & \text{M}_{12}^1 \\ \text{M}_{21}^1 & \text{M}_{22}^1 \\ \end{array} \right),\left( \begin{array}{cc} \text{M}_{11}^2 & \text{M}_{12}^2 \\ \text{M}_{21}^2 & \text{M}_{22}^2 \\ \end{array} \right)\right\}$

This contains just two matrices for display reasons, but you can change numberOfMatrices to anything you like.

Now the answer to your question is just:

Apply[Dot, matrixList]

$\left( \begin{array}{cc} \text{M}_{11}^1 \text{M}_{11}^2+\text{M}_{12}^1 \text{M}_{21}^2 & \text{M}_{11}^1 \text{M}_{12}^2+\text{M}_{12}^1 \text{M}_{22}^2 \\ \text{M}_{11}^2 \text{M}_{21}^1+\text{M}_{21}^2 \text{M}_{22}^1 & \text{M}_{12}^2 \text{M}_{21}^1+\text{M}_{22}^1 \text{M}_{22}^2 \\ \end{array} \right)$

share|improve this answer
2  
Yes, you could also take a List and change its head to Times if you want to get the normal multiplication of all elements in a list. But just to clarify: Dot is really very different from Times because conventional matrix multiplication is not commutative, whereas Times doesn't care about the order of the factors. BTW - strange that @NasserM.Abbasi appears here as your name. That's not you, right? –  Jens Dec 2 '12 at 7:18
    
@NasserM.Abbasi lol, it's too late at night here... –  Jens Dec 2 '12 at 7:51
add comment

An alternative is to use Fold[] along with Dot[]. Using Jens's example, you can do Fold[Dot, IdentityMatrix[2], matrixList]. Note that your initial identity matrix must have dimensions that conform with the dimensions of your other matrices.

share|improve this answer
add comment

Your Answer

 
discard

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.