Monocurl Essays
Series Download

What is a vector? Arrows, lists of numbers, and adding them

A vector is a list of numbers read as a movement. Adding entry by entry matches placing arrows tip to tail, and two non-parallel arrows reach the whole plane.

22 min·High school and early college·

AssumesThe Pythagorean theorem: a proof you can seeSolving two equations at once: where lines meet

One hour of flight seen from above. The plane points due east and flies at 240 km/h (blue) while the wind carries it north at 100 km/h (orange). The grey ring is where it would be in still air; the green line is the path it really follows.
Monocurl source
let pl = Board([-2.95, -1.35, 0], 0.9, 0, 7, 0, 3)
let KM = |x, y| P(pl, [x / 40, y / 40])
let Craft = |p| Region([[p[0] + 0.24, p[1], 0], [p[0] - 0.14, p[1] + 0.14, 0], [p[0] - 0.14, p[1] - 0.14, 0]], INK)
let Flight = |t| {
    let own = KM(240 * t, 0)
    let real = KM(240 * t, 100 * t)
    var out = []
    if (t > 0.13) {
        out .= Seg(KM(0, 0), real, LEAF, 4)
        out .= Tip(KM(0, 0), own, AZURE, 4.5, 0.2)
        out .= Tip(own, real, EMBER, 4.5, 0.2)
    }
    out .= Ring(own, SLATE, 0.1, 2.5)
    out .= Craft(real)
    out .= center{[2.75, 1.78, 0]} scale{1.15} color{LEAF} Number(260 * t, 0)
    return out
}
mesh map = [
    Ground(pl, 1, 40),
    center{[2.75, -1.98, 0]} Note("km east", 0.72),
    center{[-2.35, 1.6, 0]} Note("km north", 0.72),
    center{[0.85, 1.78, 0]} Note("km from the start", 0.74)
]
mesh flight = Flight(t: 0)
mesh notes = []

slide "fly"
    play Wait(0.6)
    flight.t = 1
    play Lerp(4, [&flight], linear)
    notes = [
        center{KM(132, 14)} Cap("flying", 0.74, AZURE),
        center{[P(pl, [6, 0])[0] + 0.5, KM(0, 50)[1], 0]} Cap("wind", 0.74, EMBER)
    ]
    play Fade(0.5, [&notes])
    play Wait(1.6)

Uses the shared definitions for this lesson's figures.

A pilot points her plane due east and flies at 240 km/h. A steady wind blows toward the north at 100 km/h. One hour later, how far is the plane from where it took off?

The answer 240 km ignores the wind. The answer 340 km adds the two speeds, and that is wrong as well, because the two motions do not point the same way. The true distance lies between them, and to find it we need a kind of quantity that remembers its direction along with its size, together with a rule for adding two of them. That quantity is a vector. This lesson builds vectors from the pilot’s problem, then states precisely what they are and proves the facts about them that the rest of linear algebra stands on.

Pause and try

Before reading on, work out where the plane is after one hour, measured as kilometers east and kilometers north of the start, and then its straight-line distance from the start. You will need the Pythagorean theorem: in a right triangle with legs $a$ and $b$ and hypotenuse $c$, $a^2 + b^2 = c^2$.

Show answerHide answer

The plane’s own flying moves it 240 km east. During the same hour the air it flies in has moved 100 km north and carried the plane with it. So the plane is 240 km east and 100 km north of the start. Those two displacements are the legs of a right triangle, and the distance is $\sqrt{240^2 + 100^2} = \sqrt{57600 + 10000} = \sqrt{67600} = 260$ km.

Two motions, one after the other

Look at how that answer was reached. The two motions happened at the same time, yet we found the result by pretending they happened in turn: first fly 240 km east in still air, then let the wind push the plane 100 km north. The final position is the same either way, because each motion changes the position by a fixed amount no matter where the plane happens to be.

Draw each motion as an arrow whose length and direction are those of the displacement. Then “one after the other” has a picture: start the second arrow where the first one ends. This is called placing the arrows tip to tail, and the arrow from the very start to the very end is the combined motion.

The pilot’s arrows are perpendicular, which hides part of the story, so here are two arrows that are not. Call them $\mathbf{u}$ and $\mathbf{v}$: $\mathbf{u}$ moves 3 to the right and 1 up, and $\mathbf{v}$ moves 1 to the right and 2 up.

Pause and try

Start at the corner of a sheet of grid paper. Follow $\mathbf{u}$ and then $\mathbf{v}$: where are you? Now start again and follow $\mathbf{v}$ first, then $\mathbf{u}$. Do you expect to arrive at the same place, and what shape do the four arrows make?

Show answerHide answer

Following $\mathbf{u}$ puts you 3 right and 1 up; then $\mathbf{v}$ adds 1 right and 2 up, for a total of 4 right and 3 up. In the other order you are first at 1 right and 2 up, and then $\mathbf{u}$ adds 3 right and 1 up: again 4 right and 3 up. The four arrows form a parallelogram, and both routes end at the corner opposite the start.

The arrows $\mathbf{u} = (3, 1)$ and $\mathbf{v} = (1, 2)$ placed tip to tail in both orders. Either route ends at the point $(4, 3)$, and the two routes together outline a parallelogram.
Monocurl source
let pl = Board([-3.0, -1.6, 0], 0.85, 0, 6, 0, 4)
let part = |s, k| clamp(0, s - k, 1)
let Walk = |s| {
    let a = part(s, 0)
    let b = part(s, 1)
    let c = part(s, 2)
    let d = part(s, 3)
    var out = []
    var here = times(a, u)
    if (c > 0.03) {
        out .= Vec(pl, [0, 0], times(c, v), EMBER, 3.5)
        here = times(c, v)
    }
    if (d > 0.03) {
        out .= Vec(pl, v, add(v, times(d, u)), AZURE, 3.5)
        here = add(v, times(d, u))
    }
    if (a > 0.03) {
        out .= Vec(pl, [0, 0], times(a, u), AZURE)
    }
    if (b > 0.03) {
        out .= Vec(pl, u, add(u, times(b, v)), EMBER)
        if (c <= 0.03) {
            here = add(u, times(b, v))
        }
    }
    out .= Pt(P(pl, here), INK, 0.09)
    return out
}
mesh ground = Ground(pl)
mesh names = [
    center{[2.9, 1.25, 0]} Math("\mathbf{u} = (3, 1)", 0.95, AZURE),
    center{[2.9, 0.65, 0]} Math("\mathbf{v} = (1, 2)", 0.95, EMBER)
]
mesh walk = Walk(s: 0)
mesh total = []

