Multiplying two matrices is not done entry by entry. Instead each row of the first matrix is combined with each column of the second. The rule looks strange at first, but it is exactly what is needed to work out totals such as a shopping bill, and it is what turns a system of equations into a single matrix equation. This lesson explains the rule, when a product exists, and the laws it does and does not obey.
Row times column#
Start with a row matrix times a column matrix of the same length. Multiply the matching entries and add:
[ 3 2 1 ] [ 52 110 180 ] = [ 3 × 52 + 2 × 110 + 1 × 180 ] = [ 556 ] \begin{bmatrix} 3 & 2 & 1 \end{bmatrix}\begin{bmatrix} 52 \\ 110 \\ 180 \end{bmatrix} = \begin{bmatrix} 3 \times 52 + 2 \times 110 + 1 \times 180 \end{bmatrix} = \begin{bmatrix} 556 \end{bmatrix} [ 3 2 1 ] 52 110 180 = [ 3 × 52 + 2 × 110 + 1 × 180 ] = [ 556 ]
This is a bill: buying 3 3 3 kg of rice at ₹52, 2 2 2 kg of dal at ₹110 and 1 1 1 kg of oil at ₹180 costs ₹556.
The product of two matrices#
If A A A is of order m × n m \times n m × n and B B B is of order n × p n \times p n × p , the product A B AB A B is the m × p m \times p m × p matrix whose entry in row i i i and column j j j is
(row i of A ) × (column j of B ) \text{(row } i \text{ of } A) \times \text{(column } j \text{ of } B) (row i of A ) × (column j of B )
worked out as above: multiply matching entries and add.
When does A B AB A B exist? Only when the number of columns of A A A equals the number of rows of B B B . A useful picture:
( m × n ‾ ) × ( n ‾ × p ) → m × p (m \times \underline{n}) \times (\underline{n} \times p) \to m \times p ( m × n ) × ( n × p ) → m × p
The inner numbers must match; the outer numbers give the order of the product.
Example 1#
Find A B AB A B and B A BA B A for A = [ 1 2 3 4 ] A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} A = [ 1 3 2 4 ] and B = [ 5 6 7 8 ] B = \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} B = [ 5 7 6 8 ] .
A B = [ 1 × 5 + 2 × 7 1 × 6 + 2 × 8 3 × 5 + 4 × 7 3 × 6 + 4 × 8 ] = [ 19 22 43 50 ] AB = \begin{bmatrix} 1 \times 5 + 2 \times 7 & 1 \times 6 + 2 \times 8 \\ 3 \times 5 + 4 \times 7 & 3 \times 6 + 4 \times 8 \end{bmatrix} = \begin{bmatrix} 19 & 22 \\ 43 & 50 \end{bmatrix} A B = [ 1 × 5 + 2 × 7 3 × 5 + 4 × 7 1 × 6 + 2 × 8 3 × 6 + 4 × 8 ] = [ 19 43 22 50 ]
B A = [ 5 × 1 + 6 × 3 5 × 2 + 6 × 4 7 × 1 + 8 × 3 7 × 2 + 8 × 4 ] = [ 23 34 31 46 ] BA = \begin{bmatrix} 5 \times 1 + 6 \times 3 & 5 \times 2 + 6 \times 4 \\ 7 \times 1 + 8 \times 3 & 7 \times 2 + 8 \times 4 \end{bmatrix} = \begin{bmatrix} 23 & 34 \\ 31 & 46 \end{bmatrix} B A = [ 5 × 1 + 6 × 3 7 × 1 + 8 × 3 5 × 2 + 6 × 4 7 × 2 + 8 × 4 ] = [ 23 31 34 46 ]
So A B ≠ B A AB \neq BA A B = B A . Matrix multiplication is not commutative : the order of the factors matters.
Example 2#
Let C = [ 1 2 0 3 − 1 4 ] C = \begin{bmatrix} 1 & 2 & 0 \\ 3 & -1 & 4 \end{bmatrix} C = [ 1 3 2 − 1 0 4 ] (2 × 3 2 \times 3 2 × 3 ) and E = [ 2 1 0 3 − 1 2 ] E = \begin{bmatrix} 2 & 1 \\ 0 & 3 \\ -1 & 2 \end{bmatrix} E = 2 0 − 1 1 3 2 (3 × 2 3 \times 2 3 × 2 ). Find C E CE C E and E C EC E C .
C E CE C E has order 2 × 2 2 \times 2 2 × 2 :
C E = [ 2 + 0 + 0 1 + 6 + 0 6 + 0 − 4 3 − 3 + 8 ] = [ 2 7 2 8 ] CE = \begin{bmatrix} 2 + 0 + 0 & 1 + 6 + 0 \\ 6 + 0 - 4 & 3 - 3 + 8 \end{bmatrix} = \begin{bmatrix} 2 & 7 \\ 2 & 8 \end{bmatrix} C E = [ 2 + 0 + 0 6 + 0 − 4 1 + 6 + 0 3 − 3 + 8 ] = [ 2 2 7 8 ]
E C EC E C has order 3 × 3 3 \times 3 3 × 3 :
E C = [ 2 + 3 4 − 1 0 + 4 0 + 9 0 − 3 0 + 12 − 1 + 6 − 2 − 2 0 + 8 ] = [ 5 3 4 9 − 3 12 5 − 4 8 ] EC = \begin{bmatrix} 2 + 3 & 4 - 1 & 0 + 4 \\ 0 + 9 & 0 - 3 & 0 + 12 \\ -1 + 6 & -2 - 2 & 0 + 8 \end{bmatrix} = \begin{bmatrix} 5 & 3 & 4 \\ 9 & -3 & 12 \\ 5 & -4 & 8 \end{bmatrix} E C = 2 + 3 0 + 9 − 1 + 6 4 − 1 0 − 3 − 2 − 2 0 + 4 0 + 12 0 + 8 = 5 9 5 3 − 3 − 4 4 12 8
Here C E CE C E and E C EC E C do not even have the same order.
Example 3#
Ravi buys 3 3 3 kg of rice, 2 2 2 kg of dal and 1 1 1 kg of oil. The prices per kg at two shops are given by the columns of [ 52 60 110 104 180 170 ] \begin{bmatrix} 52 & 60 \\ 110 & 104 \\ 180 & 170 \end{bmatrix} 52 110 180 60 104 170 (rows: rice, dal, oil). Where is his shopping cheaper?
[ 3 2 1 ] [ 52 60 110 104 180 170 ] = [ 556 558 ] \begin{bmatrix} 3 & 2 & 1 \end{bmatrix}\begin{bmatrix} 52 & 60 \\ 110 & 104 \\ 180 & 170 \end{bmatrix} = \begin{bmatrix} 556 & 558 \end{bmatrix} [ 3 2 1 ] 52 110 180 60 104 170 = [ 556 558 ]
The bill is ₹556 at the first shop and ₹558 at the second, so the first shop is cheaper by ₹2.
Laws of multiplication#
Whenever the products exist:
( A B ) C = A ( B C ) (AB)C = A(BC) ( A B ) C = A ( B C ) (associative law)
A ( B + C ) = A B + A C A(B + C) = AB + AC A ( B + C ) = A B + A C and ( A + B ) C = A C + B C (A + B)C = AC + BC ( A + B ) C = A C + B C (distributive laws)
A I = I A = A AI = IA = A A I = I A = A for a square matrix A A A and the identity matrix I I I of the same order
k ( A B ) = ( k A ) B = A ( k B ) k(AB) = (kA)B = A(kB) k ( A B ) = ( k A ) B = A ( k B ) for a scalar k k k
Two familiar laws of numbers fail for matrices:
In general A B ≠ B A AB \neq BA A B = B A (Example 1).
A B = O AB = O A B = O does not force A = O A = O A = O or B = O B = O B = O . For example,
[ 1 1 1 1 ] [ 1 − 1 − 1 1 ] = [ 1 − 1 − 1 + 1 1 − 1 − 1 + 1 ] = [ 0 0 0 0 ] \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}\begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix} = \begin{bmatrix} 1 - 1 & -1 + 1 \\ 1 - 1 & -1 + 1 \end{bmatrix} = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} [ 1 1 1 1 ] [ 1 − 1 − 1 1 ] = [ 1 − 1 1 − 1 − 1 + 1 − 1 + 1 ] = [ 0 0 0 0 ]
even though neither factor is the zero matrix.
Powers of a square matrix#
For a square matrix, A 2 = A A A^2 = AA A 2 = AA , A 3 = A 2 A A^3 = A^2A A 3 = A 2 A , and so on.
Example 4#
If A = [ 2 1 1 2 ] A = \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix} A = [ 2 1 1 2 ] , show that A 2 − 4 A + 3 I = O A^2 - 4A + 3I = O A 2 − 4 A + 3 I = O .
A 2 = [ 4 + 1 2 + 2 2 + 2 1 + 4 ] = [ 5 4 4 5 ] A^2 = \begin{bmatrix} 4 + 1 & 2 + 2 \\ 2 + 2 & 1 + 4 \end{bmatrix} = \begin{bmatrix} 5 & 4 \\ 4 & 5 \end{bmatrix} A 2 = [ 4 + 1 2 + 2 2 + 2 1 + 4 ] = [ 5 4 4 5 ]
A 2 − 4 A + 3 I = [ 5 4 4 5 ] − [ 8 4 4 8 ] + [ 3 0 0 3 ] = [ 0 0 0 0 ] A^2 - 4A + 3I = \begin{bmatrix} 5 & 4 \\ 4 & 5 \end{bmatrix} - \begin{bmatrix} 8 & 4 \\ 4 & 8 \end{bmatrix} + \begin{bmatrix} 3 & 0 \\ 0 & 3 \end{bmatrix} = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} A 2 − 4 A + 3 I = [ 5 4 4 5 ] − [ 8 4 4 8 ] + [ 3 0 0 3 ] = [ 0 0 0 0 ]
Practice#
If A A A is 3 × 4 3 \times 4 3 × 4 and B B B is 4 × 2 4 \times 2 4 × 2 , does A B AB A B exist? What is its order? Does B A BA B A exist?
Find [ 1 2 3 ] [ 4 5 6 ] \begin{bmatrix} 1 & 2 & 3 \end{bmatrix}\begin{bmatrix} 4 \\ 5 \\ 6 \end{bmatrix} [ 1 2 3 ] 4 5 6 .
Find [ 4 5 6 ] [ 1 2 3 ] \begin{bmatrix} 4 \\ 5 \\ 6 \end{bmatrix}\begin{bmatrix} 1 & 2 & 3 \end{bmatrix} 4 5 6 [ 1 2 3 ] .
For A = [ 2 0 1 3 ] A = \begin{bmatrix} 2 & 0 \\ 1 & 3 \end{bmatrix} A = [ 2 1 0 3 ] and B = [ 1 4 − 1 2 ] B = \begin{bmatrix} 1 & 4 \\ -1 & 2 \end{bmatrix} B = [ 1 − 1 4 2 ] , find A B AB A B and B A BA B A .
For A = [ 1 0 2 0 1 1 ] A = \begin{bmatrix} 1 & 0 & 2 \\ 0 & 1 & 1 \end{bmatrix} A = [ 1 0 0 1 2 1 ] and B = [ 1 2 3 0 1 1 ] B = \begin{bmatrix} 1 & 2 \\ 3 & 0 \\ 1 & 1 \end{bmatrix} B = 1 3 1 2 0 1 , find A B AB A B .
If A = [ 1 2 2 1 ] A = \begin{bmatrix} 1 & 2 \\ 2 & 1 \end{bmatrix} A = [ 1 2 2 1 ] , show that A 2 − 2 A − 3 I = O A^2 - 2A - 3I = O A 2 − 2 A − 3 I = O .
Find A 2 A^2 A 2 for A = [ 0 1 0 0 ] A = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix} A = [ 0 0 1 0 ] . What does this show?
For A = [ 1 1 0 1 ] A = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} A = [ 1 0 1 1 ] , find A 2 A^2 A 2 and A 3 A^3 A 3 .
Sita buys 4 4 4 pens and 3 3 3 notebooks. Pens cost ₹10 and notebooks ₹30 at one shop, and ₹12 and ₹28 at another. Use a matrix product to find her bill at each shop.
Answers#
Show answers
Yes: columns of A A A (4 4 4 ) equal rows of B B B (4 4 4 ), so A B AB A B is 3 × 2 3 \times 2 3 × 2 . B A BA B A would need the 2 2 2 columns of B B B to match the 3 3 3 rows of A A A , so it does not exist.
[ 4 + 10 + 18 ] = [ 32 ] \begin{bmatrix} 4 + 10 + 18 \end{bmatrix} = \begin{bmatrix} 32 \end{bmatrix} [ 4 + 10 + 18 ] = [ 32 ] .
A 3 × 3 3 \times 3 3 × 3 matrix: [ 4 8 12 5 10 15 6 12 18 ] \begin{bmatrix} 4 & 8 & 12 \\ 5 & 10 & 15 \\ 6 & 12 & 18 \end{bmatrix} 4 5 6 8 10 12 12 15 18 .
A B = [ 2 8 − 2 10 ] AB = \begin{bmatrix} 2 & 8 \\ -2 & 10 \end{bmatrix} A B = [ 2 − 2 8 10 ] and B A = [ 6 12 0 6 ] BA = \begin{bmatrix} 6 & 12 \\ 0 & 6 \end{bmatrix} B A = [ 6 0 12 6 ] .
A B = [ 1 + 0 + 2 2 + 0 + 2 0 + 3 + 1 0 + 0 + 1 ] = [ 3 4 4 1 ] AB = \begin{bmatrix} 1 + 0 + 2 & 2 + 0 + 2 \\ 0 + 3 + 1 & 0 + 0 + 1 \end{bmatrix} = \begin{bmatrix} 3 & 4 \\ 4 & 1 \end{bmatrix} A B = [ 1 + 0 + 2 0 + 3 + 1 2 + 0 + 2 0 + 0 + 1 ] = [ 3 4 4 1 ] .
A 2 = [ 5 4 4 5 ] A^2 = \begin{bmatrix} 5 & 4 \\ 4 & 5 \end{bmatrix} A 2 = [ 5 4 4 5 ] , and [ 5 4 4 5 ] − [ 2 4 4 2 ] − [ 3 0 0 3 ] = O \begin{bmatrix} 5 & 4 \\ 4 & 5 \end{bmatrix} - \begin{bmatrix} 2 & 4 \\ 4 & 2 \end{bmatrix} - \begin{bmatrix} 3 & 0 \\ 0 & 3 \end{bmatrix} = O [ 5 4 4 5 ] − [ 2 4 4 2 ] − [ 3 0 0 3 ] = O .
A 2 = O A^2 = O A 2 = O , although A ≠ O A \neq O A = O . A non-zero matrix can have a zero square.
A 2 = [ 1 2 0 1 ] A^2 = \begin{bmatrix} 1 & 2 \\ 0 & 1 \end{bmatrix} A 2 = [ 1 0 2 1 ] and A 3 = [ 1 3 0 1 ] A^3 = \begin{bmatrix} 1 & 3 \\ 0 & 1 \end{bmatrix} A 3 = [ 1 0 3 1 ] .
[ 4 3 ] [ 10 12 30 28 ] = [ 130 132 ] \begin{bmatrix} 4 & 3 \end{bmatrix}\begin{bmatrix} 10 & 12 \\ 30 & 28 \end{bmatrix} = \begin{bmatrix} 130 & 132 \end{bmatrix} [ 4 3 ] [ 10 30 12 28 ] = [ 130 132 ] : ₹130 at the first shop and ₹132 at the second.