Tutorials › Linear Algebra › Matrix Product Dimensions And Conformability

Matrix Operations and Algebra · Tutorial 61 of 1000

Matrix Product Dimensions And Conformability

Use inner dimensions to decide whether a matrix product is defined and outer dimensions to determine the size of its result.

Beginner 9 min read

What You'll Learn

  • Identify the row and column counts of a matrix from its dimensions.
  • Test whether two matrices are conformable for multiplication.
  • State the dimensions of a defined product without calculating its entries.
  • Distinguish when reversing the order of two matrices is dimensionally possible.
  • Track dimensions through a fixed left-associated product of several matrices.

Reading the Dimensions of a Product

Before calculating a matrix product, check whether the multiplication is permitted. The test is a comparison of dimensions: the number of columns in the first matrix must equal the number of rows in the second. When that condition holds, the product takes its row count from the first matrix and its column count from the second. These two checks—whether the product exists and what size it has—are called conformability and product-dimension checks.

Throughout, matrices have entries in a common field \(\mathbb{F}\), such as \(\mathbb{R}\) or \(\mathbb{C}\). If \(\mathbf{A}\) has \(m\) rows and \(n\) columns, write \(\mathbf{A}\in\mathbb{F}^{m\times n}\). The first number is always the row count, and the second is always the column count. Thus a matrix in \(\mathbb{F}^{m\times n}\) has \(m\) rows, each with \(n\) entries, and \(n\) columns, each with \(m\) entries.

Definition: For \(\mathbf{A}\in\mathbb{F}^{m\times n}\) and \(\mathbf{B}\in\mathbb{F}^{p\times q}\), the product \(\mathbf{A}\mathbf{B}\) is conformable or defined exactly when \(n=p\). If it is defined, its size is \(m\times q\), so \(\mathbf{A}\mathbf{B}\in\mathbb{F}^{m\times q}\). The matching dimensions \(n\) and \(p\) are called the inner dimensions; \(m\) and \(q\), which remain in the result, are the outer dimensions.

A compact way to keep track is to place the dimension labels beside the matrices:

$$ (m\times n)(n\times q)=m\times q. $$

The repeated \(n\) is the required match. It is not part of the result size; the two unpaired dimensions, \(m\) and \(q\), give the result size. If the inner dimensions differ, the product is not defined. In that case there is no resulting matrix whose dimensions can be reported.

Why the Dimension Test Works

Matrix multiplication is defined by the row-by-column rule: each position in the proposed product is formed from a row of the first matrix and a column of the second. A row of \(\mathbf{A}\in\mathbb{F}^{m\times n}\) has \(n\) entries. A column of \(\mathbf{B}\in\mathbb{F}^{p\times q}\) has \(p\) entries. The row and column can be paired entry by entry only if these lengths match. This explains why the inner dimensions must be equal. The product has one position for each choice of a row from \(\mathbf{A}\) and a column from \(\mathbf{B}\), giving \(m\) rows of positions and \(q\) columns of positions.

This reasoning establishes the dimension criterion without requiring any calculation of the entries. The next topic develops the entry formula; here, the goal is to determine whether a product is permitted and, if so, its shape.

Theorem (Matrix product dimension test): Let \(\mathbf{A}\in\mathbb{F}^{m\times n}\) and \(\mathbf{B}\in\mathbb{F}^{p\times q}\). The product \(\mathbf{A}\mathbf{B}\) is defined if and only if \(n=p\). When defined, it has exactly \(m\) rows and \(q\) columns.

Proof. By the definition of matrix multiplication, forming an entry of \(\mathbf{A}\mathbf{B}\) requires pairing a row of \(\mathbf{A}\) with a column of \(\mathbf{B}\). Each such row has \(n\) entries, while each such column has \(p\) entries. The row-by-column operation is defined exactly when the two lists have the same length, which is the condition \(n=p\). This proves both necessity and sufficiency. If the operation is defined, there is a product position for every choice of a row of \(\mathbf{A}\) and a column of \(\mathbf{B}\). There are \(m\) choices of the first kind and \(q\) choices of the second kind, so the product has \(m\) rows and \(q\) columns. \(\square\)

The phrase “if and only if” matters here. Matching inner dimensions guarantees that the product is defined, and a defined product requires matching inner dimensions. The result-size rule applies only after that condition has been met.

Worked Dimension Checks

Worked Example: A Defined Product

Let

$$ \mathbf{A}= \begin{bmatrix} 1&0&2\\ -1&3&4 \end{bmatrix}, \qquad \mathbf{B}= \begin{bmatrix} 2&1\\ 0&-2\\ 5&3 \end{bmatrix}. $$