slide "walk"
    play Wait(0.5)
    walk.s = 2
    play Lerp(2.6, [&walk], linear)
    play Wait(0.7)
    walk.s = 4
    play Lerp(2.6, [&walk], linear)
    total = [
        Vec(pl, [0, 0], [4, 3], LEAF, 4.5),
        center{[2.9, -0.25, 0]} Math("\mathbf{u} + \mathbf{v}", 0.95, LEAF),
        center{[2.9, -0.8, 0]} Math("= (4, 3)", 0.95, LEAF)
    ]
    play Fade(0.6, [&total])
    play Wait(1.8)

Uses the shared definitions for this lesson's figures.

An arrow is a list of instructions

Notice how I described $\mathbf{u}$: “3 to the right and 1 up”. That is a pair of numbers, and nothing else was needed. I never said where the arrow starts. The pilot’s wind is the same wind over the airport and over the next town; a displacement of “3 right, 1 up” is the same instruction wherever you carry it out.

Five arrows, all of them the vector (2, 1): each goes 2 to the right and 1 up. The one that starts at the origin ends at the point with coordinates (2, 1).
Five arrows, all of them the vector $(2, 1)$: each goes 2 to the right and 1 up. The one that starts at the origin ends at the point with coordinates $(2, 1)$.
Monocurl source
let pl = Board([-0.22, -0.21, 0], 0.72, -4, 5, -2, 3)
let w = [2, 1]
let starts = [[-4, 1], [-3, -2], [1, 1.6], [2, -1.5], [-1, 2]]
mesh ground = Ground(pl)
mesh legs = [
    Dash(P(pl, [2, -1.5]), P(pl, [4, -1.5]), SLATE),
    Dash(P(pl, [4, -1.5]), P(pl, [4, -0.5]), SLATE),
    center{P(pl, [3, -1.78])} Math("2", 0.8, SLATE),
    center{P(pl, [4.3, -1])} Math("1", 0.8, SLATE)
]
mesh copies = map(starts, |s| Vec(pl, s, [s[0] + 2, s[1] + 1], tint(AZURE, 0.6), 4))
mesh main = [
    Vec(pl, [0, 0], w, AZURE, 5),
    Pt(P(pl, w), AZURE, 0.085),
    center{P(pl, [2.75, 0.62])} Math("(2, 1)", 0.9, AZURE)
]

Uses the shared definitions for this lesson's figures.

So a vector in the plane is fully described by two numbers, its horizontal and vertical displacement. We write them in a column,

$$ \mathbf{u} = \begin{pmatrix} 3 \\ 1 \end{pmatrix}, \qquad \mathbf{v} = \begin{pmatrix} 1 \\ 2 \end{pmatrix}, $$

or in a row as $(3, 1)$ when space is short. The numbers are called the components of the vector. When the arrow is drawn starting at the origin, its tip sits at the point whose coordinates are the components, and this is how a vector can also stand for a position: the position you reach by following it from the origin.

Nothing forces the list to stop at two numbers. A displacement of a drone needs three (east, north, up), and the state of a system with a hundred measurements needs a hundred. Here is the general definition.

The symbol $\mathbb{R}$ stands for the real numbers, and $\mathbb{R}^2$ is the plane. Addition in the definition is done one component at a time, with no mention of arrows. We now have two candidates for “the sum of two vectors”, the geometric one from the last section and this arithmetic one, and we have to check that they are the same thing.

Why adding components matches tip to tail

Go back to $\mathbf{u} = (3, 1)$ and $\mathbf{v} = (1, 2)$, and break each arrow into its horizontal and vertical legs.

  1. The arrow u is 3 to the right and 1 up.
  2. Start v at the tip of u. It adds 1 to the right and 2 up.
  3. Slide the legs to the edges. In total: 3 + 1 to the right and 1 + 2 up.
  4. So the arrow from the start to the end is (3 + 1, 1 + 2) = (4, 3).
Each arrow is replaced by a horizontal leg and a vertical leg. Following $\mathbf{u}$ and then $\mathbf{v}$ moves $3 + 1$ to the right and $1 + 2$ up, so the tip-to-tail sum has components $(3 + 1, 1 + 2) = (4, 3)$.
Monocurl source
let pl = Board([-3.0, -1.6, 0], 0.85, 0, 6, 0, 4)
mesh ground = Ground(pl)
mesh legs = [
    Dash(P(pl, [0, 0]), P(pl, [3, 0]), AZURE, 3.5),
    Dash(P(pl, [3, 0]), P(pl, [3, 1]), AZURE, 3.5)
]
mesh arrows = [Vec(pl, [0, 0], u, AZURE)]
mesh marks = [
    center{P(pl, [1.5, 0.3])} Math("3", 0.85, AZURE),
    center{P(pl, [3.25, 0.45])} Math("1", 0.85, AZURE)
]
mesh readout = [center{[2.9, 1.25, 0]} Math("\mathbf{u} = (3, 1)", 0.95, AZURE)]
mesh total = []

slide "The arrow u is 3 to the right and 1 up."
    play Fade(0.6)

slide "Start v at the tip of u. It adds 1 to the right and 2 up."
    legs .= Dash(P(pl, [3, 1]), P(pl, [4, 1]), EMBER, 3.5)
    legs .= Dash(P(pl, [4, 1]), P(pl, [4, 3]), EMBER, 3.5)
    arrows .= Vec(pl, u, [4, 3], EMBER)
    marks .= center{P(pl, [3.5, 1.3])} Math("1", 0.85, EMBER)
    marks .= center{P(pl, [4.25, 2])} Math("2", 0.85, EMBER)
    readout .= center{[2.9, 0.65, 0]} Math("\mathbf{v} = (1, 2)", 0.95, EMBER)
    play Fade(0.6)

