# Matrix multiplication dimensions

Learn about the conditions for matrix multiplication to be defined, and about the dimensions of the product of two matrices.

#### 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.
The dimensions of a matrix give the number of rows and columns of the matrix in that order. Since matrix A has 2 rows and 3 columns, it is called a 2, times, 3 matrix.
If this is new to you, we recommend that you check out our intro to matrices.
In matrix multiplication, each entry in the product matrix is the dot product of a row in the first matrix and and a column in the second matrix.
If this is new to you, we recommend that you check out our matrix multiplication article.

#### What you will learn in this lesson

We will investigate the relationship between the dimensions of two matrices and the dimensions of their product. Specifically, we will see that the dimensions of the matrices must meet a certain condition for the multiplication to be defined.

## When is matrix multiplication defined?

In order for matrix multiplication to be defined, the number of columns in the first matrix must be equal to the number of rows in the second matrix.
To see why this is the case, consider the following two matrices:
$A=\left[\begin{array}{rr}{1} &3 \\ 2& 4 \\ 2& 5 \end{array}\right]$ and $B=\left[\begin{array}{rrrr}{1} &3&2&2 \\ 2& 4&5&1 \end{array}\right]$
To find A, B, we take the the dot product of a row in A and a column in B. This means that the the number of entries in each row of A must be the same as the number of entries in each column of B.
Recall that the dot product is found by summing the products of corresponding entries in two n-tuples of equal dimensions.
Therefore, the only way to take the dot product of a row that contains two elements is to pair it with a column that also contains two elements.
$A=\left[\begin{array}{rr}{\maroonC1} &\maroonC3 \\ 2& 4 \\ 2& 5 \end{array}\right]$ and $B=\left[\begin{array}{rrrr}{\maroonC1} &3&2&2 \\ \maroonC2& 4&5&1 \end{array}\right]$
Note that if a matrix has two entries in each row, then the matrix has two columns. Similarly, if a matrix has two entries in each column, then it must have two rows.
So, it follows that in order for matrix multiplication to be defined, the number of columns in the first matrix must be equal to the number of rows in the second matrix.

1) $A=\left[\begin{array}{rr}{2} &4 \\ 6& 4 \\ 7& 3 \end{array}\right]$ and $B=\left[\begin{array}{rr}{2} &1 \\ 8& 5 \end{array}\right]$.
Is A, B defined?

A is a 3, times, start color maroonC, 2, end color maroonC matrix. It has start color maroonC, 2, end color maroonC columns.
B is a start color maroonC, 2, end color maroonC, times, 2 matrix. It has start color maroonC, 2, end color maroonC rows.
Since the number of columns in matrix A is equal to the number of rows in matrix B, A, B is defined.
2) $C=\left[\begin{array}{rrrr}{5} &3&6&1 \\ 6& 8&5&3 \end{array}\right]$ and $D=\left[\begin{array}{rrrr}{2} &1&8 \\ 7& 5&5 \end{array}\right]$.
Is C, D defined?

C is a 2, times, start color maroonC, 4, end color maroonC matrix. It has start color maroonC, 4, end color maroonC columns.
D is a start color goldD, 2, end color goldD, times, 3 matrix. It has start color goldD, 2, end color goldD rows.
The number of columns in the matrix C is not equal to the number of rows in matrix D, and so C, D is not defined.
3) A is a 4, times, 2 matrix and B is a 2, times, 3 matrix.
Is A, B defined?

Is B, A defined?

Be sure to note the order of the matrices in the product.
To determine if A, B is defined, we must examine the number of columns in matrix A and the number of rows in matrix B.
• A is a 4, times, start color maroonC, 2, end color maroonC matrix. It has start color maroonC, 2, end color maroonC columns.
• B is a start color maroonC, 2, end color maroonC, times, 3 matrix. It has start color maroonC, 2, end color maroonC rows.
Since the number of columns in matrix A is equal to the number of rows in matrix B, A, B is defined.
To determine if B, A is defined, we must examine the number of columns in matrix B and the number of rows in matrix A.
• B is a 2, times, start color maroonC, 3, end color maroonC matrix. It has start color maroonC, 3, end color maroonC columns.
• A is a start color goldD, 4, end color goldD, times, 2 matrix. It has start color goldD, 4, end color goldD rows.
The number of columns in matrix B is not equal to the number of rows in matrix A, and so B, A is not defined.

## Dimension property

The product of an start color blueD, m, end color blueD, times, start color maroonC, n, end color maroonC matrix and an start color maroonC, n, end color maroonC, times, start color goldD, k, end color goldD matrix is an start color blueD, m, end color blueD, times, start color goldD, k, end color goldD matrix.
Let's consider the product A, B, where $A=\left[\begin{array}{rr}{1} &3 \\ 2& 4 \\ 2& 5 \end{array}\right]$ and $B=\left[\begin{array}{rrrr}{1} &3&2&2 \\ 2& 4&5&1 \end{array}\right]$.
From above, we know that A, B is defined since the number of columns in A, start subscript, start color blueD, 3, end color blueD, times, start color maroonC, 2, end color maroonC, end subscript left parenthesis, start color maroonC, 2, end color maroonC, right parenthesis matches the number of rows in B, start subscript, start color maroonC, 2, end color maroonC, times, start color goldD, 4, end color goldD, end subscript left parenthesis, start color maroonC, 2, end color maroonC, right parenthesis.
To find A, B, we must be sure to find the dot product between each row in A and each column in B. So, the resulting matrix will have the same number of rows as matrix A, start subscript, start color blueD, 3, end color blueD, times, start color maroonC, 2, end color maroonC, end subscript left parenthesis, start color blueD, 3, end color blueD, right parenthesis and the same number of columns as matrix B, start subscript, start color maroonC, 2, end color maroonC, times, start color goldD, 4, end color goldD, end subscript left parenthesis, start color goldD, 4, end color goldD, right parenthesis. It will be a start color blueD, 3, end color blueD, times, start color goldD, 4, end color goldD matrix.

4) $A=\left[\begin{array}{rr}{2} &4 \\ 6& 4 \\ 7& 3 \end{array}\right]$ and $B=\left[\begin{array}{rr}{2} &1 \\ 8& 5 \end{array}\right]$.
What are the dimensions of A, B?
times

$A=\left[\begin{array}{rr}{2} &4 \\ 6& 4 \\ 7& 3 \end{array}\right]$ is a 3, times, 2 matrix.
$B=\left[\begin{array}{rr}{2} &1 \\ 8& 5 \end{array}\right]$ is a 2, times, 2 matrix.
So A, B is a 3, times, 2 matrix.
5) $C=\left[\begin{array}{rr}{4} &3&1 \\ 6&7& 2 \end{array}\right]$ and $D=\left[\begin{array}{r}{3}\\ 1 \\ 4 \end{array}\right]$.
What are the dimensions of C, D?
times

$C=\left[\begin{array}{rr}{4} &3&1 \\ 6&7& 2 \end{array}\right]$ is a 2, times, 3 matrix.
$D=\left[\begin{array}{r}{3}\\ 1 \\ 4 \end{array}\right]$ is a 3, times, 1 matrix.
6) A is a 2, times, 3 matrix and B is a 3, times, 4 matrix.
What are the dimensions of A, B?
times

So A, B is a 2, times, 4 matrix.
7) X is a 2, times, 1 matrix and Y is a 1, times, 2 matrix.
What are the dimensions of matrix X, Y?
times

So X, Y is a 2, times, 2 matrix.