Introduction to Matrices and Matrix Operations: Learn It 4

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.

A has two rows and three columns and B has three rows and three columns. Because the number of columns in A matches the number of rows in B, the product of A and B is 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.

Work through the example model of matrix multiplication below on paper, then apply the process to the example problem below. It may take more than once to gain familiarity with it. Don’t be discouraged if you don’t understand fully right away. Matrix multiplication is a new skill and it will take time and practice for it to feel comfortable.

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.

[latex]A=\left[\begin{array}{rrr}\hfill {a}_{11}& \hfill {a}_{12}& \hfill {a}_{13}\\ \hfill {a}_{21}& \hfill {a}_{22}& \hfill {a}_{23}\end{array}\right]\text{ and }B=\left[\begin{array}{rrr}\hfill {b}_{11}& \hfill {b}_{12}& \hfill {b}_{13}\\ \hfill {b}_{21}& \hfill {b}_{22}& \hfill {b}_{23}\\ \hfill {b}_{31}& \hfill {b}_{32}& \hfill {b}_{33}\end{array}\right][/latex]

Multiply and add as follows to obtain the first entry of the product matrix [latex]AB[/latex].

  1. 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]
  2. 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]
  3. 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

[latex]AB=\left[\begin{array}{c}\begin{array}{l}{a}_{11}\cdot {b}_{11}+{a}_{12}\cdot {b}_{21}+{a}_{13}\cdot {b}_{31}\\ \end{array}\\ {a}_{21}\cdot {b}_{11}+{a}_{22}\cdot {b}_{21}+{a}_{23}\cdot {b}_{31}\end{array} \quad \begin{array}{c}\begin{array}{l}{a}_{11}\cdot {b}_{12}+{a}_{12}\cdot {b}_{22}+{a}_{13}\cdot {b}_{32}\\ \end{array}\\ {a}_{21}\cdot {b}_{12}+{a}_{22}\cdot {b}_{22}+{a}_{23}\cdot {b}_{32}\end{array} \quad \begin{array}{c}\begin{array}{l}{a}_{11}\cdot {b}_{13}+{a}_{12}\cdot {b}_{23}+{a}_{13}\cdot {b}_{33}\\ \end{array}\\ {a}_{21}\cdot {b}_{13}+{a}_{22}\cdot {b}_{23}+{a}_{23}\cdot {b}_{33}\end{array}\right][/latex]

matrix multiplication

In matrix multiplication, we calculate each element of the resulting matrix by taking the dot product of the corresponding row from the first matrix and the column from the second matrix. This involves multiplying corresponding entries and then summing those products.

Properties of Matrix Multiplication

  • 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.

Multiply matrix [latex]A[/latex] and matrix [latex]B[/latex].

[latex]A=\left[\begin{array}{cc}1& 2\\ 3& 4\end{array}\right]\text{ and }B=\left[\begin{array}{cc}5& 6\\ 7& 8\end{array}\right][/latex]

Given [latex]A[/latex] and [latex]B:[/latex]

[latex]A=\left[\begin{array}{ccc}\hfill -1& \hfill 2& \hfill 3\\ \hfill 4& \hfill 0& \hfill 5\end{array}\right]\text{ and }B=\left[\begin{array}{cc}\hfill 5& \hfill -1\\ \hfill -4& \hfill 0\\ \hfill 2& \hfill 3\end{array}\right][/latex]

  1. Find [latex]AB[/latex].
  2. Find [latex]BA[/latex].

Is it possible for [latex]AB[/latex] to be defined but not [latex]BA[/latex]?


Yes, consider a matrix [latex]A[/latex] with dimension [latex]3\times 4[/latex] and matrix [latex]B[/latex] with dimension [latex]4\times 2[/latex]. For the product [latex]AB[/latex] the inner dimensions are [latex]4[/latex] and the product is defined, but for the product [latex]BA[/latex] the inner dimensions are [latex]2[/latex] and [latex]3[/latex] so the product is undefined.

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 [latex]6[/latex] [latex]10[/latex]
Balls [latex]30[/latex] [latex]24[/latex]
Jerseys [latex]14[/latex] [latex]20[/latex]

We are also given the prices of the equipment, as shown in the table below.

Goal [latex]$300[/latex]
Ball [latex]$10[/latex]
Jersey [latex]$30[/latex]

We will convert the data to matrices. Thus, the equipment need matrix is written as

[latex]E=\left[\begin{array}{c}6\\ 30\\ 14\end{array}\begin{array}{c}10\\ 24\\ 20\end{array}\right][/latex]

The cost matrix is written as

[latex]C=\left[\begin{array}{ccc}300& 10& 30\end{array}\right][/latex]
We perform matrix multiplication to obtain costs for the equipment.
[latex]\begin{array}{l}\hfill \\ \hfill \\ CE & =\left[\begin{array}{rrr}\hfill 300& \hfill 10& \hfill 30\end{array}\right]\cdot \left[\begin{array}{rr}\hfill 6& \hfill 10\\ \hfill 30& \hfill 24\\ \hfill 14& \hfill 20\end{array}\right]\hfill \\ & =\left[\begin{array}{rr}\hfill 300\left(6\right)+10\left(30\right)+30\left(14\right)& \hfill 300\left(10\right)+10\left(24\right)+30\left(20\right)\end{array}\right]\hfill \\ & =\left[\begin{array}{rr}\hfill 2,520& \hfill 3,840\end{array}\right]\hfill \end{array}[/latex]

The total cost for equipment for the Wildcats is [latex]$2,520[/latex], and the total cost for equipment for the Mud Cats is [latex]$3,840[/latex].

How To: Given a matrix operation, evaluate using a calculator

  1. Save each matrix as a matrix variable
    [latex]\left[A\right],\left[B\right],\left[C\right],..[/latex]
  2. Enter the operation into the calculator, calling up each matrix variable as needed.
  3. If the operation is defined, the calculator will present the solution matrix; if the operation is undefined, it will display an error message.
Using a calculator, find [latex]AB-C[/latex] given

[latex]A=\left[\begin{array}{rrr}\hfill -15& \hfill 25& \hfill 32\\ \hfill 41& \hfill -7& \hfill -28\\ \hfill 10& \hfill 34& \hfill -2\end{array}\right],B=\left[\begin{array}{rrr}\hfill 45& \hfill 21& \hfill -37\\ \hfill -24& \hfill 52& \hfill 19\\ \hfill 6& \hfill -48& \hfill -31\end{array}\right],\text{and }C=\left[\begin{array}{rrr}\hfill -100& \hfill -89& \hfill -98\\ \hfill 25& \hfill -56& \hfill 74\\ \hfill -67& \hfill 42& \hfill -75\end{array}\right][/latex].