All lessons

Vectors

Day
1 of 40
Length
1:58
Textbook
Lay §1.3
Syllabus
Groundwork before Lesson 10

A vector is an arrow from the origin and a list of numbers at the same time; adding and scaling mean the same thing in both pictures.

Linear algebra answers two kinds of question. The first is how to solve many linear equations at once, which Day 3 does. The second is how a matrix moves every point of space, which starts on Day 5 and leads to Day 28's search for the directions a matrix only stretches. Both are written in the language of vectors, so the course starts with the vector itself.

Each section below opens with a problem. Try it before you open the walkthrough, even if you only get partway. The idea you need is always one you can reach from what came before, and the box after the walkthrough names what you just did.

Vectors

A robot starts at the origin of a grid. You tell it "go 3 steps right, then 2 steps up." Write down where it ends up. Then describe, as a pair of numbers, the instruction "go 2 steps left, then 3 steps up."

Walk through the solution

Right is the positive xx direction and up is the positive yy direction, so the robot ends at the point (3,2)(3, 2).

The second instruction moves −2-2 in xx (left is negative) and +3+3 in yy, so it is the pair (−2,3)(-2, 3).

Notice that the pair of numbers is the whole instruction. If you know the two numbers, you know exactly where the robot goes, and if you know where it went, you can read the two numbers back off the grid.

A vector is a list of numbers and an arrow

A vector in R2\mathbb{R}^2 is a column of two real numbers called its entries. We draw it as an arrow from the origin: the first entry says how far to go along the xx-axis and the second says how far along the yy-axis.

v⃗=[32]\yellow{\vec v} = \begin{bmatrix} \green{3} \\ \red{2} \end{bmatrix}

A vector in Rn\mathbb{R}^n is the same idea with nn entries, one for each axis.

Drag the tip of the arrow and watch the two entries change. The green dashes show the first entry and the red dashes show the second.

