# Multiplying matrices

Learn how to multiply a matrix by another matrix.

#### What you should be familiar with before taking this lesson

A matrix is a rectangular arrangement of numbers into rows and columns. Each number in a matrix is referred to as a matrix element or entry.
For example, matrix A has 2 rows and 3 columns. The element a, start subscript, start color blueD, 2, end color blueD, comma, start color goldD, 1, end color goldD, end subscript is the entry in the start color blueD, 2, n, d, space, r, o, w, end color blueD and the start color goldD, 1, s, t, space, c, o, l, u, m, n, end color goldD of matrix A, or 5.
If this is new to you, we recommend that you check out our intro to matrices. You should also make sure you know how to multiply a matrix by a scalar.

#### What you will learn in this lesson

How to find the product of two matrices. For example, find
$\left[\begin{array}{rr}{1} &7 \\ 2& 4 \end{array}\right]\cdot\left[\begin{array}{rr}{3} &3 \\ 5& 2 \end{array}\right]$.

## Scalar multiplication and matrix multiplication

When we work with matrices, we refer to real numbers as scalars.
The term scalar multiplication refers to the product of a real number and a matrix. In scalar multiplication, each entry in the matrix is multiplied by the given scalar.
In contrast, matrix multiplication refers to the product of two matrices. This is an entirely different operation. It's more complicated, but also more interesting! Let's see how it's done.
Understanding how to find the dot product of two ordered lists of numbers can help us tremendously in this quest, so let's learn about that first!

## $n$n-tuples and the dot product

We are familiar with ordered pairs, for example left parenthesis, 2, comma, 5, right parenthesis, and perhaps even ordered triples, for example left parenthesis, 3, comma, 1, comma, 8, right parenthesis.
An n-tuple is a generalization of this. It is an ordered list of n numbers.
We can find the dot product of two n-tuples of equal length by summing the products of corresponding entries.
For example, to find the dot product of two ordered pairs, we multiply the first coordinates and the second coordinates and add the results.
\begin{aligned}(\purpleC2,\greenD5)\cdot (\purpleC3,\greenC1)&=\purpleC2\cdot \purpleC3+\greenD5\cdot \greenD1\\ \\ &=6+5\\ \\&=11 \end{aligned}
Ordered n-tuples are often indicated by a variable with an arrow on top. For example, we can let a, with, vector, on top, equals, left parenthesis, 3, comma, 1, comma, 8, right parenthesis and b, with, vector, on top, equals, left parenthesis, 4, comma, 2, comma, 3, right parenthesis. The expression a, with, vector, on top, dot, b, with, vector, on top indicates the dot product of these two ordered triples and can be found as follows:
\begin{aligned}\vec{a}\cdot \vec{b}&=(\purpleC 3,\greenD1,\maroonC8)\cdot (\purpleC4, \greenD2, \maroonC3 )\\\\&=\purpleC3\cdot \purpleC4+\greenD1\cdot \greenD2+\maroonC8\cdot \maroonC3\\ \\ &=12+2+24\\ \\&=38 \end{aligned}
Notice that the dot product of two n-tuples of equal length is always a single real number.

### Check your understanding

1) Let c, with, vector, on top, equals, left parenthesis, 4, comma, 3, right parenthesis and d, with, vector, on top, equals, left parenthesis, 3, comma, 5, right parenthesis.
c, with, vector, on top, dot, d, with, vector, on top, equals

\begin{aligned}\vec{c}\cdot \vec{d}&=(\purpleC4, \greenD3) \cdot (\purpleC 3, \greenD 5)\\ \\ &=\purpleC4\cdot \purpleC 3+\greenD3\cdot \greenD5\\\\ &=12+15\\\\ &=27\end{aligned}
2) Let m, with, vector, on top, equals, left parenthesis, 2, comma, 5, comma, minus, 2, right parenthesis and n, with, vector, on top, equals, left parenthesis, 1, comma, 8, comma, minus, 3, right parenthesis.
m, with, vector, on top, dot, n, with, vector, on top, equals

\begin{aligned}\vec{m}\cdot \vec{n}&=(\purpleC 2, \greenD 5, \maroonC{-2})\cdot (\purpleC 1, \greenD 8, \maroonC{-3})\\\\ &=2\cdot 1+5\cdot 8+(-2)(-3)\\\\ &=2+40+6\\\\ &=48\end{aligned}

## Matrices and $n$n-tuples

When multiplying matrices, it's useful to think of each matrix row and column as an n-tuple.
In this matrix, row 1 is denoted start color blueD, r, start subscript, 1, end subscript, with, vector, on top, end color blueD, equals, left parenthesis, 6, comma, 2, right parenthesis and row 2 is denoted start color blueD, r, start subscript, 2, end subscript, with, vector, on top, end color blueD, equals, left parenthesis, 4, comma, 3, right parenthesis.
Similarly, column 1 is denoted start color goldD, c, start subscript, 1, end subscript, with, vector, on top, end color goldD, equals, left parenthesis, 6, comma, 4, right parenthesis and column 2 is denoted start color goldD, c, start subscript, 2, end subscript, with, vector, on top, end color goldD, equals, left parenthesis, 2, comma, 3, right parenthesis.

