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.

Main content

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 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=[132425]A=\left[\begin{array}{rr}{1} &3 \\ 2& 4 \\ 2& 5 \end{array}\right] and B=[13222451]B=\left[\begin{array}{rrrr}{1} &3&2&2 \\ 2& 4&5&1 \end{array}\right]
To find A, B, we take the dot product of a row in A and a column in B. This means that the number of entries in each row of A must be the same as the number of entries in each column of B.
A=[132425]A=\left[\begin{array}{rr}{\maroonC1} &\maroonC3 \\ 2& 4 \\ 2& 5 \end{array}\right] and B=[13222451]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.

Check your understanding

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

2) C=[53616853]C=\left[\begin{array}{rrrr}{5} &3&6&1 \\ 6& 8&5&3 \end{array}\right] and D=[218755]D=\left[\begin{array}{rrrr}{2} &1&8 \\ 7& 5&5 \end{array}\right].
Is C, D defined?
Choose 1 answer:
Choose 1 answer:

3) A is a 4, times, 2 matrix and B is a 2, times, 3 matrix.
Is A, B defined?
Choose 1 answer:
Choose 1 answer:

Is B, A defined?
Choose 1 answer:
Choose 1 answer:

Dimension property

The product of an start color #11accd, m, end color #11accd, times, start color #ed5fa6, n, end color #ed5fa6 matrix and an start color #ed5fa6, n, end color #ed5fa6, times, start color #e07d10, k, end color #e07d10 matrix is an start color #11accd, m, end color #11accd, times, start color #e07d10, k, end color #e07d10 matrix.
Let's consider the product A, B, where A=[132425]A=\left[\begin{array}{rr}{1} &3 \\ 2& 4 \\ 2& 5 \end{array}\right] and B=[13222451]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 #11accd, 3, end color #11accd, times, start color #ed5fa6, 2, end color #ed5fa6, end subscript left parenthesis, start color #ed5fa6, 2, end color #ed5fa6, right parenthesis matches the number of rows in B, start subscript, start color #ed5fa6, 2, end color #ed5fa6, times, start color #e07d10, 4, end color #e07d10, end subscript left parenthesis, start color #ed5fa6, 2, end color #ed5fa6, 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 #11accd, 3, end color #11accd, times, start color #ed5fa6, 2, end color #ed5fa6, end subscript left parenthesis, start color #11accd, 3, end color #11accd, right parenthesis and the same number of columns as matrix B, start subscript, start color #ed5fa6, 2, end color #ed5fa6, times, start color #e07d10, 4, end color #e07d10, end subscript left parenthesis, start color #e07d10, 4, end color #e07d10, right parenthesis. It will be a start color #11accd, 3, end color #11accd, times, start color #e07d10, 4, end color #e07d10 matrix.

Check your understanding

4) A=[246473]A=\left[\begin{array}{rr}{2} &4 \\ 6& 4 \\ 7& 3 \end{array}\right] and B=[2185]B=\left[\begin{array}{rr}{2} &1 \\ 8& 5 \end{array}\right].
What are the dimensions of A, B?
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3, slash, 5
  • a simplified improper fraction, like 7, slash, 4
  • a mixed number, like 1, space, 3, slash, 4
  • an exact decimal, like 0, point, 75
  • a multiple of pi, like 12, space, start text, p, i, end text or 2, slash, 3, space, start text, p, i, end text
times
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3, slash, 5
  • a simplified improper fraction, like 7, slash, 4
  • a mixed number, like 1, space, 3, slash, 4
  • an exact decimal, like 0, point, 75
  • a multiple of pi, like 12, space, start text, p, i, end text or 2, slash, 3, space, start text, p, i, end text

5) C=[431672]C=\left[\begin{array}{rr}{4} &3&1 \\ 6&7& 2 \end{array}\right] and D=[314]D=\left[\begin{array}{r}{3}\\ 1 \\ 4 \end{array}\right].
What are the dimensions of C, D?
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3, slash, 5
  • a simplified improper fraction, like 7, slash, 4
  • a mixed number, like 1, space, 3, slash, 4
  • an exact decimal, like 0, point, 75
  • a multiple of pi, like 12, space, start text, p, i, end text or 2, slash, 3, space, start text, p, i, end text
times
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3, slash, 5
  • a simplified improper fraction, like 7, slash, 4
  • a mixed number, like 1, space, 3, slash, 4
  • an exact decimal, like 0, point, 75
  • a multiple of pi, like 12, space, start text, p, i, end text or 2, slash, 3, space, start text, p, i, end text

6) A is a 2, times, 3 matrix and B is a 3, times, 4 matrix.
What are the dimensions of A, B?
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3, slash, 5
  • a simplified improper fraction, like 7, slash, 4
  • a mixed number, like 1, space, 3, slash, 4
  • an exact decimal, like 0, point, 75
  • a multiple of pi, like 12, space, start text, p, i, end text or 2, slash, 3, space, start text, p, i, end text
times
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3, slash, 5
  • a simplified improper fraction, like 7, slash, 4
  • a mixed number, like 1, space, 3, slash, 4
  • an exact decimal, like 0, point, 75
  • a multiple of pi, like 12, space, start text, p, i, end text or 2, slash, 3, space, start text, p, i, end text