Count the rows and columns separately. The matrix \(\mathbf{A}\) has \(2\) rows and \(3\) columns, so \(\mathbf{A}\in\mathbb{R}^{2\times3}\). The matrix \(\mathbf{B}\) has \(3\) rows and \(2\) columns, so \(\mathbf{B}\in\mathbb{R}^{3\times2}\). The proposed product has dimensions \((2\times3)(3\times2)\). The inner counts are \(3\) and \(3\), so they match and \(\mathbf{A}\mathbf{B}\) is defined. The outer counts are \(2\) and \(2\), so \(\mathbf{A}\mathbf{B}\in\mathbb{R}^{2\times2}\).

Check: each row of \(\mathbf{A}\) has \(3\) entries, matching the \(3\) entries in each column of \(\mathbf{B}\). There are \(2\) rows available from \(\mathbf{A}\) and \(2\) columns available from \(\mathbf{B}\), so the resulting array has \(2\) rows and \(2\) columns. This check confirms the dimension calculation; it does not calculate the product entries.

Worked Example: A Product That Is Not Defined

Suppose \(\mathbf{C}\in\mathbb{R}^{3\times2}\) and \(\mathbf{D}\in\mathbb{R}^{4\times5}\). Determine whether \(\mathbf{C}\mathbf{D}\) is defined.

Write down the proposed dimensions: \((3\times2)(4\times5)\). The first matrix has \(2\) columns, while the second has \(4\) rows. The inner dimensions are therefore \(2\) and \(4\), and \(2\ne4\). By the dimension test, \(\mathbf{C}\mathbf{D}\) is not defined.

There is no output size to report. In particular, it would be incorrect to describe the product as \(3\times5\): those are the outer dimensions, but they give a result size only when the inner dimensions match.

Check: a row of \(\mathbf{C}\) has \(2\) entries, but a column of \(\mathbf{D}\) has \(4\) entries. The row-by-column rule cannot pair these lists entry by entry, confirming that no product is defined.

Worked Example: Reversing the Order

Let \(\mathbf{E}\in\mathbb{R}^{2\times3}\) and \(\mathbf{F}\in\mathbb{R}^{3\times4}\). Check both orders.

For \(\mathbf{E}\mathbf{F}\), the dimensions are \((2\times3)(3\times4)\). The inner dimensions are \(3\) and \(3\), so the product is defined, and its outer dimensions give \(\mathbf{E}\mathbf{F}\in\mathbb{R}^{2\times4}\).

For the reversed order \(\mathbf{F}\mathbf{E}\), the dimensions are \((3\times4)(2\times3)\). The inner dimensions are \(4\) and \(2\), which do not match. Therefore \(\mathbf{F}\mathbf{E}\) is not defined.

Check: in the first order, a row of \(\mathbf{E}\) and a column of \(\mathbf{F}\) each have \(3\) entries, and the number of available rows and columns is \(2\) and \(4\). In the reversed order, a row of \(\mathbf{F}\) has \(4\) entries but a column of \(\mathbf{E}\) has \(2\). The two results of the dimension tests follow from these counts, not from the matrix entries.

Changing the order changes which dimensions must match. A product can be defined in one order and not the other, as in the example. The dimension test alone does not say that two defined products have the same entries or are equal; it answers only whether each proposed multiplication is permitted and what size its output would have.

Tracking Dimensions Through a Chain

For a sequence of matrices, apply the two-matrix test at each multiplication in the grouping that is written. For example, in \((\mathbf{A}\mathbf{B})\mathbf{C}\), first determine the size of \(\mathbf{A}\mathbf{B}\). Then use that size as the left factor’s dimensions when checking the multiplication by \(\mathbf{C}\). This is dimension bookkeeping for a specified grouping; it makes no claim about changing the grouping.

Theorem (Dimensions in a left-associated chain): Let \(\mathbf{A}_i\in\mathbb{F}^{m_i\times n_i}\) for \(i=1,\dots,k\), where \(k\ge2\). The left-associated product \(((\mathbf{A}_1\mathbf{A}_2)\mathbf{A}_3)\cdots\mathbf{A}_k\) is defined exactly when \(n_i=m_{i+1}\) for every \(i=1,\dots,k-1\). If defined, its size is \(m_1\times n_k\).

Proof. For \(k=2\), the result is the matrix product dimension test: the product is defined exactly when \(n_1=m_2\), and its size is \(m_1\times n_2\). Suppose the claim holds for a left-associated product of \(k-1\) matrices. That partial product is defined exactly when \(n_i=m_{i+1}\) for \(i=1,\dots,k-2\), and, when defined, has size \(m_1\times n_{k-1}\). Multiplying it by \(\mathbf{A}_k\in\mathbb{F}^{m_k\times n_k}\) is defined exactly when its column count \(n_{k-1}\) equals \(m_k\). This adds precisely the remaining condition. When it holds, the result has the partial product’s row count \(m_1\) and \(\mathbf{A}_k\)’s column count \(n_k\), hence size \(m_1\times n_k\). Induction proves the claim for every \(k\ge2\). \(\square\)