slide "Slide the legs to the edges. In total: 3 + 1 to the right and 1 + 2 up."
    marks = []
    play Fade(0.3, [&marks])
    legs = [
        Dash(P(pl, [0, 0]), P(pl, [3, 0]), AZURE, 3.5),
        Dash(P(pl, [4, 0]), P(pl, [4, 1]), AZURE, 3.5),
        Dash(P(pl, [3, 0]), P(pl, [4, 0]), EMBER, 3.5),
        Dash(P(pl, [4, 1]), P(pl, [4, 3]), EMBER, 3.5)
    ]
    play Trans(1.2, [&legs])
    marks = [
        center{P(pl, [1.5, 0.3])} Math("3", 0.85, AZURE),
        center{P(pl, [3.5, 0.3])} Math("1", 0.85, EMBER),
        center{P(pl, [4.25, 0.5])} Math("1", 0.85, AZURE),
        center{P(pl, [4.25, 2])} Math("2", 0.85, EMBER)
    ]
    play Fade(0.4, [&marks])

slide "So the arrow from the start to the end is (3 + 1, 1 + 2) = (4, 3)."
    total = [
        Vec(pl, [0, 0], [4, 3], LEAF),
        center{[2.9, -0.25, 0]} Math("\mathbf{u} + \mathbf{v}", 0.95, LEAF),
        center{[2.9, -0.8, 0]} Math("= (4, 3)", 0.95, LEAF)
    ]
    play Fade(0.6, [&total])

Uses the shared definitions for this lesson's figures.

The picture suggests the general argument, and the argument needs one precise statement of what it means to draw a vector somewhere: the arrow for $\mathbf{v} = (v_1, v_2)$ drawn from the point $(p_1, p_2)$ ends at the point $(p_1 + v_1,\ p_2 + v_2)$. That is the meaning of “go $v_1$ across and $v_2$ up from where you are”.

The proof also shows that $\mathbf{u} + \mathbf{v} = \mathbf{v} + \mathbf{u}$, and it reduced that fact to the same fact about numbers. Most properties of vectors are proved this way: say it in components, then use ordinary arithmetic in each one.

For the pilot, flying is $(240, 0)$ and the wind is $(0, 100)$ in kilometers per hour, so the plane’s velocity over the ground is $(240, 0) + (0, 100) = (240, 100)$.

Length, scaling and subtraction

The pilot’s question was about distance, which is the length of an arrow. The legs of $\mathbf{v} = (v_1, v_2)$ are perpendicular, so by the Pythagorean theorem the length of $\mathbf{v}$ is

$$ |\mathbf{v}| = \sqrt{v_1^2 + v_2^2}. $$

So $|(240, 100)| = 260$ and $|(4, 3)| = 5$. Lengths do not add when vectors do: $|\mathbf{u}| + |\mathbf{v}| = \sqrt{10} + \sqrt{5} \approx 5.40$, while $|\mathbf{u} + \mathbf{v}| = 5$. Walking two sides of a triangle is longer than walking the third.

What if the wind blew for two hours instead of one? The displacement would be $(0, 200)$: the same direction, twice as long. Multiplying a vector by a scalar $c$ multiplies every component by $c$, and the next figure shows what that does to the arrow as $c$ changes.

The vector $\mathbf{w} = (2, 1)$ multiplied by a scalar $c$ that runs from 2 down to $-1.5$. The arrow stays on one line through the origin; its length is multiplied by $|c|$, and it reverses when $c$ is negative.
Monocurl source
let pl = Board([-0.8, -0.05, 0], 0.8, -3, 4, -2, 2)
let w = [2, 1]
let Scaled = |c| {
    let cc = clean(c)
    var col = EMBER
    if (cc < 0) {
        col = PLUM
    }
    return [
        Vec(pl, [0, 0], times(cc, w), col, 5),
        center{[3.02, 0.95, 0]} scale{1.15} color{col} Number(cc, 1),
        center{[3.02, -0.4, 0]} scale{1.05} color{col} Number(2 * cc, 1),
        center{[3.02, -0.95, 0]} scale{1.05} color{col} Number(cc, 1)
    ]
}
mesh ground = Ground(pl)
mesh line = Cut(pl, [-6, -3], [6, 3], MIST, 3)
mesh ghost = Vec(pl, [0, 0], w, AZURE, 3)
mesh labels = [
    center{[3.02, 1.5, 0]} Note("scalar c", 0.74),
    center{[3.02, 0.15, 0]} Math("c\,\mathbf{w}", 0.85, SLATE),
    center{P(pl, [1.55, 1.25])} Math("\mathbf{w}", 0.85, AZURE)
]
mesh arrow = Scaled(c: 2)

slide "scale"
    play Wait(0.8)
    arrow.c = 0.5
    play Lerp(1.8, [&arrow])
    play Wait(0.5)
    arrow.c = -1.5
    play Lerp(2.6, [&arrow])
    play Wait(1.6)

Uses the shared definitions for this lesson's figures.

The scaled arrow always lies on the line through the origin and $\mathbf{w}$. Its length is

$$ |c\,\mathbf{w}| = \sqrt{(c w_1)^2 + (c w_2)^2} = \sqrt{c^2}\,\sqrt{w_1^2 + w_2^2} = |c|\,|\mathbf{w}|, $$

where $\sqrt{c^2} = |c|$ is the absolute value, because a length cannot be negative. A negative scalar reverses the arrow. In particular $(-1)\mathbf{w}$, written $-\mathbf{w}$, is the same displacement run backwards, and subtraction is defined as $\mathbf{u} - \mathbf{v} = \mathbf{u} + (-\mathbf{v})$, which in components is $(u_1 - v_1, u_2 - v_2)$. It answers the question “what must I add to $\mathbf{v}$ to get $\mathbf{u}$?”, since $\mathbf{v} + (\mathbf{u} - \mathbf{v}) = \mathbf{u}$.