7) X is a 2, times, 1 matrix and Y is a 1, times, 2 matrix.
What are the dimensions of matrix X, Y?
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3, slash, 5
  • a simplified improper fraction, like 7, slash, 4
  • a mixed number, like 1, space, 3, slash, 4
  • an exact decimal, like 0, point, 75
  • a multiple of pi, like 12, space, start text, p, i, end text or 2, slash, 3, space, start text, p, i, end text
times
  • Your answer should be
  • an integer, like 6
  • a simplified proper fraction, like 3, slash, 5
  • a simplified improper fraction, like 7, slash, 4
  • a mixed number, like 1, space, 3, slash, 4
  • an exact decimal, like 0, point, 75
  • a multiple of pi, like 12, space, start text, p, i, end text or 2, slash, 3, space, start text, p, i, end text

Want to join the conversation?

  • blobby green style avatar for user ranibahuthai
    What is the product of AB in the top question on this page?
    (2 votes)
    Default Khan Academy avatar avatar for user
    • orange juice squid orange style avatar for user Tucker Quering
      Hello!

      The first thing to do will be to determine the dimensions of our product matrix (I'll call it C). Because matrix A has 3 rows, and matrix B has 2 columns, matrix C will be a 3x2 matrix. 3 rows, 2 columns.

      Now, the rules for matrix multiplication say that entry i,j of matrix C is the dot product of row i in matrix A and column j in matrix B. We can use this information to find every entry of matrix C. Here are the steps for each entry:

      Entry 1,1: (2,4) * (2,8) = 2*2 + 4*8 = 4 + 32 = 36
      Entry 2,1: (6,4) * (2,8) = 6*2 + 4*8 = 12 + 32 = 44
      Entry 3,1: (7,3) * (2,8) = 7*2 + 3*8 = 14 + 24 = 38
      Entry 1,2: (2,4) * (1,5) = 2*1 + 4*5 = 2 + 20 = 22
      Entry 2,2: (6,4) * (1,5) = 6*1 + 4*5 = 6 + 20 = 26
      Entry 3,2: (7,3) * (1,5) = 7*1 + 3*5 = 7 + 15 = 22

      Therefore, our final answer is:

        36     22
      44 26
      38 22


      I've left a link to a full tutorial on matrix multiplication at the bottom. Hope this helps!

      https://www.khanacademy.org/math/precalculus/precalc-matrices/multiplying-matrices-by-matrices/a/multiplying-matrices
      (18 votes)
  • male robot johnny style avatar for user Racher
    can i multiply more than 3 matrices?
    (4 votes)
    Default Khan Academy avatar avatar for user
    • leaf green style avatar for user kubleeka
      You could multiply as many matrices as you like, so long as the order of multiplication and the dimensions of the matrices are such that multiplication is always well-defined. The easiest way to make sure it's well-defined is to multiply a bunch of square matrices of equal dimensions.
      (8 votes)
  • blobby green style avatar for user Olivia  Nesbitt
    Why (like in questions 3 & 4) is AB defined but BA is not defined? Do matrices not conform to commutative properties of multiplication?
    (3 votes)
    Default Khan Academy avatar avatar for user
    • stelly blue style avatar for user Kim Seidel
      Correct... the commutative property of multiplication does not work with matrices. Go back and pay close attention to the section above titled: When is Matrix Multiplication Defined?". The last line states: "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". The 2 questions you are asking about do not meet this condition which is why the multiplication is not defined.

      Hope this helps.
      (6 votes)
  • blobby green style avatar for user Olly
    how can I learn the non-zero value in matrix
    (3 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user 19jbenoit
    What are the dimensions of a 2 by 3 matrix and a 3 by 2 matrix
    (1 vote)
    Default Khan Academy avatar avatar for user
    • starky ultimate style avatar for user Annika
      Assuming you mean you're multiplying them, the answer would be 2 x 2. You take the number of rows from the first matrix (2) to find the first dimension, and the number of columns from the second matrix (2) to find the second dimension.
      Another way to think of this:
      The dimensions of their product is the two outside dimensions. Every time I multiply matrixes on paper, I write the dimensions underneath the matrixes. You can also just do this step mentally. Then, just look at the outer dimensions, and those will be the new dimensions. This helps me remember how to do it.

      Hope this answered your question.
      (4 votes)
  • blobby green style avatar for user mary nakombe
    How can I find the inverse of a 3*3?
    (4 votes)
    Default Khan Academy avatar avatar for user
  • piceratops ultimate style avatar for user gtc1021
    how do you find out the dimensions for matrices that are not defined or is it not possible
    (2 votes)
    Default Khan Academy avatar avatar for user
  • blobby green style avatar for user Viacheslav  VOROBIEFF
    What is the point of ascertaining whether the resultant matrix from a specific ordered multiplication is DEFINED?
    (2 votes)
    Default Khan Academy avatar avatar for user
  • aqualine ultimate style avatar for user Jaracz
    i think i got it
    (0 votes)
    Default Khan Academy avatar avatar for user