Worked Example: A Left-Associated Chain

Suppose \(\mathbf{P}\in\mathbb{R}^{3\times2}\), \(\mathbf{Q}\in\mathbb{R}^{2\times5}\), and \(\mathbf{R}\in\mathbb{R}^{5\times1}\). Determine whether \((\mathbf{P}\mathbf{Q})\mathbf{R}\) is defined and find its size.

First, \(\mathbf{P}\mathbf{Q}\) has proposed dimensions \((3\times2)(2\times5)\). The inner dimensions are \(2\) and \(2\), so it is defined, with size \(3\times5\).

Now use that size for the next multiplication: \((\mathbf{P}\mathbf{Q})\mathbf{R}\) has dimensions \((3\times5)(5\times1)\). The inner dimensions are \(5\) and \(5\), so this multiplication is also defined. The outer dimensions are \(3\) and \(1\), giving a final size of \(3\times1\).

Check: the adjacent dimension matches in the original chain are \(2=2\) and \(5=5\). The first matrix contributes the final row count \(3\), while the last matrix contributes the final column count \(1\). Thus the chain criterion gives \(3\times1\), agreeing with the step-by-step calculation.

Common Mistake: Matching the Wrong Dimensions

A frequent error is to compare the outer dimensions when deciding whether a product is defined. For instance, if \(\mathbf{X}\in\mathbb{R}^{2\times3}\) and \(\mathbf{Y}\in\mathbb{R}^{4\times2}\), someone might notice that the outer numbers are both \(2\) and conclude that \(\mathbf{X}\mathbf{Y}\) is defined with size \(2\times2\). That calculation is wrong: the dimensions are \((2\times3)(4\times2)\), so the inner numbers are \(3\) and \(4\), and \(3\ne4\). Therefore \(\mathbf{X}\mathbf{Y}\) is not defined.

The correction is to write the dimensions in order and identify the middle pair before naming a result size:

$$ (2\times3)(4\times2): \qquad 3\ne4 \quad\Longrightarrow\quad \mathbf{X}\mathbf{Y}\text{ is not defined}. $$

Only after the middle numbers match should the outside numbers be read as the product dimensions. Keeping these checks in order prevents the common mistake of assigning an output size to a product that does not exist.

Why Conformability Is Useful

Dimension checks are a quick way to catch an impossible operation before doing any arithmetic. They also help organize longer calculations: the dimensions of each intermediate result determine whether the next multiplication is available. When working with a system represented by matrices, for example, tracking dimensions helps distinguish a matrix from a vector and ensures that a proposed product has a meaningful shape. The check is necessary, but it does not guarantee a particular numerical value or any further algebraic property.

Use this sequence whenever a product is proposed:

  1. Read each matrix size as rows by columns.
  2. Compare the column count of the left matrix with the row count of the right matrix.
  3. If they differ, stop: the product is undefined.
  4. If they match, report the row count of the left matrix and the column count of the right matrix.
  5. For a chain, repeat the test using the size of each intermediate product.

Check Your Understanding

For each question, decide first whether the product is defined. Give a result size only when it is.

  1. If \(\mathbf{A}\in\mathbb{R}^{4\times3}\) and \(\mathbf{B}\in\mathbb{R}^{3\times2}\), is \(\mathbf{A}\mathbf{B}\) defined, and what is its size?
  2. If \(\mathbf{C}\in\mathbb{R}^{2\times5}\) and \(\mathbf{D}\in\mathbb{R}^{3\times4}\), explain why \(\mathbf{C}\mathbf{D}\) is or is not defined.
  3. Suppose \(\mathbf{E}\in\mathbb{R}^{1\times3}\) and \(\mathbf{F}\in\mathbb{R}^{3\times6}\). Find the dimensions of \(\mathbf{E}\mathbf{F}\).
  4. For \(\mathbf{G}\in\mathbb{R}^{2\times4}\) and \(\mathbf{H}\in\mathbb{R}^{4\times2}\), test \(\mathbf{G}\mathbf{H}\) and \(\mathbf{H}\mathbf{G}\) separately.
  5. If \(\mathbf{J}\in\mathbb{R}^{5\times2}\), \(\mathbf{K}\in\mathbb{R}^{2\times3}\), and \(\mathbf{L}\in\mathbb{R}^{3\times4}\), determine whether \((\mathbf{J}\mathbf{K})\mathbf{L}\) is defined and state its final size.

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon