PDA

View Full Version : Product of more than two matrices




MorphingDragon
Sep 2, 2010, 05:02 AM
This isn't really a computing question more of a maths question. For an assignment, we have to make classes that will work with vectors in the form of (i, j, k) and 3x3 matrices. Part of the requirements is a method that will take the product of 3 matrices (just to be really mean) Anyway, I cant remember how to get the product of 3 or more matrices. (Golly) I tried googling it and my maths textbooks are back at the youth hostel. (Its teaching break ATM)

So if A, B, C are matrices, what would the product of them be?



LPZ
Sep 2, 2010, 05:35 AM
This isn't really a computing question more of a maths question. For an assignment, we have to make classes that will work with vectors in the form of (i, j, k) and 3x3 matrices. Part of the requirements is a method that will take the product of 3 matrices (just to be really mean) Anyway, I cant remember how to get the product of 3 or more matrices. (Golly) I tried googling it and my maths textbooks are back at the youth hostel. (Its teaching break ATM)

So if A, B, C are matrices, what would the product of them be?

Well, matrix multiplication is not commutative, so the order of the terms matters. Matrix multiplication is associative, so how you group the terms doesn't matter.

So to calculate A*B*C you could do either (A*B)*C or A*(B*C). So you'd simply take your process for multiplying two matrices and use it twice:

MatrixMultiply(MatrixMultiply(A,B), C)

MorphingDragon
Sep 2, 2010, 06:10 AM
So to calculate A*B*C you could do either (A*B)*C or A*(B*C).

Thanks