Module 1: Vectors
In the last lesson you learned that a vector is a displacement — an instruction to move a certain distance in a certain direction. So what happens when you follow two displacements one after another?
Say you walk 3 blocks east and 1 block north to reach a park. From there, you walk 1 block east and 3 blocks north to reach a café. Where did you end up relative to where you started?
You went 4 blocks east and 4 blocks north in total. That combined journey is the sum of the two vectors.
Here's the geometric rule: place the tail of the second vector at the tip of the first. The sum is the arrow that goes straight from where you started to where you ended up.
In the interactive, the faint blue and pink arrows show this — each vector is drawn again starting from the other's tip. The green arrow is the result.
You don't need to draw anything to compute a sum. Just add the x-components together and the y-components together:
That's it. No trick. The geometry (tip-to-tail) and the algebra (add the components) always give the same answer.
import numpy as np
v1 = np.array([3, 1])
v2 = np.array([1, 3])
print(v1 + v2) # [4, 4]NumPy adds arrays element-wise by default. This is exactly vector addition — the same rule, just written as code.