### Check your understanding

3) Which of the following ordered triples is c, start subscript, 2, end subscript, with, vector, on top?
Choose 1 answer:
Choose 1 answer:

c, start subscript, 2, end subscript, with, vector, on top refers to the ordered triple in the second column of the matrix.
c, start subscript, 2, end subscript, with, vector, on top, equals, left parenthesis, 3, comma, 3, comma, 1, right parenthesis

## Matrix multiplication

We are now ready to look at an example of matrix multiplication.
Given $A=\left[\begin{array}{rr}{1} &7 \\ 2& 4 \end{array}\right]$ and $B=\left[\begin{array}{rr}{3} &3 \\ 5& 2 \end{array}\right]$, let's find matrix C, equals, A, B.
To help our understanding, let's label the rows in matrix A and the columns in matrix B. We can define the product matrix, matrix C, as shown below.
Notice that each entry in matrix C is the dot product of a row in matrix A and a column in matrix B. Specifically, the entry c, start subscript, start color blueD, i, end color blueD, comma, start color goldD, j, end color goldD, end subscript is the dot product of start color blueD, a, start subscript, i, end subscript, with, vector, on top, end color blueD and start color goldD, b, start subscript, j, end subscript, with, vector, on top, end color goldD.
In the image below, we see that c, start subscript, start color blueD, 1, end color blueD, comma, start color goldD, 2, end color goldD, end subscript is the dot product of start color blueD, a, start subscript, 1, end subscript, with, vector, on top, end color blueD and start color goldD, b, start subscript, 2, end subscript, with, vector, on top, end color goldD.
\begin{aligned}c_{\blueD1,\goldD2}&=(\blueD1,\blueD7)\cdot (\goldD3,\goldD2)\\ &=\blueD1\cdot \goldD3+\blueD7\cdot \goldD2\\&=3+14\\&=17 \end{aligned}
We can complete the dot products to find the complete product matrix:
$C=\left[\begin{array}{rr}{38} &17 \\ 26& 14 \end{array}\right]$
\begin{aligned}c_{\blueD1,\goldD1}&=\blueD{\vec{a_1}}\cdot \goldD{\vec{b_1}}\\ &=(\blueD1,\blueD7)\cdot (\goldD3,\goldD5)\\ &=\blueD1\cdot \goldD3+\blueD7\cdot \goldD5\\&=3+35\\&=38 \end{aligned}
\begin{aligned}c_{\blueD2,\goldD1}&=\blueD{\vec{a_2}}\cdot \goldD{\vec{b_1}}\\ &=(\blueD2,\blueD4)\cdot (\goldD3,\goldD5)\\ &=\blueD2\cdot \goldD3+\blueD4\cdot \goldD5\\&=6+20\\&=26 \end{aligned}
\begin{aligned}c_{\blueD2,\goldD2}&=\blueD{\vec{a_2}}\cdot \goldD{\vec{b_2}}\\ &=(\blueD2,\blueD4)\cdot (\goldD3,\goldD2)\\ &=\blueD2\cdot \goldD3+\blueD4\cdot \goldD2\\&=6+8\\&=14 \end{aligned}

### Check your understanding

4) $C=\left[\begin{array}{rr}{2} &1 \\ 5& 2 \end{array}\right]$ and $D=\left[\begin{array}{rr}{1} &4 \\ 3& 6 \end{array}\right]$.
Let F, equals, C, dot, D.
a) Which of the following is f, start subscript, 2, comma, 1, end subscript?
Choose 1 answer:
Choose 1 answer:

The entry f, start subscript, start color blueD, 2, end color blueD, comma, start color goldD, 1, end color goldD, end subscript is the dot product of start color blueD, 2, n, d, space, r, o, w, space, i, n, space, C, end color blueD and the start color goldD, 1, s, t, space, c, o, l, u, m, n, space, i, n, space, D, end color goldD.
Since $C=\left[\begin{array}{rr}{2} &1 \\ \blueD5& \blueD2 \end{array}\right]$ and $D=\left[\begin{array}{rr}{\goldD1} &4 \\ \goldD3& 6 \end{array}\right]$, we have:
\begin{aligned}f_{\blueD2,\goldD1}&=\blueD{(5,2)}\cdot \goldD{(1,3)}\\ \\ &=5\cdot 1+2\cdot 3\\ \\ &=11 \end{aligned}
b) Find F.
F, equals

