Multiplying a matrix by a vector
A matrix sits next to a vector. What single vector does their product stand for, and what does it tell you about which right sides an equation can reach?
Where you are 9 in Matrices as linear transformations
When you reach for it
Three earlier lessons meet here. Linear combination scales vectors and adds them, and asks which weights build a given vector. Matrix multiplication gives each entry of a product as a row of the first factor times a column of the second. Writing a system as a matrix equation packs a system into one equation A\mathbf{x} = \mathbf{b}.
A matrix times a vector can be read row by row, as the multiplication rule computes it, or column by column, as a combination of the columns of A with the entries of \mathbf{x} as weights. The two readings always agree, and the column reading is the one that explains things: it is why A(\mathbf{u} + \mathbf{v}) = A\mathbf{u} + A\mathbf{v}, and why A\mathbf{x} = \mathbf{b} has a solution exactly when \mathbf{b} is built from the columns. Reach for it whenever fixed ingredients are mixed in chosen amounts.
The procedure
Two readings of one product
Let A be an m \times n matrix with columns \mathbf{a}_1, \dots, \mathbf{a}_n, each in \mathbb{R}^m, and let \mathbf{x} = (x_1, \dots, x_n) be a column vector in \mathbb{R}^n. Then
This is the column reading: entry j of \mathbf{x} is the weight on column j. It needs one weight per column, so \mathbf{x} must have n entries, and the result lives where the columns live, in \mathbb{R}^m.
The row reading is the multiplication rule with a one-column second factor: entry i of A\mathbf{x} is row i of A times \mathbf{x},
They agree because they add the same products. Entry i of column j is a_{ij}, so entry i of x_1\mathbf{a}_1 + \dots + x_n\mathbf{a}_n is x_1a_{i1} + \dots + x_na_{in}, which is the row sum term for term (multiplication of numbers is commutative). The row reading groups the products by row, the column reading by column.
The standard vector \mathbf{e}_j puts weight 1 on column j and 0 elsewhere, so
multiplying by \mathbf{e}_j picks out column j.
Linearity
For every \mathbf{u} and \mathbf{v} in \mathbb{R}^n and every scalar c,
Why. By the column reading, A(\mathbf{u} + \mathbf{v}) = (u_1 + v_1)\mathbf{a}_1 + \dots + (u_n + v_n)\mathbf{a}_n. Distribute each weight over its column, then reorder and regroup (the commutative and associative properties of vector addition) so the u terms come first:
Likewise A(c\mathbf{u}) = (cu_1)\mathbf{a}_1 + \dots + (cu_n)\mathbf{a}_n, which is c(u_1\mathbf{a}_1 + \dots + u_n\mathbf{a}_n) by merging products of scalars and distributing c. Together the rules say A carries any combination to the same combination of outputs,
and taking c = 0 gives A\mathbf{0} = \mathbf{0}.
Which right sides are reachable
As \mathbf{x} runs over \mathbb{R}^n, the column reading says A\mathbf{x} runs over every combination of the columns, which is their span. So:
A\mathbf{x} = \mathbf{b} is consistent exactly when \mathbf{b} is in \operatorname{span}\{\mathbf{a}_1, \dots, \mathbf{a}_n\}, and each solution is a list of weights that builds \mathbf{b} from the columns.
Row reduction of [\,A \mid \mathbf{b}\,] decides it: the system is inconsistent exactly when a row reduces to [\,0 \ \cdots \ 0 \mid d\,] with d \neq 0, and carrying a general \mathbf{b} through turns such rows into equations on \mathbf{b}. And A\mathbf{x} = \mathbf{b} is consistent for every \mathbf{b} in \mathbb{R}^m exactly when the columns span \mathbb{R}^m, which happens exactly when an echelon form of A has a pivot in every row, as Span shows.
Worked examples
Both readings, side by side
Compute A\mathbf{x} for
first row by row, then as a combination of columns.
SolutionA is 2 \times 3 and \mathbf{x} has 3 entries, one per column, so the product is defined and lies in \mathbb{R}^2.
Row by row. Row 1 times \mathbf{x} is 3(2) + (-2)(5) + 1(-1) = 6 - 10 - 1 = -5. Row 2 times \mathbf{x} is 1(2) + 0(5) + 4(-1) = 2 + 0 - 4 = -2.
By columns. The weights 2, 5, -1 go on the three columns:
Both give A\mathbf{x} = (-5, -2), from the same six products.
A product drawn in the plane
Let A = \begin{bmatrix} 3 & -1 \\ 1 & 2 \end{bmatrix}. Find A\mathbf{x} for \mathbf{x} = (2, 1) and read it on a picture, then find A\mathbf{e}_1 and A\mathbf{e}_2.
SolutionThe columns are \mathbf{a}_1 = (3, 1) and \mathbf{a}_2 = (-1, 2). By the column reading,
The row reading agrees: 3(2) - 1(1) = 5 and 1(2) + 2(1) = 4. In the figure the product is a walk along the columns.
The standard vectors put all the weight on one column, so A\mathbf{e}_1 = \mathbf{a}_1 = (3, 1) and A\mathbf{e}_2 = \mathbf{a}_2 = (-1, 2): one step along one column.
Fertilizer in the spreader
Delali, Elikem and Senyo feed their fields from three fertilizer blends. A sack of blend 1 carries (4, 1, 0) kilograms of (nitrogen, phosphorus, potassium), blend 2 carries (0, 3, 2) and blend 3 carries (1, 1, 5). Put the blends in the columns of
(a) Delali spreads \mathbf{x} = (2, 1.5, 1) sacks of the three blends. How much of each nutrient goes on her field? (b) Elikem spreads \mathbf{y} = (1, 2, 0) sacks on the same field. Find the total nutrients two ways. (c) Senyo spreads three times Delali’s recipe. Find his nutrients without a new product.
Solution(a) Sacks times kilograms per sack is kilograms, so blend j adds x_j times column j:
That is 9 kilograms of nitrogen, 7.5 of phosphorus and 8 of potassium. Row 1, (4, 0, 1), lists the nitrogen in a sack of each blend, so row 1 times \mathbf{x} counts the nitrogen.
(b) Elikem’s sacks carry D\mathbf{y} = 1(4, 1, 0) + 2(0, 3, 2) = (4, 7, 4). On one field the nutrients add: D\mathbf{x} + D\mathbf{y} = (13, 14.5, 12). The other way, the combined recipe is \mathbf{x} + \mathbf{y} = (3, 3.5, 1) sacks, and
The agreement is the first linearity rule, D(\mathbf{x} + \mathbf{y}) = D\mathbf{x} + D\mathbf{y}.
(c) By the second rule, D(3\mathbf{x}) = 3D\mathbf{x} = (27, 22.5, 24) kilograms.
A matrix recovered from two outputs
A 2 \times 2 matrix A satisfies A(1, 1) = (3, 5) and A(1, -1) = (1, -1). Find A(4, 2) and then A itself.
SolutionWrite the input as a combination of the known inputs, and linearity does the rest. Weights with c_1(1, 1) + c_2(1, -1) = (4, 2) satisfy c_1 + c_2 = 4 and c_1 - c_2 = 2, so c_1 = 3, c_2 = 1. Then
The columns of A are A\mathbf{e}_1 and A\mathbf{e}_2, so the same move finds them. Since \displaystyle \mathbf{e}_1 = \frac{1}{2}(1, 1) + \frac{1}{2}(1, -1) and \displaystyle \mathbf{e}_2 = \frac{1}{2}(1, 1) - \frac{1}{2}(1, -1),
So A = \begin{bmatrix} 2 & 1 \\ 2 & 3 \end{bmatrix}. Check: A(1, 1) = (3, 5), A(1, -1) = (1, -1), and A(4, 2) = (8 + 2, 8 + 6) = (10, 14).
Reachable and unreachable right sides
Let
Find the condition on \mathbf{b} = (b_1, b_2, b_3) for A\mathbf{x} = \mathbf{b} to be consistent, and decide the cases \mathbf{b} = (3, 7, 0) and \mathbf{b} = (1, 0, 1), solving the consistent one.
SolutionRow reduce [\,A \mid \mathbf{b}\,], carrying a general right side. Subtract 2 times row 1 from row 2, and add row 1 to row 3:
Subtracting 3 times row 2 from row 3 leaves [\,0 \ \ 0 \ \ 0 \mid 7b_1 - 3b_2 + b_3\,]. So the system is consistent exactly when
The columns span only this plane, not all of \mathbb{R}^3.
For (3, 7, 0): 21 - 21 + 0 = 0, so it is reachable. The reduced rows give x_2 - x_3 = 7 - 6 = 1 and x_1 + 2x_2 = 3; with x_3 = t free,
With t = 0, \mathbf{a}_1 + \mathbf{a}_2 = (1, 2, -1) + (2, 5, 1) = (3, 7, 0), as it should. For (1, 0, 1): 7 - 0 + 1 = 8 \neq 0, so no \mathbf{x} exists. The free weight comes from \mathbf{a}_3 = 2\mathbf{a}_1 - \mathbf{a}_2, which says A(2, -1, -1) = \mathbf{0}.
Every right side reachable
Show that A\mathbf{x} = \mathbf{b} is consistent for every \mathbf{b} in \mathbb{R}^2 when A = \begin{bmatrix} 1 & 2 & -1 \\ 3 & 6 & 1 \end{bmatrix}, and find one solution for \mathbf{b} = (1, 7).
SolutionSubtracting 3 times row 1 from row 2 gives the echelon form \begin{bmatrix} 1 & 2 & -1 \\ 0 & 0 & 4 \end{bmatrix}, with a pivot in each row. No row can become [\,0 \ \ 0 \ \ 0 \mid d\,] with d \neq 0, so the columns span \mathbb{R}^2 and every \mathbf{b} is reachable.
For \mathbf{b} = (1, 7) the reduced right side is 7 - 3 = 4, so x_3 = 1, and row 1 gives x_1 + 2x_2 = 1 + x_3 = 2. Taking x_2 = 0, \mathbf{x} = (2, 0, 1). Check by columns: 2(1, 3) + 1(-1, 1) = (1, 7). Other values of x_2 give other solutions.
Boundaries
- Sizes must match. A\mathbf{x} is defined only when \mathbf{x} has one entry per column of A. An m \times n matrix takes vectors in \mathbb{R}^n to vectors in \mathbb{R}^m, two different spaces when m \neq n.
- Linearity is for products, not products plus a constant. The rule \mathbf{x} \mapsto A\mathbf{x} + \mathbf{c} with \mathbf{c} \neq \mathbf{0} sends \mathbf{0} to \mathbf{c}, so it breaks both rules.
- Consistency is not uniqueness. \mathbf{b} in the span of the columns gives at least one solution; there is exactly one only when A\mathbf{x} = \mathbf{0} has no solution but \mathbf{0} (Examples 5 and 6 have many).
Where this goes next
Every matrix gives a Linear transformation, \mathbf{x} \mapsto A\mathbf{x}, and A\mathbf{e}_j = \mathbf{a}_j is how Finding the matrix of a transformation builds a matrix from a geometric move. All the A\mathbf{x} together form the image; the \mathbf{x} with A\mathbf{x} = \mathbf{0}, met in Example 5, form the kernel. Two solutions of A\mathbf{x} = \mathbf{b} differ by a solution of A\mathbf{x} = \mathbf{0}, the start of Homogeneous systems and solutions in parametric vector form. The pivot count that decides spanning is the rank, and one matrix applied after another is Composing transformations as a matrix product.
Exercises
Both readings
In Exercises 1 to 3, compute the product row by row, then check it as a combination of columns.
- \begin{bmatrix} 2 & 0 & -3 \\ 1 & 4 & 1 \end{bmatrix}\begin{bmatrix} 1 \\ -2 \\ 2 \end{bmatrix}
- \begin{bmatrix} 1 & -1 \\ 0 & 2 \\ 5 & 3 \end{bmatrix}\begin{bmatrix} 4 \\ -3 \end{bmatrix}
- \begin{bmatrix} 3 & 1 & 0 & -2 \\ -1 & 2 & 4 & 1 \end{bmatrix}\mathbf{x} with \mathbf{x} = (1, 0, -1, 2)
- Find \begin{bmatrix} 2 & 7 \\ -3 & 5 \end{bmatrix}\mathbf{e}_2 without multiplying, and say why.
- Write 3(1, -2) - (4, 0) + 2(0, 5) as A\mathbf{x} for a matrix A and vector \mathbf{x}, and compute it.
- Let A = \begin{bmatrix} 1 & 0 & 2 \\ 4 & -1 & 3 \end{bmatrix}. Decide whether A\mathbf{x} is defined for (a) \mathbf{x} = (2, 1) and (b) \mathbf{x} = (1, 1, 1), and compute it where it is.
Linearity
- Suppose A\mathbf{u} = (2, -1, 4) and A\mathbf{v} = (0, 3, -2). Find A(\mathbf{u} + \mathbf{v}), A(3\mathbf{u}) and A(\mathbf{u} - 2\mathbf{v}).
- A 2 \times 2 matrix A satisfies A(1, 2) = (5, 1) and A(0, 1) = (2, -1). Find A(1, 0) and then A.
- With the blends of Example 3, Senyo spreads 1 sack of blend 1, none of blend 2 and 2 sacks of blend 3. Find the nutrients he spreads, then the nutrients for a field needing three times as much, using linearity.
- With the same blends, Elikem wants exactly (5, 8, 9) kilograms of (nitrogen, phosphorus, potassium). How many sacks of each blend does he spread?
- A matrix A satisfies A(2, 1) = (4, 0, 6). Find A(-6, -3) without knowing A.
Reachable right sides
- Let A = \begin{bmatrix} 1 & -2 \\ -3 & 6 \end{bmatrix}. Decide whether A\mathbf{x} = \mathbf{b} is consistent for (a) \mathbf{b} = (3, -9) and (b) \mathbf{b} = (1, 1), and describe the span of the columns.
- Let A = \begin{bmatrix} 1 & 0 & 2 \\ 0 & 1 & -1 \\ 1 & 1 & 1 \end{bmatrix}. Find the condition on \mathbf{b} for A\mathbf{x} = \mathbf{b} to be consistent, decide the cases (2, 3, 5) and (1, 1, 1), and give a solution where one exists.
- Let A = \begin{bmatrix} 1 & 2 \\ 0 & 1 \\ 2 & 3 \end{bmatrix}. Find h so that A\mathbf{x} = (1, h, 4) is consistent, and give the solution.
- Let A = \begin{bmatrix} 1 & 1 & 0 \\ 0 & 1 & 1 \\ 1 & 0 & k \end{bmatrix}. For which k is A\mathbf{x} = \mathbf{b} consistent for every \mathbf{b} in \mathbb{R}^3?
- Let B = \begin{bmatrix} 1 & 2 & -1 \\ 2 & 3 & 1 \end{bmatrix}. Find every \mathbf{x} with B\mathbf{x} = \mathbf{0}. Then compute B(1, 1, 1) and use linearity to give two other vectors with the same product.
Reasoning
- Prove A(\mathbf{u} + \mathbf{v}) = A\mathbf{u} + A\mathbf{v} and A(c\mathbf{u}) = c\,A\mathbf{u} from the row reading instead of the column reading.
- Suppose A\mathbf{p} = \mathbf{b} and A\mathbf{q} = \mathbf{b}. Show that A(\mathbf{p} - \mathbf{q}) = \mathbf{0}. Conversely, show that if A\mathbf{z} = \mathbf{0} then \mathbf{p} + \mathbf{z} also solves A\mathbf{x} = \mathbf{b}.
- Prove that the set of \mathbf{b} for which A\mathbf{x} = \mathbf{b} is consistent contains \mathbf{0} and is closed under addition and under scaling.
- Give a counterexample to the claim “if A\mathbf{x} = A\mathbf{y}, then \mathbf{x} = \mathbf{y}.”
- Explain why, for a 3 \times 2 matrix A, the equation A\mathbf{x} = \mathbf{b} cannot be consistent for every \mathbf{b} in \mathbb{R}^3.
Answers
- (-4, -5). Rows: 2 + 0 - 6 = -4 and 1 - 8 + 2 = -5. Columns: (2, 1) - 2(0, 4) + 2(-3, 1) = (-4, -5).
- (7, -6, 11). Rows: 4 + 3, 0 - 6, 20 - 9. Columns: 4(1, 0, 5) - 3(-1, 2, 3) = (7, -6, 11).
- (-1, -3). Rows: 3 + 0 + 0 - 4 = -1 and -1 + 0 - 4 + 2 = -3. Columns: (3, -1) - (0, 4) + 2(-2, 1) = (-1, -3).
- (7, 5), column 2: \mathbf{e}_2 puts weight 1 on column 2 and 0 on column 1.
- A = \begin{bmatrix} 1 & 4 & 0 \\ -2 & 0 & 5 \end{bmatrix}, \mathbf{x} = (3, -1, 2): the vectors are the columns and the scalars the weights. A\mathbf{x} = (3 - 4 + 0, -6 + 0 + 10) = (-1, 4).
- (a) Not defined: A has 3 columns and \mathbf{x} has 2 entries. (b) (3, 6), from 1 + 0 + 2 and 4 - 1 + 3.
- A(\mathbf{u} + \mathbf{v}) = (2, 2, 2), A(3\mathbf{u}) = (6, -3, 12), A(\mathbf{u} - 2\mathbf{v}) = (2, -1, 4) - (0, 6, -4) = (2, -7, 8), all by linearity.
- (1, 0) = (1, 2) - 2(0, 1), so A(1, 0) = (5, 1) - 2(2, -1) = (1, 3). The columns are A\mathbf{e}_1 = (1, 3) and A\mathbf{e}_2 = (2, -1), so A = \begin{bmatrix} 1 & 2 \\ 3 & -1 \end{bmatrix}. Check: A(1, 2) = (1 + 4, 3 - 2) = (5, 1).
- D(1, 0, 2) = (4, 1, 0) + 2(1, 1, 5) = (6, 3, 10) kilograms. Tripled: D(3, 0, 6) = 3D(1, 0, 2) = (18, 9, 30) kilograms.
- 1 sack of blend 1, 2 of blend 2 and 1 of blend 3: (4, 1, 0) + 2(0, 3, 2) + (1, 1, 5) = (5, 8, 9). It is the only recipe: reducing D gives a pivot in every column.
- (-6, -3) = -3(2, 1), so A(-6, -3) = -3(4, 0, 6) = (-12, 0, -18).
- (a) Consistent: (3, -9) = 3(1, -3), so \mathbf{x} = (3, 0) is one solution. (b) Inconsistent. Column 2 is -2 times column 1, so the span of the columns is the line through \mathbf{0} along (1, -3), and (1, 1) is not a multiple of (1, -3).
- Consistent exactly when b_3 = b_1 + b_2: row 3 minus row 1 minus row 2 leaves [\,0 \ \ 0 \ \ 0 \mid b_3 - b_1 - b_2\,]. (2, 3, 5) is reachable, with \mathbf{x} = (2, 3, 0) for one; (1, 1, 1) is not, since 1 \neq 2.
- h = -2, with \mathbf{x} = (5, -2). Rows 1 and 3 give x_1 + 2x_2 = 1 and 2x_1 + 3x_2 = 4, so x_2 = -2, x_1 = 5, and row 2 forces h = x_2.
- Every k except -1. Row 3 minus row 1 is (0, -1, k), and adding row 2 gives (0, 0, k + 1): a pivot in every row exactly when k + 1 \neq 0.
- \mathbf{x} = t(-5, 3, 1) for any t: row 2 minus 2 times row 1 gives -x_2 + 3x_3 = 0, so x_2 = 3x_3 and x_1 = -2x_2 + x_3 = -5x_3. B(1, 1, 1) = (2, 6), and by linearity (-4, 4, 2) and (6, -2, 0) (t = 1 and t = -1) also give (2, 6).
- Entry i of A(\mathbf{u} + \mathbf{v}) is \sum_j a_{ij}(u_j + v_j) = \sum_j a_{ij}u_j + \sum_j a_{ij}v_j by the distributive property, which is entry i of A\mathbf{u} + A\mathbf{v}. Entry i of A(c\mathbf{u}) is \sum_j a_{ij}cu_j = c\sum_j a_{ij}u_j. Equal in every entry, so the vectors are equal.
- A(\mathbf{p} - \mathbf{q}) = A\mathbf{p} - A\mathbf{q} = \mathbf{b} - \mathbf{b} = \mathbf{0}, by linearity with weights 1, -1. And A(\mathbf{p} + \mathbf{z}) = A\mathbf{p} + A\mathbf{z} = \mathbf{b} + \mathbf{0} = \mathbf{b}.
- \mathbf{0} = A\mathbf{0}. If \mathbf{b} = A\mathbf{x} and \mathbf{b}' = A\mathbf{x}', then \mathbf{b} + \mathbf{b}' = A(\mathbf{x} + \mathbf{x}') and c\mathbf{b} = A(c\mathbf{x}), so both are reachable.
- A = \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}, \mathbf{x} = (1, 0), \mathbf{y} = (0, 1): A\mathbf{x} = A\mathbf{y} = (1, 1) but \mathbf{x} \neq \mathbf{y}.
- The reachable \mathbf{b} form the span of the two columns. An echelon form of A has at most one pivot per column, so at most two, and A has three rows; some row has no pivot, so the columns do not span \mathbb{R}^3 and some \mathbf{b} is unreachable.