200 Finding the Product of Two Matrices
In addition to multiplying a matrix by a scalar, we can multiply two matrices. Finding the product of two matrices is only possible when the inner dimensions are the same, meaning that the number of columns of the first matrix is equal to the number of rows of the second matrix. If [latex]A[/latex] is an [latex]\text{ }m\text{ }\times \text{ }r\text{ }[/latex] matrix and [latex]B[/latex] is an [latex]\text{ }r\text{ }\times \text{ }n\text{ }[/latex] matrix, then the product matrix [latex]AB[/latex] is an [latex]\text{ }m\text{ }\times \text{ }n\text{ }[/latex] matrix. For example, the product [latex]AB[/latex] is possible because the number of columns in [latex]A[/latex] is the same as the number of rows in [latex]B[/latex]. If the inner dimensions do not match, the product is not defined.
We multiply entries of [latex]A[/latex] with entries of [latex]B[/latex] according to a specific pattern as outlined below. The process of matrix multiplication becomes clearer when working a problem with real numbers.
To obtain the entries in row [latex]i[/latex] of [latex]AB,\text{}[/latex] we multiply the entries in row [latex]i[/latex] of [latex]A[/latex] by column [latex]j[/latex] in [latex]B[/latex] and add. For example, given matrices [latex]A[/latex] and [latex]B,\text{}[/latex] where the dimensions of [latex]A[/latex] are [latex]2\text{ }\times \text{ }3[/latex] and the dimensions of [latex]B[/latex] are [latex]3\text{ }\times \text{ }3,\text{}[/latex] the product of [latex]AB[/latex] will be a [latex]2\text{ }\times \text{ }3[/latex] matrix.
Multiply and add as follows to obtain the first entry of the product matrix [latex]AB[/latex].
- To obtain the entry in row 1, column 1 of [latex]AB,\text{}[/latex] multiply the first row in [latex]A[/latex] by the first column in [latex]B[/latex], and add.
[latex]\left[\begin{array}{ccc}{a}_{11}& {a}_{12}& {a}_{13}\end{array}\right]\cdot \left[\begin{array}{c}{b}_{11}\\ {b}_{21}\\ {b}_{31}\end{array}\right]={a}_{11}\cdot {b}_{11}+{a}_{12}\cdot {b}_{21}+{a}_{13}\cdot {b}_{31}[/latex]
- To obtain the entry in row 1, column 2 of [latex]AB,\text{}[/latex] multiply the first row of [latex]A[/latex] by the second column in [latex]B[/latex], and add.
[latex]\left[\begin{array}{ccc}{a}_{11}& {a}_{12}& {a}_{13}\end{array}\right]\cdot \left[\begin{array}{c}{b}_{12}\\ {b}_{22}\\ {b}_{32}\end{array}\right]={a}_{11}\cdot {b}_{12}+{a}_{12}\cdot {b}_{22}+{a}_{13}\cdot {b}_{32}[/latex]
- To obtain the entry in row 1, column 3 of [latex]AB,\text{}[/latex] multiply the first row of [latex]A[/latex] by the third column in [latex]B[/latex], and add.
[latex]\left[\begin{array}{ccc}{a}_{11}& {a}_{12}& {a}_{13}\end{array}\right]\cdot \left[\begin{array}{c}{b}_{13}\\ {b}_{23}\\ {b}_{33}\end{array}\right]={a}_{11}\cdot {b}_{13}+{a}_{12}\cdot {b}_{23}+{a}_{13}\cdot {b}_{33}[/latex]
We proceed the same way to obtain the second row of [latex]AB[/latex]. In other words, row 2 of [latex]A[/latex] times column 1 of [latex]B[/latex]; row 2 of [latex]A[/latex] times column 2 of [latex]B[/latex]; row 2 of [latex]A[/latex] times column 3 of [latex]B[/latex]. When complete, the product matrix will be
A General Note: Properties of Matrix Multiplication
For the matrices [latex]A,B,\text{}[/latex] and [latex]C[/latex] the following properties hold.
- Matrix multiplication is associative: [latex]\left(AB\right)C=A\left(BC\right)[/latex].
- Matrix multiplication is distributive: [latex]\begin{array}{l}\begin{array}{l}\\ C\left(A+B\right)=CA+CB,\end{array}\hfill \\ \left(A+B\right)C=AC+BC.\hfill \end{array}[/latex]
Note that matrix multiplication is not commutative.
Example 8: Multiplying Two Matrices
Multiply matrix [latex]A[/latex] and matrix [latex]B[/latex].
Solution
First, we check the dimensions of the matrices. Matrix [latex]A[/latex] has dimensions [latex]2\times 2[/latex] and matrix [latex]B[/latex] has dimensions [latex]2\times 2[/latex]. The inner dimensions are the same so we can perform the multiplication. The product will have the dimensions [latex]2\times 2[/latex].
We perform the operations outlined previously.
Example 9: Multiplying Two Matrices
Given [latex]A[/latex] and [latex]B:[/latex]
- Find [latex]AB[/latex].
- Find [latex]BA[/latex].
Solution
- As the dimensions of [latex]A[/latex] are [latex]2\text{}\times \text{}3[/latex] and the dimensions of [latex]B[/latex] are [latex]3\text{}\times \text{}2,\text{}[/latex] these matrices can be multiplied together because the number of columns in [latex]A[/latex] matches the number of rows in [latex]B[/latex]. The resulting product will be a [latex]2\text{}\times \text{}2[/latex] matrix, the number of rows in [latex]A[/latex] by the number of columns in [latex]B[/latex].
[latex]\begin{array}{l}\hfill \\ AB=\left[\begin{array}{rrr}\hfill -1& \hfill 2& \hfill 3\\ \hfill 4& \hfill 0& \hfill 5\end{array}\right]\text{ }\left[\begin{array}{rr}\hfill 5& \hfill -1\\ \hfill -4& \hfill 0\\ \hfill 2& \hfill 3\end{array}\right]\hfill \\ \text{ }=\left[\begin{array}{rr}\hfill -1\left(5\right)+2\left(-4\right)+3\left(2\right)& \hfill -1\left(-1\right)+2\left(0\right)+3\left(3\right)\\ \hfill 4\left(5\right)+0\left(-4\right)+5\left(2\right)& \hfill 4\left(-1\right)+0\left(0\right)+5\left(3\right)\end{array}\right]\hfill \\ \text{ }=\left[\begin{array}{rr}\hfill -7& \hfill 10\\ \hfill 30& \hfill 11\end{array}\right]\hfill \end{array}[/latex]
- The dimensions of [latex]B[/latex] are [latex]3\times 2[/latex] and the dimensions of [latex]A[/latex] are [latex]2\times 3[/latex]. The inner dimensions match so the product is defined and will be a [latex]3\times 3[/latex] matrix.
[latex]\begin{array}{l}\hfill \\ BA=\left[\begin{array}{rr}\hfill 5& \hfill -1\\ \hfill -4& \hfill 0\\ \hfill 2& \hfill 3\end{array}\right]\text{ }\left[\begin{array}{rrr}\hfill -1& \hfill 2& \hfill 3\\ \hfill 4& \hfill 0& \hfill 5\end{array}\right]\hfill \\ \text{ }=\left[\begin{array}{rrr}\hfill 5\left(-1\right)+-1\left(4\right)& \hfill 5\left(2\right)+-1\left(0\right)& \hfill 5\left(3\right)+-1\left(5\right)\\ \hfill -4\left(-1\right)+0\left(4\right)& \hfill -4\left(2\right)+0\left(0\right)& \hfill -4\left(3\right)+0\left(5\right)\\ \hfill 2\left(-1\right)+3\left(4\right)& \hfill 2\left(2\right)+3\left(0\right)& \hfill 2\left(3\right)+3\left(5\right)\end{array}\right]\hfill \\ \text{ }=\left[\begin{array}{rrr}\hfill -9& \hfill 10& \hfill 10\\ \hfill 4& \hfill -8& \hfill -12\\ \hfill 10& \hfill 4& \hfill 21\end{array}\right]\hfill \end{array}[/latex]
Analysis of the Solution
Notice that the products [latex]AB[/latex] and [latex]BA[/latex] are not equal.
This illustrates the fact that matrix multiplication is not commutative.
Q & A
Is it possible for AB to be defined but not BA?
Yes, consider a matrix A with dimension [latex]3\times 4[/latex] and matrix B with dimension [latex]4\times 2[/latex]. For the product AB the inner dimensions are 4 and the product is defined, but for the product BA the inner dimensions are 2 and 3 so the product is undefined.
Example 10: Using Matrices in Real-World Problems
Let’s return to the problem presented at the opening of this section. We have the table below, representing the equipment needs of two soccer teams.
Wildcats | Mud Cats | |
---|---|---|
Goals | 6 | 10 |
Balls | 30 | 24 |
Jerseys | 14 | 20 |
We are also given the prices of the equipment, as shown in the table below.
Goal | $300 |
Ball | $10 |
Jersey | $30 |
We will convert the data to matrices. Thus, the equipment need matrix is written as
The cost matrix is written as
We perform matrix multiplication to obtain costs for the equipment.
The total cost for equipment for the Wildcats is $2,520, and the total cost for equipment for the Mud Cats is $3,840.
How To: Given a matrix operation, evaluate using a calculator.
- Save each matrix as a matrix variable [latex]\left[A\right],\left[B\right],\left[C\right],..[/latex].
- Enter the operation into the calculator, calling up each matrix variable as needed.
- If the operation is defined, the calculator will present the solution matrix; if the operation is undefined, it will display an error message.
Example 11: Using a Calculator to Perform Matrix Operations
Find [latex]AB-C[/latex] given
Solution
On the matrix page of the calculator, we enter matrix [latex]A[/latex] above as the matrix variable [latex]\left[A\right][/latex], matrix [latex]B[/latex] above as the matrix variable [latex]\left[B\right][/latex], and matrix [latex]C[/latex] above as the matrix variable [latex]\left[C\right][/latex].
On the home screen of the calculator, we type in the problem and call up each matrix variable as needed.
The calculator gives us the following matrix.