Let's start by labeling the rows in matrix C and the columns in matrix D.
We can find the product, matrix F, as follows:
\begin{aligned}F&=\left[\begin{array}{rr}{2} & {1} \\ 5 & 2\end{array}\right]\left[\begin{array}{rr} 1 & 4 \\ {3} & 6\end{array}\right]\\\\\\ &=\left[\begin{array}{rr}{\vec{c_1}\cdot \vec{d_1}} & {\vec{c_1}\cdot \vec{d_2}} \\ \vec{c_2}\cdot \vec{d_1} & \vec{c_2}\cdot \vec{d_2}\end{array}\right]\\\\\\ &=\left[\begin{array}{rr}{2\cdot 1+1\cdot 3} & {2\cdot 4+1\cdot 6} \\ 5\cdot 1+2\cdot 3 &5\cdot4+2\cdot 6\end{array}\right]\\\\\\ &=\left[\begin{array}{rr}{5} & {14} \\ 11 & 32\end{array}\right]\end{aligned}
5) $X=\left[\begin{array}{rr}{4} &1 \\ 2& 3 \end{array}\right]$ and $Y=\left[\begin{array}{rrr}{2} &8 \\ 5& 4 \end{array}\right]$.
Find Z, equals, X, dot, Y.
Z, equals

Let's start by labeling the rows in matrix X and the columns in matrix Y.
We can find the product, matrix Z, as follows:
\begin{aligned}Z&=\left[\begin{array}{rr}{4} &1 \\ 2& 3 \end{array}\right]\left[\begin{array}{rrr}{2} &8 \\ 5& 4 \end{array}\right]\\\\\\ &=\left[\begin{array}{rr}{\vec{x_1}\cdot \vec{y_1}} & {\vec{x_1}\cdot \vec{y_2}} \\ \vec{x_2}\cdot \vec{y_1} & \vec{x_2}\cdot \vec{y_2}\end{array}\right]\\\\\\ &=\left[\begin{array}{rr}{4\cdot 2+1\cdot 5} & {4\cdot 8+1\cdot 4} \\ 2\cdot 2+3\cdot 5 &2\cdot8+3\cdot 4\end{array}\right]\\\\\\ &=\left[\begin{array}{rr}{13} & {36} \\ 19 &28\end{array}\right]\end{aligned}
6) $M=\left[\begin{array}{rrr}{2} &8 &3 \\ 5& 4&1 \end{array}\right]$ and $N=\left[\begin{array}{rr}{4} &1 \\ 6& 3\\2&4 \end{array}\right]$.
Let P, equals, M, dot, N.
a) Which of the following is p, start subscript, 1, comma, 2, end subscript?
Choose 1 answer:
Choose 1 answer:

The entry p, start subscript, start color blueD, 1, end color blueD, comma, start color goldD, 2, end color goldD, end subscript is the dot product of start color blueD, 1, s, t, space, r, o, w, space, i, n, space, M, end color blueD and the start color goldD, 2, n, d, space, c, o, l, u, m, n, space, i, n, space, N, end color goldD.
Since $M=\left[\begin{array}{rrr}{\blueD2} &\blueD8 &\blueD3 \\ 5& 4&1 \end{array}\right]$ and $N=\left[\begin{array}{rr}{4} &\goldD1 \\ 6& \goldD3\\2&\goldD4 \end{array}\right]$ , we have:
\begin{aligned}p_{\blueD1,\goldD2}&=\blueD{(2,8,3)}\cdot \goldD{(1,3,4)}\\ \\ &=2\cdot 1+8\cdot 3+3\cdot 4\\ \\ &=2+24+12\\ \\ &=38 \end{aligned}
b) Find P.
P, equals

Let's start by labeling the rows in matrix M and the columns in matrix N.
We can find the product, matrix P, as follows:
\begin{aligned}P&=\left[\begin{array}{rrr}{2} &8 &3 \\ 5& 4&1 \end{array}\right]\left[\begin{array}{rr}{4} &1 \\ 6& 3\\2&4 \end{array}\right]\\\\\\ &=\left[\begin{array}{rr}{\vec{m_1}\cdot \vec{n_1}} & {\vec{m_1}\cdot \vec{n_2}} \\ \vec{m_2}\cdot \vec{n_1} & \vec{m_2}\cdot \vec{n_2}\end{array}\right]\\\\\\ &=\left[\begin{array}{rr}{2\cdot 4+8\cdot 6+3\cdot 2} & {2\cdot 1+8\cdot 3+3\cdot4} \\ 5\cdot 4+4\cdot 6+1\cdot 2 &5\cdot1+4\cdot 3+1\cdot 4\end{array}\right]\\\\\\ &=\left[\begin{array}{rr}{62} & {38} \\ 46&21\end{array}\right]\end{aligned}

## Why is matrix multiplication defined this way?

Up until now, you may have found operations with matrices fairly intuitive. For example when you add two matrices, you add the corresponding entries.
But things do not work as you'd expect them to work with multiplication. To multiply two matrices, we cannot simply multiply the corresponding entries.
If this troubles you, we recommend that you take a look at the following articles, where you will see matrix multiplication being put to use.