Linear Algebra, Live
Strang §1.1 · Linear combinations

Linear combinations: stretch vectors, then add them

A vector is a step with a length and a direction, like “2 steps east, 1 step north”. You can do two things with steps. You can stretch one: take it 3 times, half a time, or backwards. And you can add two: walk one step, then the other from where you stopped. Stretch, then add, and you get a linear combination. The whole course grows from one question: which places can you reach this way?

Lesson 1 · slide 1Linear combinations
c 21 + d -11 = 2c − dc + d
Key ideas
  1. A vector in the plane is a pair of numbers, v = v₁v₂: v₁ is the first number, v₂ the second. We draw it as an arrow from the origin.
  2. Two operations: multiply a vector by a number c, and add two vectors. Both work one part (component) at a time.
  3. Doing both gives a linear combination cv + dw.
  4. The big question: which vectors can we reach with all possible c and d?

This course follows Professor Gilbert Strang's book Introduction to Linear Algebra. The label above each slide, like §1.1, names the matching section of his book.

Why vectors at all?

A sensor reports two numbers: 2 metres east and 1 metre north. They belong together, so we keep them as one pair: v = 21. That pair is a vector.

A vector is a column of numbers: 2 on top, 1 below, and that is how this site prints it. In a sentence or in the lab code it is often written across, as (2, 1) or [2, 1], to save space. The column, (2, 1) and [2, 1]: all three are the same vector.

To add two vectors, add first parts to first parts and second parts to second parts. They never mix:

v = 21,   w = −11  →  v + w = (2 + (−1), 1 + 1) = 12

On the plane, adding means walking: go along v, then along w from its tip. You end at the tip of v + w.

Go along v, then along w from its tip. You land on v + w.

Multiplying by a number

To get 3v, multiply each part by 3: 3v = 63. Same direction, three times as long. The 3 is called a scalar, because it only scales.

A negative number turns the arrow around: −v = −2−1. And 0·v is the zero vector 00.

As c changes, cv slides along one line through the origin. Negative c points it the other way.

Putting both together

Pick numbers c and d and form cv + dw. With c = 3 and d = 2:

3v + 2w = 63 + −22 = 45

That is a linear combination: "take 3 steps of v, then 2 steps of w".

3 steps of v, then 2 steps of w, lands on 45.

The question behind everything

We ask this all course long: which vectors can we reach?

The multiples cv of one vector fill a line through the origin. That is where "linear" comes from. Two vectors that point different ways, like v and w, fill the whole plane.

Each dot is one combination cv + dw. Try many c and d, and the dots spread over the whole plane.

The reverse is harder. Given a target like 45, what are c and d? Write the combination out:

c(2, 1) + d(−1, 1) = 2c − dc + d

We need 2c − d = 4 and c + d = 5 at the same time. For two numbers, the school method works: c + d = 5 gives d = 5 − c. Put that into the first equation: 2c − (5 − c) = 4, so 3c = 9, c = 3 and d = 2. The examples below do the same. Lesson 2 gives a method that works for any number of unknowns.

A bigger example: 3 numbers

The pictures use 2 numbers because paper is flat. Real vectors often have more. A drone flies in 3D, so each of its moves has 3 numbers: (east, north, up).

v = 101,   w = 021
3v + 2w = 303 + 042 = 345

The rules don't change: stretch every part, then add part by part. With 4 numbers, 100 numbers, or a million (the pixels of a photo), it works the same way.

The lab

Under every slide is the lab: Python code you can edit and run, and the picture it draws. Here, change c and d, run, and see where cv + dw lands.

Next: how long is a vector, and when do two vectors meet at a right angle? One small calculation, the dot product, answers both.

Examples

Example 1 · Compute a combination

v = 11, w = 1−1, c = 2, d = 3. Find cv + dw.

Show solutionHide solution
2v = 22    3w = 3−3
2v + 3w = 2 + 32 − 3 = 5−1

Example 2 · Find the numbers

Write 30 as c·11 + d·1−1.

Show solutionHide solution
c + d = 3    c − d = 0
Adding: 2c = 3, so c = 1.5 and d = 1.5
Check: 1.5·11 + 1.5·1−1 = 30 ✓

Example 3 · When the plane is not filled

Take v = 12 and w = 24. Notice that w = 2v: both arrows lie on the same line.

Show solutionHide solution
cv + dw = c(1, 2) + 2d(1, 2) = (c + 2d)·12

Every combination is a multiple of 12, so the combinations only fill a line, not the plane. The target 10 can never be reached.

Example 4

Find c and d with c·12 + d·01 = 38.

Show solutionHide solution

The first component gives c = 3. The second: 2·3 + d = 8, so d = 2.

Example 5

Can combinations of 24 and −1−2 ever reach 10?

Show solutionHide solution

No. −1−2 = −½·24, so both vectors lie on the line y = 2x. Every combination stays on that line, and 10 is not on it.

Exercise Find c and d so that cv + dw lands exactly on the new target (1, 5). Edit the code and press Run.
slide_1.py Loading Python…
1
Output · Ctrl+Enter runs
Press Run to execute this slide's code. Ctrl+Enter works too.

Enjoying lesson 1? Get the full course: all 8 lessons through the SVD and PCA, your progress saved lesson by lesson, every solution and 5 extra problems per lesson. $20 once, yours for life.

Questions and comments

Stuck on something, or found a mistake? Ask here and I'll answer. You sign in with GitHub.

The full course

From Ax = b to PCA, by running it

Lessons 1 to 3 are free. Finish all eight and you will be able to:

You get: all 8 lessons with Python labs · every worked example and solution · 5 extra problems per lesson · your progress tracked · answers to your questions · every future update.

$20 once · lifetime access
Continue to checkout →

Already a member? Log in to the course