If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

### Course: Algebra (all content)>Unit 20

Lesson 8: Multiplying matrices by matrices

# Multiplying matrices

When we multiply a matrix by a scalar (i.e., a single number) we simply multiply all the matrix's terms by that scalar. We can also multiply a matrix by another matrix, but this process is more complicated. Even so, it is very beautiful and interesting. Learn how to do it with this article.

#### 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}_{2,1}$ is the entry in the $2\text{nd row}$ and the $1\text{st column}$ 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.
$\begin{array}{rl}2\cdot \left[\begin{array}{cc}5& 2\\ 3& 1\end{array}\right]& =\left[\begin{array}{cc}2\cdot 5& 2\cdot 2\\ 2\cdot 3& 2\cdot 1\end{array}\right]\\ \\ & =\left[\begin{array}{cc}10& 4\\ 6& 2\end{array}\right]\end{array}$
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$‍ -tuples and the dot product

We are familiar with ordered pairs, for example $\left(2,5\right)$, and perhaps even ordered triples, for example $\left(3,1,8\right)$.
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{array}{rl}\left(2,5\right)\cdot \left(3,1\right)& =2\cdot 3+5\cdot 1\\ \\ & =6+5\\ \\ & =11\end{array}$
Ordered $n$-tuples are often indicated by a variable with an arrow on top. For example, we can let $\stackrel{\to }{a}=\left(3,1,8\right)$ and $\stackrel{\to }{b}=\left(4,2,3\right)$. The expression $\stackrel{\to }{a}\cdot \stackrel{\to }{b}$ indicates the dot product of these two ordered triples and can be found as follows:
$\begin{array}{rl}\stackrel{\to }{a}\cdot \stackrel{\to }{b}& =\left(3,1,8\right)\cdot \left(4,2,3\right)\\ \\ & =3\cdot 4+1\cdot 2+8\cdot 3\\ \\ & =12+2+24\\ \\ & =38\end{array}$
Notice that the dot product of two $n$-tuples of equal length is always a single real number.

1) Let $\stackrel{\to }{c}=\left(4,3\right)$ and $\stackrel{\to }{d}=\left(3,5\right)$.
$\stackrel{\to }{c}\cdot \stackrel{\to }{d}=$

2) Let $\stackrel{\to }{m}=\left(2,5,-2\right)$ and $\stackrel{\to }{n}=\left(1,8,-3\right)$.
$\stackrel{\to }{m}\cdot \stackrel{\to }{n}=$

## Matrices and $n$‍ -tuples

When multiplying matrices, it's useful to think of each matrix row and column as an $n$-tuple.
$\begin{array}{rcc}& \stackrel{\to }{{c}_{1}}& \stackrel{\to }{{c}_{2}}\\ & ↓& ↓\\ \\ \begin{array}{c}\stackrel{\to }{{r}_{1}}\to \\ \stackrel{\to }{{r}_{2}}\to \end{array}& \left[\begin{array}{c}6\\ 4\end{array}& \begin{array}{c}2\\ 3\end{array}\right]\end{array}$
In this matrix, row $1$ is denoted $\stackrel{\to }{{r}_{1}}=\left(6,2\right)$ and row $2$ is denoted $\stackrel{\to }{{r}_{2}}=\left(4,3\right)$.
Similarly, column $1$ is denoted $\stackrel{\to }{{c}_{1}}=\left(6,4\right)$ and column $2$ is denoted $\stackrel{\to }{{c}_{2}}=\left(2,3\right)$.

$\begin{array}{rccc}& \stackrel{\to }{{c}_{1}}& \stackrel{\to }{{c}_{2}}& \stackrel{\to }{{c}_{3}}\\ & ↓& ↓& ↓\\ \\ \begin{array}{c}\stackrel{\to }{{r}_{1}}\to \\ \stackrel{\to }{{r}_{2}}\to \\ \stackrel{\to }{{r}_{3}}\to \end{array}& \left[\begin{array}{c}1\\ 6\\ 2\end{array}& \begin{array}{c}3\\ 3\\ 1\end{array}& \begin{array}{c}5\\ 7\\ 4\end{array}\right]\end{array}$
3) Which of the following ordered triples is $\stackrel{\to }{{c}_{2}}$?