Drag the tip of v⃗\vec v until v⃗=[−23]\vec v = \begin{bmatrix} -2 \\ 3 \end{bmatrix}.
v⃗=[32]\vec v = \begin{bmatrix} \textcolor{#7BC96F}{3} \\ \textcolor{#F2665E}{2} \end{bmatrix}

Which vector is the arrow that goes 1 step left and 4 steps down?

Vector addition

Everything later in the course is built from two operations, adding vectors and scaling them. We start with adding.

The robot follows the instruction v⃗=[32]\yellow{\vec v} = \begin{bmatrix} 3 \\ 2 \end{bmatrix} and then, starting from where it stopped, the instruction w⃗=[−12]\blue{\vec w} = \begin{bmatrix} -1 \\ 2 \end{bmatrix}. Where does it end? Would it end somewhere else if it did w⃗\blue{\vec w} first?

Walk through the solution

Track each coordinate separately. The first trip moves 33 right and the second moves 11 left, so the total sideways motion is 3+(−1)=23 + (-1) = 2. The first trip moves 22 up and the second moves 22 up, so the total upward motion is 2+2=42 + 2 = 4. The robot ends at (2,4)(2, 4).

[32]+[−12]=[3+(−1)2+2]=[24]\yellow{\begin{bmatrix} 3 \\ 2 \end{bmatrix}} + \blue{\begin{bmatrix} -1 \\ 2 \end{bmatrix}} = \begin{bmatrix} 3 + (-1) \\ 2 + 2 \end{bmatrix} = \teal{\begin{bmatrix} 2 \\ 4 \end{bmatrix}}

Doing w⃗\blue{\vec w} first gives sideways motion −1+3-1 + 3 and upward motion 2+22 + 2, which are the same two sums. So the robot lands at (2,4)(2, 4) either way.

In the picture, doing one trip after the other means drawing the second arrow starting at the tip of the first. The two orders trace the two halves of a parallelogram and meet at its far corner.

Add vectors entry by entry

To add two vectors of the same size, add the entries in each position:

[u1u2]+[v1v2]=[u1+v1u2+v2]\begin{bmatrix} u_1 \\ u_2 \end{bmatrix} + \begin{bmatrix} v_1 \\ v_2 \end{bmatrix} = \begin{bmatrix} u_1 + v_1 \\ u_2 + v_2 \end{bmatrix}

In the picture, slide v⃗\vec v so its tail sits on the tip of u⃗\vec u. The sum is the arrow from the origin to where v⃗\vec v now ends. Since u⃗+v⃗=v⃗+u⃗\vec u + \vec v = \vec v + \vec u, the sum is the far corner of the parallelogram with sides u⃗\vec u and v⃗\vec v.

Move both tips so that v⃗+w⃗=[41]\vec v + \vec w = \begin{bmatrix} 4 \\ 1 \end{bmatrix}. There are many ways to do it.
vwv + w
[32]+[−12]=[24]\textcolor{#FFD447}{\begin{bmatrix} 3 \\ 2 \end{bmatrix}} + \textcolor{#5BC0EB}{\begin{bmatrix} -1 \\ 2 \end{bmatrix}} = \textcolor{#3DD6B5}{\begin{bmatrix} 2 \\ 4 \end{bmatrix}}

Scalar multiplication

What single instruction does the same thing as doing v⃗=[32]\yellow{\vec v} = \begin{bmatrix} 3 \\ 2 \end{bmatrix} twice in a row? What would "do v⃗\yellow{\vec v} half a time" mean, and what about "do v⃗\yellow{\vec v} backward"?

Walk through the solution

Twice in a row is v⃗+v⃗=[3+32+2]=[64]\yellow{\vec v} + \yellow{\vec v} = \begin{bmatrix} 3 + 3 \\ 2 + 2 \end{bmatrix} = \begin{bmatrix} 6 \\ 4 \end{bmatrix}. Each entry doubled, and the arrow points the same way but is twice as long.

Half a time should be the vector that, done twice, gives v⃗\yellow{\vec v}. That is [1.51]\begin{bmatrix} 1.5 \\ 1 \end{bmatrix}, which is each entry halved.

Backward means undoing the trip, going 3 left and 2 down. That is [−3−2]\begin{bmatrix} -3 \\ -2 \end{bmatrix}, which is each entry multiplied by −1-1.

In all three cases we multiplied every entry by the same number: 22, 12\tfrac12 and −1-1.

Scaling multiplies every entry

A scalar is a single real number. The scalar multiple c u⃗c\,\vec u multiplies every entry of u⃗\vec u by cc:

c[u1u2]=[c u1c u2]c \begin{bmatrix} u_1 \\ u_2 \end{bmatrix} = \begin{bmatrix} c\,u_1 \\ c\,u_2 \end{bmatrix}

The arrow gets ∣c∣|c| times as long. If cc is negative it also flips to point the opposite way, and if c=0c = 0 you get the zero vector 0⃗\vec 0, which has every entry 00.

Find the scalar that lands on the ringed point. Notice that every position the arrow can reach lies on one line through the origin.

Find the scalar cc that moves the tip of c v⃗c\,\vec v onto the ringed point.
c [32]=[32]c\,\begin{bmatrix} 3 \\ 2 \end{bmatrix} = \textcolor{#FFD447}{\begin{bmatrix} 3 \\ 2 \end{bmatrix}}

Is [95]\begin{bmatrix} 9 \\ 5 \end{bmatrix} a scalar multiple of [32]\begin{bmatrix} 3 \\ 2 \end{bmatrix}?

Subtraction

Let u⃗=[41]\yellow{\vec u} = \begin{bmatrix} 4 \\ 1 \end{bmatrix} and v⃗=[13]\blue{\vec v} = \begin{bmatrix} 1 \\ 3 \end{bmatrix}. Compute u⃗−v⃗\yellow{\vec u} - \blue{\vec v}. Then find the instruction that takes the robot from the tip of v⃗\blue{\vec v} to the tip of u⃗\yellow{\vec u}.

Walk through the solution

Subtracting means adding the backward trip, u⃗−v⃗=u⃗+(−1)v⃗\vec u - \vec v = \vec u + (-1)\vec v:

[41]+[−1−3]=[3−2]\begin{bmatrix} 4 \\ 1 \end{bmatrix} + \begin{bmatrix} -1 \\ -3 \end{bmatrix} = \begin{bmatrix} 3 \\ -2 \end{bmatrix}

To go from (1,3)(1, 3) to (4,1)(4, 1) the robot moves 4−1=34 - 1 = 3 right and 1−3=−21 - 3 = -2 up, so the instruction is also [3−2]\begin{bmatrix} 3 \\ -2 \end{bmatrix}. That is no coincidence. Since v⃗+(u⃗−v⃗)=u⃗\vec v + (\vec u - \vec v) = \vec u, the difference is exactly the trip that finishes the journey from v⃗\vec v to u⃗\vec u.

Move the tips so that u⃗−v⃗=[−22]\vec u - \vec v = \begin{bmatrix} -2 \\ 2 \end{bmatrix}. Watch the dashed arrow from the tip of v⃗\vec v to the tip of u⃗\vec u.
uvu − v
[41]−[13]=[3−2]\textcolor{#FFD447}{\begin{bmatrix} 4 \\ 1 \end{bmatrix}} - \textcolor{#5BC0EB}{\begin{bmatrix} 1 \\ 3 \end{bmatrix}} = \textcolor{#3DD6B5}{\begin{bmatrix} 3 \\ -2 \end{bmatrix}}

Linear combinations

Now we can combine the two operations: scale some vectors, then add the results. This is the single most important construction in the course.

Let u⃗=[2−1]\yellow{\vec u} = \begin{bmatrix} 2 \\ -1 \end{bmatrix} and v⃗=[13]\blue{\vec v} = \begin{bmatrix} 1 \\ 3 \end{bmatrix}. Compute 3u⃗−2v⃗3\yellow{\vec u} - 2\blue{\vec v}.

Walk through the solution

Do the scalings first, then the addition. Work through it one step at a time.

  1. 1

    Scale u⃗\yellow{\vec u} by 33:   3[2−1]=[6−3]\;3\begin{bmatrix} 2 \\ -1 \end{bmatrix} = \begin{bmatrix} 6 \\ -3 \end{bmatrix}.

  2. 2
  3. 3

Linear combination

Given vectors v⃗1,…,v⃗p\vec v_1, \dots, \vec v_p in Rn\mathbb{R}^n and scalars c1,…,cpc_1, \dots, c_p, the vector

y⃗=c1v⃗1+c2v⃗2+⋯+cpv⃗p\vec y = c_1 \vec v_1 + c_2 \vec v_2 + \cdots + c_p \vec v_p

is a linear combination of v⃗1,…,v⃗p\vec v_1, \dots, \vec v_p with weights c1,…,cpc_1, \dots, c_p. The weights can be any real numbers, including 00 and negatives.

The previous problem gave you the weights and asked for the vector. The harder and more useful question runs the other way: given a target vector, which weights reach it? Tomorrow you will see that solving a system of equations is exactly this question.

The slanted grid below is made of whole steps of v⃗=[−11]\yellow{\vec v} = \begin{bmatrix} -1 \\ 1 \end{bmatrix} and w⃗=[21]\blue{\vec w} = \begin{bmatrix} 2 \\ 1 \end{bmatrix}. Find weights aa and bb with av⃗+bw⃗=[−52]a\yellow{\vec v} + b\blue{\vec w} = \begin{bmatrix} -5 \\ 2 \end{bmatrix} by counting grid steps. Use the sliders to test your guess.

Walk through the solution

Starting at the origin, three yellow steps take you to 3v⃗=(−3,3)3\yellow{\vec v} = (-3, 3). From there you need to go 22 more left and 11 down, which is one blue step backward, −w⃗=(−2,−1)-\blue{\vec w} = (-2, -1). So a=3a = 3 and b=−1b = -1:

3[−11]−[21]=[−52]3\begin{bmatrix} -1 \\ 1 \end{bmatrix} - \begin{bmatrix} 2 \\ 1 \end{bmatrix} = \begin{bmatrix} -5 \\ 2 \end{bmatrix}

On this slanted grid, the weights play the role that xx and yy play on the ordinary grid. Day 15 turns that idea into coordinates relative to a basis.

Count grid steps to reach the ringed point. Each yellow step is one v⃗\vec v and each blue step is one w⃗\vec w.
0[−11]+0[21]=[00]0\textcolor{#FFD447}{\begin{bmatrix} -1 \\ 1 \end{bmatrix}} + 0\textcolor{#5BC0EB}{\begin{bmatrix} 2 \\ 1 \end{bmatrix}} = \textcolor{#3DD6B5}{\begin{bmatrix} 0 \\ 0 \end{bmatrix}}

When the grid is not drawn for you, you have to find the weights by reasoning. Try it with a different pair of vectors. On Day 4, multiplying a matrix by a vector will compute exactly this kind of sum.

Choose weights aa and bb so that a v⃗+b w⃗a\,\vec v + b\,\vec w lands on the ringed point [56]\begin{bmatrix} 5 \\ 6 \end{bmatrix}.
1[32]+0[−12]=[32]1\textcolor{#FFD447}{\begin{bmatrix} 3 \\ 2 \end{bmatrix}} + 0\textcolor{#5BC0EB}{\begin{bmatrix} -1 \\ 2 \end{bmatrix}} = \textcolor{#3DD6B5}{\begin{bmatrix} 3 \\ 2 \end{bmatrix}}
The vectors v and w with a lattice of orange dots spread across the whole screen. Each dot is a·v + b·w for a different pair of weights.

Every orange dot above is a v⃗+b w⃗a\,\yellow{\vec v} + b\,\blue{\vec w} for one choice of aa and bb. Because v⃗\yellow{\vec v} and w⃗\blue{\vec w} point in different directions, some choice of weights reaches every point of the plane. Tomorrow's lesson names that set the span and asks which vectors a given set of arrows can reach.

Practice

Warm-up

Compute [2−1]+[−54]\begin{bmatrix} 2 \\ -1 \end{bmatrix} + \begin{bmatrix} -5 \\ 4 \end{bmatrix}.

Show the solution
[2+(−5)−1+4]=[−33]\begin{bmatrix} 2 + (-5) \\ -1 + 4 \end{bmatrix} = \begin{bmatrix} -3 \\ 3 \end{bmatrix}

Compute −3[2−14]-3\begin{bmatrix} 2 \\ -1 \\ 4 \end{bmatrix}.

Show the solution

Multiply each of the three entries by −3-3: [−63−12]\begin{bmatrix} -6 \\ 3 \\ -12 \end{bmatrix}. A vector in R3\mathbb{R}^3 works exactly like one in R2\mathbb{R}^2, with one more entry.

Let u⃗=[5−2]\vec u = \begin{bmatrix} 5 \\ -2 \end{bmatrix} and v⃗=[13]\vec v = \begin{bmatrix} 1 \\ 3 \end{bmatrix}. Compute u⃗−v⃗\vec u - \vec v.

Show the solution
[5−1−2−3]=[4−5]\begin{bmatrix} 5 - 1 \\ -2 - 3 \end{bmatrix} = \begin{bmatrix} 4 \\ -5 \end{bmatrix}

Core

Compute   2[1−3]+[45]\;2\begin{bmatrix} 1 \\ -3 \end{bmatrix} + \begin{bmatrix} 4 \\ 5 \end{bmatrix}.

Show the solution
[2−6]+[45]=[6−1]\begin{bmatrix} 2 \\ -6 \end{bmatrix} + \begin{bmatrix} 4 \\ 5 \end{bmatrix} = \begin{bmatrix} 6 \\ -1 \end{bmatrix}

Let u⃗=[20−1]\vec u = \begin{bmatrix} 2 \\ 0 \\ -1 \end{bmatrix} and v⃗=[1−42]\vec v = \begin{bmatrix} 1 \\ -4 \\ 2 \end{bmatrix}. Compute 3u⃗−2v⃗3\vec u - 2\vec v. (Modeled on Lay §1.3, Example 1.)

Show a hint

Compute 3u⃗3\vec u and −2v⃗-2\vec v separately, then add them entry by entry.

Show the solution
3u⃗−2v⃗=[60−3]+[−28−4]=[48−7]\begin{aligned} 3\vec u - 2\vec v &= \begin{bmatrix} 6 \\ 0 \\ -3 \end{bmatrix} + \begin{bmatrix} -2 \\ 8 \\ -4 \end{bmatrix} \\ &= \begin{bmatrix} 4 \\ 8 \\ -7 \end{bmatrix} \end{aligned}

Find the scalar cc with c[−26]=[5−15]c\begin{bmatrix} -2 \\ 6 \end{bmatrix} = \begin{bmatrix} 5 \\ -15 \end{bmatrix}.

c=c =
Show the solution

The first entries need −2c=5-2c = 5, so c=−52c = -\tfrac52. Check the second entry with the same cc: 6⋅(−52)=−156 \cdot (-\tfrac52) = -15. Both entries agree, so c=−52c = -\tfrac52.

Find weights aa and bb so that a[11]+b[2−1]=[71]a\begin{bmatrix} 1 \\ 1 \end{bmatrix} + b\begin{bmatrix} 2 \\ -1 \end{bmatrix} = \begin{bmatrix} 7 \\ 1 \end{bmatrix}.

Show a hint

Write out the left side as one vector, then match its top entry to 77 and its bottom entry to 11. That gives two equations in aa and bb.

Show the solution

Matching entries gives a+2b=7a + 2b = 7 and a−b=1a - b = 1. Subtracting the second equation from the first gives 3b=63b = 6, so b=2b = 2 and a=3a = 3.

Check: 3[11]+2[2−1]=[71]3\begin{bmatrix} 1 \\ 1 \end{bmatrix} + 2\begin{bmatrix} 2 \\ -1 \end{bmatrix} = \begin{bmatrix} 7 \\ 1 \end{bmatrix}.

A bakery tray of bread uses 44 kg of flour, 11 kg of sugar and 11 kg of butter, and a tray of muffins uses 22 kg of flour, 22 kg of sugar and 11 kg of butter. Write each recipe as a vector (flour, sugar, butter). How much of each ingredient do 33 trays of bread and 55 trays of muffins use? (Modeled on Lay §1.3, Example 7.)

Show the solution

The recipes are b⃗=[411]\vec b = \begin{bmatrix} 4 \\ 1 \\ 1 \end{bmatrix} and m⃗=[221]\vec m = \begin{bmatrix} 2 \\ 2 \\ 1 \end{bmatrix}. The total is the linear combination 3b⃗+5m⃗3\vec b + 5\vec m:

[1233]+[10105]=[22138]\begin{bmatrix} 12 \\ 3 \\ 3 \end{bmatrix} + \begin{bmatrix} 10 \\ 10 \\ 5 \end{bmatrix} = \begin{bmatrix} 22 \\ 13 \\ 8 \end{bmatrix}

So they need 2222 kg of flour, 1313 kg of sugar and 88 kg of butter. Here a vector is a bundle of quantities, not an arrow, and scaling then adding is still the right operation.

Challenge

Find the vector x⃗\vec x with x⃗+[3−1]=2x⃗−[15]\vec x + \begin{bmatrix} 3 \\ -1 \end{bmatrix} = 2\vec x - \begin{bmatrix} 1 \\ 5 \end{bmatrix}.

Show a hint

Vector equations can be rearranged like ordinary equations. Move every x⃗\vec x to one side.

Show the solution

Subtract x⃗\vec x from both sides and add [15]\begin{bmatrix} 1 \\ 5 \end{bmatrix} to both sides:

x⃗=[3−1]+[15]=[44]\vec x = \begin{bmatrix} 3 \\ -1 \end{bmatrix} + \begin{bmatrix} 1 \\ 5 \end{bmatrix} = \begin{bmatrix} 4 \\ 4 \end{bmatrix}

Check: the left side is [73]\begin{bmatrix} 7 \\ 3 \end{bmatrix}, and the right side is [88]−[15]=[73]\begin{bmatrix} 8 \\ 8 \end{bmatrix} - \begin{bmatrix} 1 \\ 5 \end{bmatrix} = \begin{bmatrix} 7 \\ 3 \end{bmatrix}.

Can you reach [73]\begin{bmatrix} 7 \\ 3 \end{bmatrix} with a linear combination of [21]\begin{bmatrix} 2 \\ 1 \end{bmatrix} and [42]\begin{bmatrix} 4 \\ 2 \end{bmatrix}?

Show that c(u⃗+v⃗)=c u⃗+c v⃗c(\vec u + \vec v) = c\,\vec u + c\,\vec v for any vectors u⃗,v⃗\vec u, \vec v in R2\mathbb{R}^2 and any scalar cc. (Modeled on Lay §1.3, Practice Problem 1.)

Show a hint

Write u⃗=(u1,u2)\vec u = (u_1, u_2) and v⃗=(v1,v2)\vec v = (v_1, v_2), work out both sides entry by entry, and use a fact about ordinary numbers.

Show the solution
c(u⃗+v⃗)=c[u1+v1u2+v2]definition of addition=[cu1+cv1cu2+cv2]distributive law for numbers=c u⃗+c v⃗definitions of scaling and addition\begin{aligned} c(\vec u + \vec v) &= c\begin{bmatrix} u_1 + v_1 \\ u_2 + v_2 \end{bmatrix} && \text{definition of addition} \\ &= \begin{bmatrix} c u_1 + c v_1 \\ c u_2 + c v_2 \end{bmatrix} && \text{distributive law for numbers} \\ &= c\,\vec u + c\,\vec v && \text{definitions of scaling and addition} \end{aligned}

Every vector rule works this way. The operations act one entry at a time, so each rule follows from the matching rule for ordinary numbers.