Tutorials › Linear Algebra › Rows Of A Product As Linear Combinations

Matrix Operations and Algebra · Tutorial 65 of 1000

Rows Of A Product As Linear Combinations

Learn to express and check each row of a matrix product using the corresponding row of the first matrix as coefficients.

Beginner 9 min read

What You'll Learn

  • State the dimensions required for a product and its row formula.
  • Match the coefficients in a product row to entries of the corresponding row of the first matrix.
  • Compute product rows as linear combinations of rows of the second matrix.
  • Verify row-combination calculations against the entry formula.
  • Explain why every row of a product belongs to the row space of the second matrix.
  • Identify and correct a common error in assigning row-combination coefficients.

The Rows of a Product

Matrix multiplication can be read in two complementary ways: a column of a product is built from columns of the first factor, while a row of a product is built from rows of the second factor. Here we focus on the row description. It gives a direct way to understand what the entries in a row of a product mean, and it provides a useful check when computing a product by hand.

Let \(\mathbf{A}\in\mathbb{R}^{m\times n}\) and \(\mathbf{B}\in\mathbb{R}^{n\times p}\). The product \(\mathbf{A}\mathbf{B}\) is defined because the number of columns of \(\mathbf{A}\) equals the number of rows of \(\mathbf{B}\). The product has \(m\) rows and \(p\) columns. For a matrix \(\mathbf{M}\), write \(\operatorname{row}_i(\mathbf{M})\) for its \(i\)-th row, viewed as a row vector. Thus \(\operatorname{row}_i(\mathbf{A})=(a_{i1},\dots,a_{in})\), and \(\operatorname{row}_k(\mathbf{B})\) has \(p\) entries.

Theorem (Row formula for a product): If \(\mathbf{A}\in\mathbb{R}^{m\times n}\) and \(\mathbf{B}\in\mathbb{R}^{n\times p}\), then for each \(i=1,\dots,m\), $$ \operatorname{row}_i(\mathbf{A}\mathbf{B}) =\sum_{k=1}^{n}a_{ik}\operatorname{row}_k(\mathbf{B}). $$ The coefficients are the entries of the \(i\)-th row of \(\mathbf{A}\), in order. The right-hand side combines the \(n\) rows of \(\mathbf{B}\), so it has \(p\) entries, as required for a row of \(\mathbf{A}\mathbf{B}\).

Proof. Fix a row index \(i\) with \(1\le i\le m\). By the entry formula for matrix multiplication, the entry in row \(i\), column \(j\) of \(\mathbf{A}\mathbf{B}\) is \(\sum_{k=1}^{n}a_{ik}b_{kj}\), for each \(j=1,\dots,p\). The entry in column \(j\) of \(\sum_{k=1}^{n}a_{ik}\operatorname{row}_k(\mathbf{B})\) is also \(\sum_{k=1}^{n}a_{ik}b_{kj}\), because the \(j\)-th entry of row \(k\) of \(\mathbf{B}\) is \(b_{kj}\). Therefore the two row vectors have equal entries in every column \(j=1,\dots,p\). They are equal. Since \(i\) was arbitrary, the formula holds for every row of the product. \(\square\)

The indices are worth tracking carefully. The fixed index \(i\) chooses which product row we are finding, so the coefficients \(a_{i1},\dots,a_{in}\) all come from row \(i\) of \(\mathbf{A}\). The index \(k\) runs through the rows of \(\mathbf{B}\). Each coefficient \(a_{ik}\) multiplies row \(k\) of \(\mathbf{B}\). The column index \(j\) is used when checking a particular entry; it does not choose a row to combine.

Using the Formula in a Product

Worked Example: A Product with Two Rows and Three Rows

Compute the product and express each of its rows as a combination of rows of \(\mathbf{B}\), where

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

Let the rows of \(\mathbf{B}\) be \(\mathbf{b}_1=(1,2)\), \(\mathbf{b}_2=(-2,1)\), and \(\mathbf{b}_3=(3,0)\). The first row of \(\mathbf{A}\) is \((2,-1,3)\). By the row formula, row 1 of the product is \(2\mathbf{b}_1-\mathbf{b}_2+3\mathbf{b}_3\). Compute it term by term:

$$ 2(1,2)-(-2,1)+3(3,0) =(2,4)-(-2,1)+(9,0) =(2+2+9,\;4-1+0) =(13,3). $$

The second row of \(\mathbf{A}\) is \((0,4,1)\), so row 2 of the product is \(0\mathbf{b}_1+4\mathbf{b}_2+\mathbf{b}_3\):

$$ 0(1,2)+4(-2,1)+(3,0) =(0,0)+(-8,4)+(3,0) =(-5,4). $$

