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 solutionHide the walkthrough
Right is the positive x direction and up is the positive y direction, so the robot ends at the point (3,2).
The second instruction moves −2 in x (left is negative) and +3 in y, so it is the pair (−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 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 x-axis and the second says how far along the y-axis.
v=[32]
A vector in Rn is the same idea with n 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 until v=[−23].
That’s it. The first entry is how far right, the second is how far up.
v=[32]
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] and then, starting from where it stopped, the instruction w=[−12]. Where does it end? Would it end somewhere else if it did w first?
Walk through the solutionHide the walkthrough
Track each coordinate separately. The first trip moves 3 right and the second moves 1 left, so the total sideways motion is 3+(−1)=2. The first trip moves 2 up and the second moves 2 up, so the total upward motion is 2+2=4. The robot ends at (2,4).
[32]+[−12]=[3+(−1)2+2]=[24]
Doing w first gives sideways motion −1+3 and upward motion 2+2, which are the same two sums. So the robot lands at (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]
In the picture, slide v so its tail sits on the tip of u. The sum is the arrow from the origin to where v now ends. Since u+v=v+u, the sum is the far corner of the parallelogram with sides u and v.
Move both tips so that v+w=[41]. There are many ways to do it.
Nice. Every pair whose entries add up to the target works, and the dashed copy of w always ends at the same place.
[32]+[−12]=[24]
Scalar multiplication
What single instruction does the same thing as doing v=[32] twice in a row? What would "do v half a time" mean, and what about "do v backward"?
Walk through the solutionHide the walkthrough
Twice in a row is v+v=[3+32+2]=[64]. 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. That is [1.51], which is each entry halved.
Backward means undoing the trip, going 3 left and 2 down. That is [−3−2], which is each entry multiplied by −1.
In all three cases we multiplied every entry by the same number: 2, 21 and −1.
Scaling multiplies every entry
A scalar is a single real number. The scalar multiplecu multiplies every entry of u by c:
c[u1u2]=[cu1cu2]
The arrow gets ∣c∣ times as long. If c is negative it also flips to point the opposite way, and if c=0 you get the zero vector0, which has every entry 0.
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 c that moves the tip of cv onto the ringed point.
Right, c=−1.5. A negative scalar flips the arrow before stretching it.
c[32]=[32]
Is [95] a scalar multiple of [32]?
Subtraction
Let u=[41] and v=[13]. Compute u−v. Then find the instruction that takes the robot from the tip of v to the tip of u.
Walk through the solutionHide the walkthrough
Subtracting means adding the backward trip, u−v=u+(−1)v:
[41]+[−1−3]=[3−2]
To go from (1,3) to (4,1) the robot moves 4−1=3 right and 1−3=−2 up, so the instruction is also [3−2]. That is no coincidence. Since v+(u−v)=u, the difference is exactly the trip that finishes the journey from v to u.
Move the tips so that u−v=[−22]. Watch the dashed arrow from the tip of v to the tip of u.
That works. The difference u−v is the trip from the tip of v to the tip of u, moved back to start at the origin.
[41]−[13]=[3−2]
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] and v=[13]. Compute 3u−2v.
Walk through the solutionHide the walkthrough
Do the scalings first, then the addition. Work through it one step at a time.
1
Scale u by 3: 3[2−1]=[6−3].
2
Scale v by −2, because subtracting 2v is adding −2v: −2[13]=[−2−6].
3
Add entry by entry: [6−3]+[−2−6]=[4−9].
Linear combination
Given vectors v1,…,vp in Rn and scalars c1,…,cp, the vector
y=c1v1+c2v2+⋯+cpvp
is a linear combination of v1,…,vp with weightsc1,…,cp. The weights can be any real numbers, including 0 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] and w=[21]. Find weights a and b with av+bw=[−52] by counting grid steps. Use the sliders to test your guess.
Walk through the solutionHide the walkthrough
Starting at the origin, three yellow steps take you to 3v=(−3,3). From there you need to go 2 more left and 1 down, which is one blue step backward, −w=(−2,−1). So a=3 and b=−1:
3[−11]−[21]=[−52]
On this slanted grid, the weights play the role that x and y 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 and each blue step is one w.
You read the weights straight off the slanted grid. On this grid, the weights are the point’s coordinates.
0[−11]+0[21]=[00]
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 a and b so that av+bw lands on the ringed point [56].
You found it: 2v+1w=[56]. Those weights are the only pair that works.
1[32]+0[−12]=[32]
Every orange dot above is av+bw for one choice of a and b. Because v and 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].
Show the solutionHide the solution
[2+(−5)−1+4]=[−33]
Compute −32−14.
Show the solutionHide the solution
Multiply each of the three entries by −3: −63−12. A vector in R3 works exactly like one in R2, with one more entry.
Let u=[5−2] and v=[13]. Compute u−v.
Show the solutionHide the solution
[5−1−2−3]=[4−5]
Core
Compute 2[1−3]+[45].
Show the solutionHide the solution
[2−6]+[45]=[6−1]
Let u=20−1 and v=1−42. Compute 3u−2v. (Modeled on Lay §1.3, Example 1.)
Show a hintHide the hint
Compute 3u and −2v separately, then add them entry by entry.
Show the solutionHide the solution
3u−2v=60−3+−28−4=48−7
Find the scalar c with c[−26]=[5−15].
Show the solutionHide the solution
The first entries need −2c=5, so c=−25. Check the second entry with the same c: 6⋅(−25)=−15. Both entries agree, so c=−25.
Find weights a and b so that a[11]+b[2−1]=[71].
Show a hintHide the hint
Write out the left side as one vector, then match its top entry to 7 and its bottom entry to 1. That gives two equations in a and b.
Show the solutionHide the solution
Matching entries gives a+2b=7 and a−b=1. Subtracting the second equation from the first gives 3b=6, so b=2 and a=3.
Check: 3[11]+2[2−1]=[71].
A bakery tray of bread uses 4 kg of flour, 1 kg of sugar and 1 kg of butter, and a tray of muffins uses 2 kg of flour, 2 kg of sugar and 1 kg of butter. Write each recipe as a vector (flour, sugar, butter). How much of each ingredient do 3 trays of bread and 5 trays of muffins use? (Modeled on Lay §1.3, Example 7.)
Show the solutionHide the solution
The recipes are b=411 and m=221. The total is the linear combination 3b+5m:
1233+10105=22138
So they need 22 kg of flour, 13 kg of sugar and 8 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 with x+[3−1]=2x−[15].
Show a hintHide the hint
Vector equations can be rearranged like ordinary equations. Move every x to one side.
Show the solutionHide the solution
Subtract x from both sides and add [15] to both sides:
x=[3−1]+[15]=[44]
Check: the left side is [73], and the right side is [88]−[15]=[73].
Can you reach [73] with a linear combination of [21] and [42]?
Show that c(u+v)=cu+cv for any vectors u,v in R2 and any scalar c. (Modeled on Lay §1.3, Practice Problem 1.)
Show a hintHide the hint
Write u=(u1,u2) and v=(v1,v2), work out both sides entry by entry, and use a fact about ordinary numbers.
Show the solutionHide the solution
c(u+v)=c[u1+v1u2+v2]=[cu1+cv1cu2+cv2]=cu+cvdefinition of additiondistributive law for numbersdefinitions of scaling and addition
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.