The correction for the wind. To move due east over the ground (green), the pilot flies along the blue arrow (240, -100), and the wind (orange) supplies the missing (0, 100).
The correction for the wind. To move due east over the ground (green), the pilot flies along the blue arrow $(240, -100)$, and the wind (orange) supplies the missing $(0, 100)$.
Monocurl source
let pl = Board([-2.95, 1.2, 0], 0.85, 0, 7, -3, 1)
let KM = |x, y| P(pl, [x / 40, y / 40])
mesh ground = Ground(pl, 1, 40)
mesh arrows = [
    Tip(KM(0, 0), KM(240, 0), LEAF, 5, 0.22),
    Tip(KM(0, 0), KM(240, -100), AZURE, 5, 0.22),
    Tip(KM(240, -100), KM(240, -6), EMBER, 5, 0.22)
]
mesh names = [
    center{KM(92, -72)} Math("\mathbf{a} = (240, -100)", 0.85, AZURE),
    center{[KM(240, 0)[0] + 0.5, KM(0, -55)[1], 0]} Math("\mathbf{w}", 0.9, EMBER),
    center{KM(150, 14)} Math("\mathbf{g} = (240, 0)", 0.85, LEAF)
]

Uses the shared definitions for this lesson's figures.

Building arrows out of two fixed ones

Scaling and adding can be combined, and the simplest instance is hiding in the coordinates themselves. Let $\mathbf{i} = (1, 0)$ be one step to the right and $\mathbf{j} = (0, 1)$ one step up. Then

$$ (4, 3) = (4, 0) + (0, 3) = 4\,\mathbf{i} + 3\,\mathbf{j}. $$

The components of a vector are the amounts of $\mathbf{i}$ and $\mathbf{j}$ needed to build it. That raises a question: is there anything special about $\mathbf{i}$ and $\mathbf{j}$? Suppose the only moves allowed were multiples of our earlier arrows $\mathbf{u} = (3, 1)$ and $\mathbf{v} = (1, 2)$. Could we still get everywhere?

Pause and try

Find numbers $a$ and $b$ with $a\,\mathbf{u} + b\,\mathbf{v} = (2, -1)$. Then do the same for the target $(-1, 3)$. Guessing is allowed.

Show answerHide answer

A negative amount is needed: $1\,\mathbf{u} + (-1)\mathbf{v} = (3, 1) - (1, 2) = (2, -1)$, so $a = 1$, $b = -1$. For the second target, $(-1)\mathbf{u} + 2\,\mathbf{v} = (-3, -1) + (2, 4) = (-1, 3)$, so $a = -1$, $b = 2$.

Mixtures $a\,\mathbf{u} + b\,\mathbf{v}$ of $\mathbf{u} = (3, 1)$ and $\mathbf{v} = (1, 2)$. As $a$ and $b$ change, the tip visits the targets $(4, 3)$, $(-1, 3)$ and $(2, -1)$. The slanted grid marks the whole-number mixtures.
Monocurl source
let pl = Board([-0.98, -0.44, 0], 0.58, -4, 5, -2, 4)
let targets = [[4, 3], [-1, 3], [2, -1]]
let Mix = |a, b| {
    let p = times(a, u)
    let q = add(p, times(b, v))
    return [
        Vec(pl, [0, 0], p, AZURE, 5, 0.18),
        Vec(pl, p, q, EMBER, 5, 0.18),
        Pt(P(pl, q), LEAF, 0.1),
        center{[3.15, 0.45, 0]} scale{1.2} color{AZURE} Number(clean(a), 2),
        center{[3.15, -0.4, 0]} scale{1.2} color{EMBER} Number(clean(b), 2)
    ]
}
mesh ground = Ground(pl)
mesh lattice = Lines(pl, [3, 1, 1, 2], tint(AZURE, 0.42), tint(EMBER, 0.42))
mesh rings = map(targets, |t| Ring(P(pl, t), LEAF, 0.12, 3))
mesh labels = [
    center{[2.8, 1.3, 0]} Math("a\,\mathbf{u} + b\,\mathbf{v}", 1.0, INK),
    center{[2.4, 0.45, 0]} Math("a =", 1.0, AZURE),
    center{[2.4, -0.4, 0]} Math("b =", 1.0, EMBER)
]
mesh mix = Mix(a: 1, b: 0)

slide "mix"
    play Wait(0.5)
    mix.b = 1
    play Lerp(1.4, [&mix])
    play Wait(0.8)
    mix.a = -1
    mix.b = 2
    play Lerp(2, [&mix])
    play Wait(0.8)
    mix.a = 1
    mix.b = -1
    play Lerp(2, [&mix])
    play Wait(1.4)

Uses the shared definitions for this lesson's figures.

Guessing works for friendly targets. For an arbitrary one we need a method. Asking for $a\,\mathbf{u} + b\,\mathbf{v} = (w_1, w_2)$ is asking for

$$ a\begin{pmatrix}3\\1\end{pmatrix} + b\begin{pmatrix}1\\2\end{pmatrix} = \begin{pmatrix}w_1\\w_2\end{pmatrix}, \qquad\text{that is,}\qquad \begin{aligned} 3a + b &= w_1 \\ a + 2b &= w_2. \end{aligned} $$

This is a system of two linear equations in the unknowns $a$ and $b$, and it can be solved by elimination: combine the equations so that one unknown cancels.

The same elimination with letters in place of 7 and 0 gives $5a = 2w_1 - w_2$ and $5b = 3w_2 - w_1$. Whatever the target, there is a solution, and only one. Before stating this in general we need names.

In the animation, the span is the set of points the green dot can reach, and “basis” says that it can reach every point, by one setting of the two dials only. The pair $\mathbf{i}, \mathbf{j}$ is a basis, called the standard basis, because $(x, y) = x\,\mathbf{i} + y\,\mathbf{j}$ and no other amounts will do. We have just seen evidence that $\mathbf{u}, \mathbf{v}$ is another.

When two arrows are not enough

