Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.An arrow that says “go this way, this far”
A treasure map says: “walk 3 steps east, then 2 steps north”. That instruction is a vector. You can draw it as an arrow, or write it as two numbers: (3, 2).
Adding arrows = doing one move, then the other
First walk (3, 2), then walk (1, 4). Where do you end up? 3 + 1 = 4 steps east and 2 + 4 = 6 steps north: (4, 6). Adding vectors just means doing one move after the other.
Stretching arrows
“Walk twice as far in the same direction” turns (3, 2) into (6, 4). Multiplying a vector by a number stretches it. A negative number turns it around.
Play with it. Move the sliders and watch the orange arrow, u + v:
Vectors that aren’t arrows
A list of numbers can describe anything. A fruit could be (weight 150 g, sweetness 7, redness 9). A robot arm could be (joint 1 angle, joint 2 angle, joint 3 angle). Mathematicians call these vectors too, even when there’s no arrow to draw.
A Mars rover keeps track of its position as a vector (x, y, z). Every time it drives, it adds the small move vector to its position.
- 1. Walk (2, 1), then walk (3, 3). Where are you?
- 2. What is 3 × (1, 2)?
- 3. A list (age, height, weight) describing a person is…
Level 1: Beginner
★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.Notation
We write vectors in bold or with an arrow: or . They’re usually written as a column:
The numbers are the components. is the flat plane, and is 3D space.
The operations
| Operation | Rule | Example |
|---|---|---|
| Addition | add matching components | |
| Scalar multiplication | multiply every component | |
| Negative | flip every sign | |
| Subtraction | add the negative | |
| Zero vector | all zeros |
From one point to another
The vector that takes you from point to point is . From to : .
Length
By Pythagoras, the length (or norm) of is . So . Dividing a vector by its length gives a unit vector, which has length 1 and the same direction: .
- 1. (5, −1) − (2, 3) = ?
- 2. Length of (6, 8)?
- 3. The vector from A = (2, 2) to B = (5, 6) is…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.Vectors in n dimensions
is the set of all lists of real numbers. Operations work component by component:
They obey familiar rules: , , , , . These rules are exactly what defines a “vector space” (A2.1-3).
Linear and convex combinations
A linear combination of vectors is . When the weights are non-negative and sum to 1, it’s a convex combination: a weighted average.
- Linear interpolation (lerp): moves along the segment from (at ) to (at ). Robots use it to plan straight-line motions, and animators use it for in-between frames.
- Centroid (mean): , the centre of a cloud of points. It’s what k-means clustering computes for each cluster.
Vectors in NumPy
In practice we use NumPy arrays, where u + v and 3 * u work component by component and run very fast. A whole dataset is a matrix with one vector per row.
Where vectors show up
| Field | Vector |
|---|---|
| Data science | Each row of a table: a data point with features |
| ML | Model parameters . The gradient is a vector pointing uphill |
| NLP | Word and sentence embeddings in and up |
| Robotics | Position, velocity, acceleration, force, torque. Joint configuration |
| Physics | The resultant force is the vector sum of all forces. Zero resultant means equilibrium |
- 1. lerp(a, b, 0.25) is…
- 2. The centroid of (0,0), (6,0), (0,6) is…
- 3. Which is a convex combination?
Level 3: Advanced
★★★★☆ Advanced⏱ 35 minGraduate level, with full derivations and proofs.Points versus vectors
A point is a location, and a vector is a displacement. They behave differently:
- point − point = vector ()
- point + vector = point
- point + point has no meaning: the answer depends on where you put the origin.
But affine combinations, with , are meaningful for points.
An affine combination of points doesn’t depend on the choice of origin.
Proof. Shift the origin by , so each point becomes . Then . That’s the same point, written in the new coordinates. ∎ If the weights summed to anything other than 1, the result would move with the origin.
Robotics encodes this difference with homogeneous coordinates: a point versus a direction . A rigid transform moves points but only rotates directions (R2).
Barycentric coordinates
Every point in the plane can be written as with for a triangle . is inside the triangle exactly when all three weights are . This is how graphics cards decide which pixels a triangle covers, and how meshes interpolate values in simulations.
The centroid minimizes squared distance
For points , the point minimizing is the centroid .
Proof. Write and expand:
The middle sum is by the definition of the mean. The last term is and is zero only when . ∎ This is exactly why each k-means update moves a centre to the mean of its cluster (D8).
Exercise 3.1: Show that the midpoint of A and B is an affine combination, and find its weights
. The weights sum to 1, so doesn’t depend on the origin.
Exercise 3.2: Is (1, 1) inside the triangle (0,0), (4,0), (0,4)?
Write with . This gives . All are , so yes, it’s inside.
- 1. Which expression is meaningful for points A, B?
- 2. In homogeneous coordinates, a direction vector has last component…
- 3. Barycentric weights (0.5, 0.6, −0.1) mean the point is…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Meaning as direction: embeddings
Word2vec (Mikolov et al., 2013) found that relations between words appear as consistent vector offsets. For example, is closest to . Recent research on the linear representation hypothesis (Park, Choe and Veitch, 2024) asks when and why high-level concepts in large language models are encoded as directions. That question is central to interpretability and model steering (F15). You’ll test the idea in Practice Code 5.
High-dimensional vectors behave strangely
In with large , two random directions are almost perpendicular. The cosine of the angle between them is roughly normal with standard deviation . So for large , the typical is about . This is why huge numbers of nearly independent features can be packed into an embedding space (“superposition”, F15), and why similarity search needs care (A2.1-2).
Six-dimensional vectors in robotics
Rigid-body robotics packs angular and linear quantities into 6-vectors: a twist for velocity, and a wrench for force and torque. Featherstone’s spatial vector algebra (2008) uses them to compute the dynamics of a robot with joints in time. That’s what real-time controllers for humanoids and quadrupeds run (R4).
References
- H. Grassmann (1844). Die lineale Ausdehnungslehre. (The first general theory of vector spaces.)
- J. W. Gibbs and E. B. Wilson (1901). Vector Analysis. Yale University Press.
- T. Mikolov, W. Yih, G. Zweig (2013). “Linguistic regularities in continuous space word representations.” NAACL-HLT.
- R. Featherstone (2008). Rigid Body Dynamics Algorithms. Springer.
- K. Park, Y. J. Choe, V. Veitch (2024). “The linear representation hypothesis and the geometry of large language models.” ICML.
- G. Strang (2016). Introduction to Linear Algebra, 5th ed. Wellesley-Cambridge Press. Chapter 1.
- S. Axler (2024). Linear Algebra Done Right, 4th ed. Springer (open access). Chapter 1.