Thus the product is \(\begin{bmatrix}13&3\\-5&4\end{bmatrix}\). Check the entries directly using the entry formula. Its first row is \((2\cdot1+(-1)(-2)+3\cdot3,\;2\cdot2+(-1)\cdot1+3\cdot0)=(13,3)\). Its second row is \((0\cdot1+4(-2)+1\cdot3,\;0\cdot2+4\cdot1+1\cdot0)=(-5,4)\), agreeing with both row combinations.

A coefficient of zero means that the corresponding row of \(\mathbf{B}\) contributes nothing to that particular product row. A negative coefficient means that a scalar multiple in the opposite direction is used. Neither situation changes the rule: the \(k\)-th coefficient in row \(i\) of \(\mathbf{A}\) always multiplies row \(k\) of \(\mathbf{B}\).

Worked Example: A Product with Three Rows

Compute \(\mathbf{A}\mathbf{B}\) and verify each row-combination description, with

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

Write the rows of \(\mathbf{B}\) as \(\mathbf{b}_1=(2,1,-1)\) and \(\mathbf{b}_2=(0,4,2)\). The first row of \(\mathbf{A}\) is \((1,2)\), giving \(\mathbf{b}_1+2\mathbf{b}_2\):

$$ (2,1,-1)+2(0,4,2) =(2,1,-1)+(0,8,4) =(2,9,3). $$

The second row is \((-1,0)\), giving \(-\mathbf{b}_1+0\mathbf{b}_2=(-2,-1,1)\). The third row is \((3,-2)\), giving \(3\mathbf{b}_1-2\mathbf{b}_2\):

$$ 3(2,1,-1)-2(0,4,2) =(6,3,-3)-(0,8,4) =(6,-5,-7). $$

Therefore the product is \(\begin{bmatrix}2&9&3\\-2&-1&1\\6&-5&-7\end{bmatrix}\). To check it by entries, the first row is \((1\cdot2+2\cdot0,\;1\cdot1+2\cdot4,\;1(-1)+2\cdot2)=(2,9,3)\). The second is \((-1\cdot2+0\cdot0,\;(-1)\cdot1+0\cdot4,\;(-1)(-1)+0\cdot2)=(-2,-1,1)\). The third is \((3\cdot2+(-2)\cdot0,\;3\cdot1+(-2)\cdot4,\;3(-1)+(-2)\cdot2)=(6,-5,-7)\).

Rows Can Combine to Give a Zero Row

A product row need not be nonzero just because some of its coefficients are nonzero. Different rows of \(\mathbf{B}\) may combine so that their contributions cancel. The row formula accounts for this automatically: the result depends on the entire indicated combination, not on any one coefficient or row in isolation.

Worked Example: Cancellation Between Rows

Find the product and explain why its first row is zero, using

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

Call the rows of \(\mathbf{B}\) \(\mathbf{b}_1=(1,2)\), \(\mathbf{b}_2=(3,1)\), and \(\mathbf{b}_3=(4,3)\). The first row of \(\mathbf{A}\) gives \(\mathbf{b}_1+\mathbf{b}_2-\mathbf{b}_3\). Evaluating in order,

$$ (1,2)+(3,1)-(4,3) =(4,3)-(4,3) =(0,0). $$

The second row of \(\mathbf{A}\) gives \(2\mathbf{b}_1-\mathbf{b}_2+0\mathbf{b}_3\):

$$ 2(1,2)-(3,1)+0(4,3) =(2,4)-(3,1)+(0,0) =(-1,3). $$

So \(\mathbf{A}\mathbf{B}=\begin{bmatrix}0&0\\-1&3\end{bmatrix}\). Directly checking the entries gives the first row \((1\cdot1+1\cdot3+(-1)\cdot4,\;1\cdot2+1\cdot1+(-1)\cdot3)=(0,0)\), and the second row \((2\cdot1+(-1)\cdot3+0\cdot4,\;2\cdot2+(-1)\cdot1+0\cdot3)=(-1,3)\). The row combination and entry calculation agree.

A Consequence for Row Spaces

The row space \(\operatorname{Row}\mathbf{B}\) is the set of all linear combinations of the rows of \(\mathbf{B}\). The row formula immediately locates every row of a product within this set. In fact, combinations of the product rows also remain in the row space of \(\mathbf{B}\).

Corollary: If \(\mathbf{A}\in\mathbb{R}^{m\times n}\) and \(\mathbf{B}\in\mathbb{R}^{n\times p}\), then \(\operatorname{Row}(\mathbf{A}\mathbf{B})\subseteq\operatorname{Row}\mathbf{B}\).