Not every pair works. Take $\mathbf{u} = (3, 1)$ again, with $\mathbf{p} = (1.5, 0.5)$ as its partner. Since $\mathbf{p} = \frac12 \mathbf{u}$, every combination is $a\,\mathbf{u} + b\,\mathbf{p} = (a + \frac{b}{2})\mathbf{u}$, a multiple of $\mathbf{u}$. The dot can only run back and forth along one line, and a target such as $(-1, 3)$, which is off that line, is unreachable. Two vectors are called parallel when one of them is a scalar multiple of the other. (Under this definition the zero vector is parallel to everything, since $\mathbf{0} = 0\,\mathbf{u}$.)

The partner of $\mathbf{u} = (3, 1)$ slides from $\mathbf{v} = (1, 2)$ to $(1.5, 0.5)$, which is parallel to $\mathbf{u}$. The grid of mixtures closes up onto a single line, the number $u_1 v_2 - u_2 v_1$ falls to 0, and the point $(-1, 3)$ can no longer be reached.
Monocurl source
let pl = Board([-0.98, -0.44, 0], 0.58, -4, 5, -2, 4)
let Fold = |t| {
    let w = [1 + 0.5 * t, 2 - 1.5 * t]
    return [
        Lines(pl, [3, w[0], 1, w[1]], tint(AZURE, 0.42), tint(EMBER, 0.42)),
        Vec(pl, [0, 0], u, AZURE, 5, 0.18),
        Vec(pl, [0, 0], w, EMBER, 5, 0.18),
        Ring(P(pl, [-1, 3]), ROSE, 0.12, 3),
        center{[2.8, 0.1, 0]} scale{1.4} color{INK} Number(clean(3 * w[1] - w[0]), 2)
    ]
}
mesh ground = Ground(pl)
mesh labels = [center{[2.8, 0.9, 0]} Math("u_1 v_2 - u_2 v_1", 0.9, SLATE)]
mesh fold = Fold(t: 0)
mesh verdict = []

slide "fold"
    play Wait(1)
    fold.t = 1
    play Lerp(4, [&fold])
    verdict = [center{[2.8, -0.75, 0]} Cap("one line only", 0.76, ROSE)]
    play Fade(0.5, [&verdict])
    play Wait(1.8)

Uses the shared definitions for this lesson's figures.

The readout in that figure tracks the quantity that appeared as the 5 in “$5a = 14$”. For $\mathbf{u} = (3, 1)$ and $\mathbf{v} = (1, 2)$ it is $3 \cdot 2 - 1 \cdot 1 = 5$, and for the parallel pair it is $3 \cdot 0.5 - 1 \cdot 1.5 = 0$. The theorem says this one number decides everything.

Read the theorem against the two animations. In the first, $D = 5$, the slanted grid covers the plane, and each target has one address $(a, b)$. In the second, $D$ shrinks to 0 as the grid closes up. The formulas for $a$ and $b$ have $D$ in the denominator, so they report the collapse in advance.

What carries over to more dimensions

Everything defined by components works in $\mathbb{R}^n$ unchanged: addition, scaling, subtraction, and length, which is $\sqrt{v_1^2 + \dots + v_n^2}$. Linear combinations and span make sense for any number of vectors. What changes is the count needed to reach everything. In $\mathbb{R}^3$, two non-parallel vectors span only a plane through the origin, and a basis needs three vectors (Problem 8 looks at this). The number $D$ returns later in this series under the name determinant, where it measures the area of the parallelogram we drew in the second figure.

Looking back, the hard step was the first one: agreeing that a pair of numbers read as “this far across, this far up” deserves to be treated as a single object. Once it is, adding arrows becomes adding numbers, and a geometric question (can I reach that point?) becomes two linear equations. The next lesson asks what happens when we move the basis arrows themselves and let every other vector follow.

Check yourself

Which of these pairs is a basis of $\mathbb{R}^2$?

Problems

The first three repeat the lesson’s moves, the next three combine them, and the last two go beyond the plane or ask for a proof.

Problem 1

Let $\mathbf{u} = (2, -1)$ and $\mathbf{v} = (-3, 4)$. Compute $\mathbf{u} + \mathbf{v}$, $3\mathbf{u}$, $\mathbf{u} - 2\mathbf{v}$ and $|\mathbf{u} + \mathbf{v}|$.

Show solutionHide solution

$\mathbf{u} + \mathbf{v} = (2 - 3,\ -1 + 4) = (-1, 3)$. $3\mathbf{u} = (6, -3)$. $2\mathbf{v} = (-6, 8)$, so $\mathbf{u} - 2\mathbf{v} = (2 + 6,\ -1 - 8) = (8, -9)$. Finally $|\mathbf{u} + \mathbf{v}| = \sqrt{(-1)^2 + 3^2} = \sqrt{10} \approx 3.16$.

Problem 2

A boat points straight across a river and moves at 4 m/s through the water. The current flows at 3 m/s along the river. The river is 100 m wide. Find the boat’s speed over the ground, the time it takes to cross, and how far downstream it lands.

Show solutionHide solution

Put the first axis along the river and the second across it. The boat’s velocity through the water is $(0, 4)$ and the current is $(3, 0)$, so its velocity over the ground is $(3, 4)$ m/s, with speed $\sqrt{9 + 16} = 5$ m/s. Only the second component carries it across: $100 / 4 = 25$ seconds. In that time the first component carries it $3 \times 25 = 75$ m downstream. Check: the displacement is $25\,(3, 4) = (75, 100)$, of length $125 = 5 \times 25$ meters.

Problem 3

The point $A$ has coordinates $(1, 2)$ and the point $B$ has coordinates $(4, 6)$. Find the vector that goes from $A$ to $B$, its length, and the coordinates of the point two fifths of the way from $A$ to $B$.

Show solutionHide solution

The vector from $A$ to $B$ is what must be added to $A$’s position to get $B$’s: $(4 - 1,\ 6 - 2) = (3, 4)$, of length $\sqrt{9 + 16} = 5$. Two fifths of the way along is $A$ plus $\frac25$ of that vector: $(1, 2) + \frac25 (3, 4) = (1 + 1.2,\ 2 + 1.6) = (2.2, 3.6)$. Its distance from $A$ is $\frac25 \cdot 5 = 2$, as it should be.

