Linear Algebra, Live
Strang §1.3 · Matrices

Ax is a combination of the columns of A.

Stack v and w side by side as the columns of a matrix A. Put the numbers c and d into a vector x. Then Ax is exactly cv + dw.

a₁₁a₁₂a₂₁a₂₂ x₁x₂ = x₁ a₁₁a₂₁ + x₂ a₁₂a₂₂

Think: a shopping basket

You buy eggs and rice. Each food gives you roughly this much protein and carbs:

1 egg = (6 g protein, 1 g carbs)    1 bowl of rice = (4 g protein, 45 g carbs)
A = 64145   x = (2 eggs, 1 bowl)

Each column of A is one food. The vector x says how many of each you take. Ax is the total in your basket.

Two ways to add it up

  • By columns (whole foods): 2 eggs + 1 bowl = 2·(6, 1) + 1·(4, 45) = (16, 47).
  • By rows (one nutrient at a time): protein 6·2 + 4·1 = 16. Carbs 1·2 + 45·1 = 47.

Same totals. The row way is how you calculate by hand: each entry is a dot product of a row with x. The column way is how you think: Ax is a mix of the columns.

Strang's advice: compute by rows if you like, but think by columns. The column view tells you what Ax can be.

Watch out

x needs one number per column. Two foods, two quantities. A 2 by 2 matrix needs a vector with 2 entries.

In the lab, the code computes Ax both ways. The plane draws the column way: x₁ times column 1, then x₂ times column 2 from its tip.

Worked examples

Example 1 · Both ways

A = 3125, x = (1, 2).

By columns: 1·(3, 2) + 2·(1, 5) = (5, 12)
By rows: (3·1 + 1·2, 2·1 + 5·2) = (5, 12)

Example 2 · A wide matrix

A = 102311 has 3 columns, so x needs 3 entries. Take x = (2, 1, 1).

Ax = 2·(1, 3) + 1·(0, 1) + 1·(2, 1) = (4, 8)

Three columns in, a vector with 2 entries out: one per row of A.

Problems

Try each one before you open the solution.

1

Compute Ax by columns for A = 1420 and x = (3, −1).

Show solutionHide solution

3·(1, 2) − 1·(4, 0) = (3 − 4, 6 − 0) = (−1, 6).

2

Which x makes Ax equal to column 2 of A? Which x gives column 1 + column 2?

Show solutionHide solution

x = (0, 1) picks out column 2. x = (1, 1) gives column 1 + column 2.

3

A is 3 by 2. How many entries must x have, and how many does Ax have?

Show solutionHide solution

x needs 2 entries, one per column. Ax has 3 entries, one per row.

Exercise Choose x so that Ax = (0, 3). Edit the code and press Run.
slide_2.py Loading Python…
1
Output · Ctrl+Enter runs
Press Run to execute this slide's code. Ctrl+Enter works too.
✎Lesson review
3 more worked examples and 5 mixed problems with solutions
→