Proof. By the row formula, for each \(i=1,\dots,m\), row \(i\) of \(\mathbf{A}\mathbf{B}\) is a linear combination of the rows of \(\mathbf{B}\). Hence each row of \(\mathbf{A}\mathbf{B}\) belongs to \(\operatorname{Row}\mathbf{B}\). An arbitrary element of \(\operatorname{Row}(\mathbf{A}\mathbf{B})\) is a linear combination of the rows of \(\mathbf{A}\mathbf{B}\). Each of those rows is itself a linear combination of rows of \(\mathbf{B}\); substituting these combinations and collecting the real coefficients expresses the arbitrary element as a linear combination of rows of \(\mathbf{B}\). Therefore it belongs to \(\operatorname{Row}\mathbf{B}\), proving the inclusion. \(\square\)

This conclusion is an inclusion, not necessarily an equality: the combinations selected by the rows of \(\mathbf{A}\) might not produce every possible linear combination of rows of \(\mathbf{B}\). The row formula tells us exactly how the rows of the product are built, while the corollary records one consequence for the sets of combinations those rows can generate.

A Reliable Calculation Routine

For a product \(\mathbf{A}\mathbf{B}\), the row-combination method can be organized as follows. First check the dimensions: if \(\mathbf{A}\) has \(n\) columns, \(\mathbf{B}\) must have \(n\) rows. Then treat one row of \(\mathbf{A}\) at a time. Its entries, in order, are the coefficients for rows \(1,\dots,n\) of \(\mathbf{B}\). Calculate the resulting row one coordinate at a time, keeping the same coefficient attached to the same row of \(\mathbf{B}\) in every coordinate. Finally, compare each result with the entry formula for the corresponding row.

1
Choose a product row.
Fix a row index \(i\) of \(\mathbf{A}\). The same index specifies row \(i\) of \(\mathbf{A}\mathbf{B}\).
2
Read the coefficients.
Use \(a_{i1},\dots,a_{in}\), in order, as the coefficients of rows \(1,\dots,n\) of \(\mathbf{B}\).
3
Combine and check.
Compute \(\sum_{k=1}^{n}a_{ik}\operatorname{row}_k(\mathbf{B})\), then check its entries using \((\mathbf{A}\mathbf{B})_{ij}=\sum_{k=1}^{n}a_{ik}b_{kj}\) for \(j=1,\dots,p\).

Common Mistake: Using the Wrong Coefficients

A common error is to use the entries of column \(i\) of \(\mathbf{A}\), rather than the entries of row \(i\), when finding row \(i\) of the product. For the first example, row 1 of \(\mathbf{A}\) is \((2,-1,3)\), so the correct first product row is \(2\mathbf{b}_1-\mathbf{b}_2+3\mathbf{b}_3=(13,3)\). A wrong calculation might use \((2,0)\), the first column of \(\mathbf{A}\), as if those were the coefficients, and write \(2\mathbf{b}_1+0\mathbf{b}_2\). That gives \((2,4)\), not \((13,3)\). The correction is to identify the row being computed first, then take all coefficients from that row of \(\mathbf{A}\). A direct entry check catches the error: the first entry must be \(2\cdot1+(-1)(-2)+3\cdot3=13\), not \(2\).

Another useful check is the output length. Each row of \(\mathbf{B}\) has \(p\) entries, so every linear combination of those rows has \(p\) entries. The product \(\mathbf{A}\mathbf{B}\) also has \(p\) columns. If a proposed product row has a different number of entries, the dimensions or the calculation have been mishandled.

Check Your Understanding

For each question, keep track of the dimensions and verify computed product rows using the entry formula.

  1. If \(\mathbf{A}\in\mathbb{R}^{2\times3}\) and \(\mathbf{B}\in\mathbb{R}^{3\times4}\), how many entries does each row of \(\mathbf{A}\mathbf{B}\) have?
  2. Suppose row 2 of \(\mathbf{A}\) is \((3,0,-2)\). Write row 2 of \(\mathbf{A}\mathbf{B}\) as a combination of the rows of \(\mathbf{B}\).
  3. Let the rows of \(\mathbf{B}\) be \((1,0)\), \((0,1)\), and \((1,1)\). What combination does the coefficient row \((1,1,-1)\) produce?
  4. Explain why every row of \(\mathbf{A}\mathbf{B}\) belongs to \(\operatorname{Row}\mathbf{B}\).
  5. For \(\mathbf{A}=\begin{bmatrix}2&-1\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}1&3\\4&2\end{bmatrix}\), compute the product row by a row combination and check both entries directly.

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