## 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=AB$.
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.
$\begin{array}{cccccc}& & & & \stackrel{\to }{{b}_{1}}& \stackrel{\to }{{b}_{2}}\\ & & & & ↓& ↓\\ \\ \begin{array}{c}\stackrel{\to }{{a}_{1}}\to \\ \stackrel{\to }{{a}_{2}}\to \end{array}& \left[\begin{array}{c}1\\ 2\end{array}& \begin{array}{c}7\\ 4\end{array}\right]& \cdot & \left[\begin{array}{c}3\\ 5\end{array}& \begin{array}{c}3\\ 2\end{array}\right]& =& \left[\begin{array}{c}\stackrel{\to }{{a}_{1}}\cdot \stackrel{\to }{{b}_{1}}\\ \stackrel{\to }{{a}_{2}}\cdot \stackrel{\to }{{b}_{1}}\end{array}& \begin{array}{c}\stackrel{\to }{{a}_{1}}\cdot \stackrel{\to }{{b}_{2}}\\ \stackrel{\to }{{a}_{2}}\cdot \stackrel{\to }{{b}_{2}}\end{array}\right]\\ \\ & A& & & B& & & C\end{array}$
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}_{i,j}$ is the dot product of $\stackrel{\to }{{a}_{i}}$ and $\stackrel{\to }{{b}_{j}}$.
For example, ${c}_{1,2}$ is the dot product of $\stackrel{\to }{{a}_{1}}$ and $\stackrel{\to }{{b}_{2}}$.
$\begin{array}{cccccccc}\left[\begin{array}{c}\mathbf{1}\\ 2\end{array}& \begin{array}{c}\mathbf{7}\\ 4\end{array}\right]& \cdot & \left[\begin{array}{c}3\\ 5\end{array}& \begin{array}{c}\mathbf{3}\\ \mathbf{2}\end{array}\right]& =& \left[\begin{array}{c}\stackrel{\to }{{a}_{1}}\cdot \stackrel{\to }{{b}_{1}}\\ \stackrel{\to }{{a}_{2}}\cdot \stackrel{\to }{{b}_{1}}\end{array}& \begin{array}{c}\mathbf{17}\\ \stackrel{\to }{{a}_{2}}\cdot \stackrel{\to }{{b}_{2}}\end{array}\right]\end{array}$
We can complete the dot products to find the complete product matrix:
$C=\left[\begin{array}{rr}38& 17\\ 26& 14\end{array}\right]$

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=C\cdot D$.
a) Which of the following is ${f}_{2,1}$?

b) Find $F$.
$F=$

5) $X=\left[\begin{array}{rr}4& 1\\ 2& 3\end{array}\right]$ and $Y=\left[\begin{array}{rr}2& 8\\ 5& 4\end{array}\right]$.
Find $Z=X\cdot Y$.
$Z=$

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=M\cdot N$.
a) Which of the following is ${p}_{1,2}$?

b) Find $P$.
$P=$

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

## Want to join the conversation?

• What Matrixes cannot be multlipied by eachother?
• A matrix can be multiplied by any other matrix that has the same number of rows as the first has columns. I.E. A matrix with 2 columns can be multiplied by any matrix with 2 rows. (An easy way to determine this is to write out each matrix's rows x columns, and if the numbers on the inside are the same, they can be multiplied. E.G. 2 x 3 times 3 x 3. These matrices may be multiplied by each other to create a 2 x 3 matrix.)

So the answer to your question is, a matrix cannot be multiplied by a matrix with a different number of rows then the first has columns.
• Can we take the dot product of two n-tuples of unequal length? Or is that undefined like when adding two matrices with different dimensions?
• You are correct in your assumption, the n-tuples must be of equal length.
• This article/lesson didn't really illustrate the rules of multiplying matrices with different dimensions, and as a result I bombed the following practice. Did anyone else have similar results?

How do I report this to KhanAcademy? There doesn't seem to be any option anywhere for "please include more content" or "this didn't help me and here's why" on the site.
• I don't understand this at all. Can someone give me a different explanation?
• how do you solve a 2 by 2 times a 3 by 2
• In order to mutiply two matrices, the number of columns in the first matrix has to be the same as the number of rows in the second matrix. Here, you're trying to multiply a 2x2 matrix by a matrix with 3 rows, which you just can't do. Multiplication as a matrix operation is only defined when the columns in the first matrix and rows in the second matrix are the same number.
• The article as a whole seems to use the dot product and the cross product interchangeably. I was under the impression that this was not the case for matrices. Are they indeed interchangeable?
• Cross product is not used in the article, and they are indeed different operations that cannot be used interchangeably.
• is a square matrix containing a row or column of zeros invertible ?
• Great question! If you have a row of zeros, the matrix 'crushes' the dimension of a vector down (eg. a cube crushed into a plane). So information about where the point was along some axis is lost. Because of this, the matrix isn't invertible since there's no way to gain back the information of where it would be along the axis where it was crushed.
• Could you elaborate about dot product? I don't really understand what it is.
What is it and why do we use this?