Problem 4

Write $(1, 8)$ as a linear combination of $\mathbf{u} = (3, 1)$ and $\mathbf{v} = (1, 2)$, first by elimination and then with the formulas of the theorem.

Show solutionHide solution

We need $3a + b = 1$ and $a + 2b = 8$. Doubling the first and subtracting the second gives $5a = 2 - 8 = -6$, so $a = -\frac65$. Then $b = 1 - 3a = 1 + \frac{18}{5} = \frac{23}{5}$. With the formulas, $D = 5$, $a = \frac{w_1 v_2 - w_2 v_1}{D} = \frac{1 \cdot 2 - 8 \cdot 1}{5} = -\frac65$ and $b = \frac{u_1 w_2 - u_2 w_1}{D} = \frac{3 \cdot 8 - 1 \cdot 1}{5} = \frac{23}{5}$. Check: $-\frac65 (3, 1) + \frac{23}{5}(1, 2) = \left(\frac{-18 + 23}{5},\ \frac{-6 + 46}{5}\right) = (1, 8)$.

Problem 5

For which values of the number $k$ do the vectors $(k, 2)$ and $(8, k)$ fail to be a basis of $\mathbb{R}^2$? For each such $k$, write one vector as a multiple of the other.

Show solutionHide solution

$D = k \cdot k - 2 \cdot 8 = k^2 - 16$, which is zero exactly when $k = 4$ or $k = -4$. For $k = 4$ the vectors are $(4, 2)$ and $(8, 4) = 2\,(4, 2)$. For $k = -4$ they are $(-4, 2)$ and $(8, -4) = -2\,(-4, 2)$. For every other $k$ the pair is a basis.

Problem 6

A parallelogram has one corner at the origin and sides $\mathbf{u}$ and $\mathbf{v}$ leaving that corner, where $\mathbf{u}, \mathbf{v}$ are any vectors in $\mathbb{R}^2$. Use vectors to prove that its two diagonals cross at the midpoint of each.

Show solutionHide solution

The corners are at $\mathbf{0}$, $\mathbf{u}$, $\mathbf{u} + \mathbf{v}$ and $\mathbf{v}$. One diagonal runs from $\mathbf{0}$ to $\mathbf{u} + \mathbf{v}$; its midpoint is halfway along, at $\frac12(\mathbf{u} + \mathbf{v})$. The other runs from $\mathbf{u}$ to $\mathbf{v}$. The vector from $\mathbf{u}$ to $\mathbf{v}$ is $\mathbf{v} - \mathbf{u}$, so its midpoint is $\mathbf{u} + \frac12(\mathbf{v} - \mathbf{u}) = \frac12 \mathbf{u} + \frac12 \mathbf{v}$. The two midpoints are the same point, so each diagonal passes through the midpoint of the other. For $\mathbf{u} = (3, 1)$, $\mathbf{v} = (1, 2)$ that point is $(2, 1.5)$.

Problem 7

The three vectors $\mathbf{i} = (1, 0)$, $\mathbf{j} = (0, 1)$ and $\mathbf{s} = (1, 1)$ certainly reach every point of the plane. Find two different ways to write $(2, 3)$ as $a\,\mathbf{i} + b\,\mathbf{j} + c\,\mathbf{s}$, and then explain why three vectors in $\mathbb{R}^2$ can never give every vector exactly one address $(a, b, c)$.

Show solutionHide solution

$(2, 3) = 2\,\mathbf{i} + 3\,\mathbf{j} + 0\,\mathbf{s}$, and also $(2, 3) = 0\,\mathbf{i} + 1\,\mathbf{j} + 2\,\mathbf{s}$, since $(0, 1) + (2, 2) = (2, 3)$. In general, take any three vectors $\mathbf{x}, \mathbf{y}, \mathbf{z}$ in $\mathbb{R}^2$. If two of them, say $\mathbf{x}$ and $\mathbf{y}$, are not parallel, they are a basis, so $\mathbf{z} = a\,\mathbf{x} + b\,\mathbf{y}$ for some $a, b$; then $\mathbf{z}$ has the two addresses $(a, b, 0)$ and $(0, 0, 1)$. If instead every two of them are parallel, then either all three are zero, or one is nonzero and the other two are multiples of it; in both cases the span is at most a line, so some vectors have no address at all. Either way uniqueness or existence fails.

Problem 8

In $\mathbb{R}^3$, let $\mathbf{u} = (1, 0, 1)$ and $\mathbf{v} = (0, 1, 1)$. (a) Is $(1, 2, 3)$ a linear combination of $\mathbf{u}$ and $\mathbf{v}$? (b) Is $(1, 2, 4)$? (c) Describe the span of $\mathbf{u}$ and $\mathbf{v}$ by an equation, and conclude that two vectors cannot be enough to span $\mathbb{R}^3$ in this case.

Show solutionHide solution

A combination is $a\,\mathbf{u} + b\,\mathbf{v} = (a, b, a + b)$. (a) Matching the first two components forces $a = 1$, $b = 2$, and then the third component is $a + b = 3$, which matches. So $(1, 2, 3) = \mathbf{u} + 2\mathbf{v}$. (b) Again $a = 1$ and $b = 2$ are forced, but the third component would be 3, not 4. So $(1, 2, 4)$ is not a combination. (c) The span is the set of vectors $(x, y, z)$ with $z = x + y$: every combination $(a, b, a + b)$ satisfies it, and any vector satisfying it is $x\,\mathbf{u} + y\,\mathbf{v}$. That is a plane through the origin, and it misses $(1, 2, 4)$ along with every other vector whose third component is not the sum of the first two.

Shared definitions used by this lesson's figures
# house kit: prepended to every essay figure after the std imports

# palette. AZURE and EMBER are the two actors, LEAF marks an answer, ROSE a problem
let PAPER = [1, 1, 1, 1]
let INK = [0.08, 0.09, 0.11, 1]
let SLATE = [0.40, 0.44, 0.50, 1]
let MIST = [0.85, 0.86, 0.88, 1]
let AZURE = [0.13, 0.42, 0.68, 1]
let EMBER = [0.89, 0.42, 0.12, 1]
let LEAF = [0.13, 0.55, 0.36, 1]
let ROSE = [0.78, 0.22, 0.24, 1]
let PLUM = [0.47, 0.30, 0.66, 1]
let GOLD = [0.85, 0.62, 0.08, 1]

background = PAPER

# an opaque pastel of col; use for fills so overlaps do not darken
let tint = |col, amount = 0.18| [
    1 - (1 - col[0]) * amount,
    1 - (1 - col[1]) * amount,
    1 - (1 - col[2]) * amount,
    1
]

# text: Cap for labels, Note for quiet labels, Math for typeset maths
let Cap = |txt, size = 0.75, col = INK| color{col} Text(txt, size, "Charter")
let Note = |txt, size = 0.65| color{SLATE} Text(txt, size, "Charter")
let Math = |tex, size = 0.9, col = INK| color{col} Tex(tex, size)

# a paper rectangle to sit behind text that crosses lines
let Plate = |pos, size| center{pos} fill{PAPER} stroke{alpha{0} PAPER, 0} Rect(size)

# shapes with fill and stroke both set, so no stray black appears
let Pt = |pos, col = INK, r = 0.075| center{pos} fill{col} stroke{col, 1} Circle(r, 48)
let Ring = |pos, col = INK, r = 0.1, w = 3| center{pos} fill{PAPER} stroke{col, w} Circle(r, 48)
let Seg = |a, b, col = INK, w = 3| stroke{col, w} Line(a, b)
let Path = |pts, col = INK, w = 3| stroke{col, w} Polyline(pts)
let Region = |pts, col| fill{col} stroke{alpha{0} col, 0} Polygon(pts)
let Outline = |pts, col = INK, w = 3| fill{alpha{0} PAPER} stroke{col, w} Polygon(pts)
let Shape = |pts, col, amount = 0.18, w = 3| fill{tint(col, amount)} stroke{col, w} Polygon(pts)
let Disc = |pos, r, col, amount = 0.18, w = 3| center{pos} fill{tint(col, amount)} stroke{col, w} Circle(r, 96)
let Box = |pos, size, col, amount = 0.18, w = 3| center{pos} fill{tint(col, amount)} stroke{col, w} Rect(size)
# a line from a to b ending in a small solid arrowhead
let Tip = |a, b, col = INK, w = 3, head = 0.17| {
    let d = normalize([b[0] - a[0], b[1] - a[1], 0])
    let n = [-d[1], d[0], 0]
    let base = [b[0] - d[0] * head, b[1] - d[1] * head, 0]
    return [
        stroke{col, w} Line(a, base),
        fill{col} stroke{col, 1} Polygon([
            b,
            [base[0] + n[0] * head * 0.42, base[1] + n[1] * head * 0.42, 0],
            [base[0] - n[0] * head * 0.42, base[1] - n[1] * head * 0.42, 0]
        ])
    ]
}

# plots. a frame is [x0, x1, y0, y1, centre, width, height]: a data window and the scene box it fills
let Frame = |x0, x1, y0, y1, c = [0, 0, 0], w = 6.4, h = 3.6| [x0, x1, y0, y1, c, w, h]
let fx = |fr, x| fr[4][0] + (x - (fr[0] + fr[1]) / 2) * fr[5] / (fr[1] - fr[0])
let fy = |fr, y| fr[4][1] + (y - (fr[2] + fr[3]) / 2) * fr[6] / (fr[3] - fr[2])
let at = |fr, x, y| [fx(fr, x), fy(fr, y), 0]

# axes through the data origin (or the nearest edge of the window), with optional names
let Axes = |fr, x_name = "", y_name = "", col = SLATE| {
    let ox = clamp(fr[0], 0, fr[1])
    let oy = clamp(fr[2], 0, fr[3])
    var parts = [
        Tip(at(fr, fr[0], oy), [fx(fr, fr[1]) + 0.25, fy(fr, oy), 0], col, 2.5, 0.15),
        Tip(at(fr, ox, fr[2]), [fx(fr, ox), fy(fr, fr[3]) + 0.25, 0], col, 2.5, 0.15)
    ]
    if (x_name != "") {
        parts .= center{[fx(fr, fr[1]) + 0.5, fy(fr, oy), 0]} Math(x_name, 0.8, col)
    }
    if (y_name != "") {
        parts .= center{[fx(fr, ox), fy(fr, fr[3]) + 0.5, 0]} Math(y_name, 0.8, col)
    }
    return parts
}

# tick marks with numbers at the listed data values
let XTicks = |fr, xs, col = SLATE, places = 0| block {
    let oy = fy(fr, clamp(fr[2], 0, fr[3]))
    for (x in xs) {
        . Seg([fx(fr, x), oy - 0.07, 0], [fx(fr, x), oy + 0.07, 0], col, 2)
        . center{[fx(fr, x), oy - 0.33, 0]} Math(to_string(x, places), 0.72, col)
    }
}
let YTicks = |fr, ys, col = SLATE, places = 0| block {
    let ox = fx(fr, clamp(fr[0], 0, fr[1]))
    for (y in ys) {
        . Seg([ox - 0.07, fy(fr, y), 0], [ox + 0.07, fy(fr, y), 0], col, 2)
        . center{[ox - 0.36, fy(fr, y), 0]} Math(to_string(y, places), 0.72, col)
    }
}

# faint grid lines at the listed data values
let GridLines = |fr, xs, ys, col = MIST| block {
    for (x in xs) {
        . Seg(at(fr, x, fr[2]), at(fr, x, fr[3]), col, 1.5)
    }
    for (y in ys) {
        . Seg(at(fr, fr[0], y), at(fr, fr[1], y), col, 1.5)
    }
}

# the graph of f over [a, b], drawn in the frame. values are clamped to the window
let Graph = |fr, f, a, b, col = AZURE, w = 4, n = 160|
    stroke{col, w} Polyline(map(sample(a, b, n), |x| at(fr, x, clamp(fr[2], f(x), fr[3]))))

# the region between the graph of f and the x axis over [a, b]
let AreaUnder = |fr, f, a, b, col = AZURE, amount = 0.2, n = 80| {
    var pts = [at(fr, a, 0)]
    for (x in sample(a, b, n)) {
        pts .= at(fr, x, clamp(fr[2], f(x), fr[3]))
    }
    pts .= at(fr, b, 0)
    return fill{tint(col, amount)} stroke{alpha{0} col, 0} Polygon(pts)
}

# vectors are pairs [x, y]. a board is [o, u, x0, x1, y0, y1]: the scene point of the origin,
# the unit length, and the window of whole numbers that is drawn
let Board = |o, u, x0, x1, y0, y1| [o, u, x0, x1, y0, y1]
let P = |pl, v| [pl[0][0] + pl[1] * v[0], pl[0][1] + pl[1] * v[1], 0]
let add = |v, w| [v[0] + w[0], v[1] + w[1]]
let times = |c, v| [c * v[0], c * v[1]]
# matrices are [a, b, c, d] with rows (a b) and (c d), so the columns are (a, c) and (b, d)
let IDENT = [1, 0, 0, 1]
let apply = |m, v| [m[0] * v[0] + m[1] * v[1], m[2] * v[0] + m[3] * v[1]]
let blend = |m, n, t| [
    m[0] + (n[0] - m[0]) * t,
    m[1] + (n[1] - m[1]) * t,
    m[2] + (n[2] - m[2]) * t,
    m[3] + (n[3] - m[3]) * t
]
let GRIDC = tint(AZURE, 0.42)
# faint gridlines, both axes, and numbers along the bottom and left edges every `step`
let Ground = |pl, step = 1, mult = 1| {
    var out = []
    let lo = P(pl, [pl[2], pl[4]])
    let hi = P(pl, [pl[3], pl[5]])
    for (x in range(pl[2], pl[3] + 1)) {
        let sx = P(pl, [x, 0])[0]
        out .= Seg([sx, lo[1], 0], [sx, hi[1], 0], MIST, 1.5)
        if (mod(x, step) == 0) {
            out .= center{[sx, lo[1] - 0.27, 0]} Math(to_string(x * mult), 0.72, SLATE)
        }
    }
    for (y in range(pl[4], pl[5] + 1)) {
        let sy = P(pl, [0, y])[1]
        out .= Seg([lo[0], sy, 0], [hi[0], sy, 0], MIST, 1.5)
        if (mod(y, step) == 0) {
            out .= center{[lo[0] - 0.38, sy, 0]} Math(to_string(y * mult), 0.72, SLATE)
        }
    }
    if (pl[4] <= 0 and pl[5] >= 0) {
        out .= Seg(P(pl, [pl[2], 0]), P(pl, [pl[3], 0]), SLATE, 2.5)
    }
    if (pl[2] <= 0 and pl[3] >= 0) {
        out .= Seg(P(pl, [0, pl[4]]), P(pl, [0, pl[5]]), SLATE, 2.5)
    }
    return out
}
# the part of the segment from scene point p to q that lies in the box lo..hi
let ClipSeg = |p, q, lo, hi, col, w| {
    let d = [q[0] - p[0], q[1] - p[1]]
    var t0 = 0
    var t1 = 1
    for (k in [0, 1]) {
        if (abs(d[k]) < 0.00001) {
            if (p[k] < lo[k] - 0.0001 or p[k] > hi[k] + 0.0001) {
                t1 = -1
            }
        }
        if (abs(d[k]) >= 0.00001) {
            let ta = (lo[k] - p[k]) / d[k]
            let tb = (hi[k] - p[k]) / d[k]
            t0 = max(t0, min(ta, tb))
            t1 = min(t1, max(ta, tb))
        }
    }
    if (t1 - t0 < 0.002) {
        return []
    }
    return stroke{col, w} Line(
        [p[0] + t0 * d[0], p[1] + t0 * d[1], 0],
        [p[0] + t1 * d[0], p[1] + t1 * d[1], 0]
    )
}
# a segment between two points of the board, cut off at the window
let Cut = |pl, a, b, col = SLATE, w = 2|
    ClipSeg(P(pl, a), P(pl, b), P(pl, [pl[2], pl[4]]), P(pl, [pl[3], pl[5]]), col, w)
# the whole-number grid after the matrix m: lines along the first column in col_a, along the second in col_b
let Lines = |pl, m, col_a = GRIDC, col_b = GRIDC, n = 8| block {
    for (k in range(-n, n + 1)) {
        var w = 1.8
        if (k == 0) {
            w = 3
        }
        . Cut(pl, apply(m, [-n, k]), apply(m, [n, k]), col_a, w)
        . Cut(pl, apply(m, [k, -n]), apply(m, [k, n]), col_b, w)
    }
}
# an arrow between two points of the board
let Vec = |pl, a, b, col = INK, w = 4.5, head = 0.2| {
    let p = P(pl, a)
    let q = P(pl, b)
    if (sqrt((q[0] - p[0]) ^ 2 + (q[1] - p[1]) ^ 2) < head * 1.3) {
        return Seg(p, q, col, w)
    }
    return Tip(p, q, col, w, head)
}
# transform the grid: the matrix is t of the way from m0 to m1; the first basis arrow is blue, the second orange
let Warp = |pl, m0, m1, t| {
    let m = blend(m0, m1, t)
    return [
        Lines(pl, m),
        Vec(pl, [0, 0], [m[0], m[2]], AZURE),
        Vec(pl, [0, 0], [m[1], m[3]], EMBER)
    ]
}
let Dash = |a, b, col = SLATE, w = 2.5| stroke{col, w} dashed{[0.1, 0.08]} Line(a, b)
let clean = |x| {
    if (abs(x) < 0.005) {
        return 0
    }
    return x
}
let u = [3, 1]
let v = [1, 2]