Vectors
Add, scale and measure vectors, compute dot products and angles, and project one vector onto another.
20 min
A vector is a quantity with both size and direction. In practice it is a list of numbers: v = (3, 4) is an arrow from the origin to the point (3, 4) in the plane. In data work the same list might be a customer's features or a pixel's colour. Linear algebra treats them all the same way.
- Addition: add component by component. (1, 2) + (3, −1) = (4, 1). Geometrically, place the arrows head to tail.
- Scalar multiplication: multiply every component. 2(3, 4) = (6, 8): the same direction, twice as long. A negative scalar flips the direction.
Every other idea in the course is built from these two moves, called linear combinations: c₁v₁ + c₂v₂ + … .
The length (norm) of v = (v₁, v₂, …) is |v| = √(v₁² + v₂² + …). For (3, 4) it is 5. A unit vector has length 1; divide any nonzero vector by its length to get one: (3, 4)/5 = (0.6, 0.8).
u · v = u₁v₁ + u₂v₂ + … , and geometrically
u · v = |u||v| cos θ, where θ is the angle between them.
So cos θ = (u · v)/(|u||v|). The sign tells you the angle type: positive means acute, zero means perpendicular (orthogonal), negative means obtuse.
The shadow of v on the line through u is the vector
proj_u(v) = [(u · v)/(u · u)] u
It is the part of v pointing along u. The leftover, v − proj_u(v), is perpendicular to u. Projection is how best-fit lines and least squares work.
Let u = (3, 4) and v = (2, −1). Find |u|, the angle between them, and the projection of v onto u.
- 1
|u| = √(9 + 16) = 5 and |v| = √(4 + 1) = √5
Lengths.
Start at u = (3, 4), v = (2, −1): cos θ ≈ 0.179. Set v = (4, −3): you get 0 and the vectors are perpendicular. Set v = (−3, −4): you get −1, opposite directions. (Leave both vectors nonzero.)
cos θ between u and v
—
- A linear combination uses only vector addition and scalar multiplication.
- |v| = √(sum of squares); divide by it to get a unit vector.
- u · v = Σ uᵢvᵢ = |u||v| cos θ.
- u · v = 0 means u and v are perpendicular.
- proj_u(v) = [(u · v)/(u · u)] u.
Practice.
|(2, −3, 6)| = ?
(1, 2, 3) · (4, −5, 6) = ?
Find k so that (k, 2) is perpendicular to (3, −6).
The projection of (3, 4) onto the x-axis direction (1, 0) is:
- A(3, 0)
- B(0, 4)
- C(3, 4)
- D(5, 0)
If u · v < 0, the angle between u and v is:
- Aacute
- Bright
- Cobtuse
- Dzero
Practise this lesson, not just read it
In BiliMind the questions above are marked when you answer, the flashcards come back on a schedule, and the rest of Linear Algebra is planned around your week. Free.