Vector Math
Dot product, cross product, magnitude, angle, and projections.
Number
Counts
About this topic
Vector Addition & Subtraction Combine vectors component-by-component.
Adding vectors places them head-to-tail — the resultant goes from the start of the first to the tip of the last. Subtraction gives the vector pointing from one to the other.
Key formulas & rules
- •u + v = (u₁+v₁, u₂+v₂, u₃+v₃)
- •u − v = (u₁−v₁, u₂−v₂, u₃−v₃)
- •Commutative: u + v = v + u
- •Associative: (u+v)+w = u+(v+w)
- •Geometrically forms a parallelogram
- •Result magnitude ≤ |u| + |v| (triangle inequality)
Examples
| Input | Output | Note |
|---|---|---|
| (3,4) + (1,2) | (4,6) | Add components |
| (3,4) − (1,2) | (2,2) | Subtract components |
| (1,0) + (0,1) | (1,1) | Perpendicular vectors |
| (2,2) − (2,2) | (0,0) | Equal vectors cancel |
Real-world uses
Dot Product (u · v) A scalar that measures alignment of two vectors.
The dot product combines two vectors into a single number. It tells you whether vectors point in similar directions, are perpendicular, or opposite.
Key formulas & rules
- •Algebraic: u·v = u₁v₁ + u₂v₂ + u₃v₃
- •Geometric: u·v = |u||v|cos θ
- •Commutative: u·v = v·u
- •If u·v = 0 → perpendicular (orthogonal)
- •If u·v > 0 → angle is acute (< 90°)
- •If u·v < 0 → angle is obtuse (> 90°)
Examples
| Input | Output | Note |
|---|---|---|
| (3,4) · (1,2) | 11 | 3×1 + 4×2 = 11 |
| (1,0) · (0,1) | 0 | Perpendicular |
| (2,3) · (2,3) | 13 | |u|² = 4+9 |
| (1,1) · (−1,1) | 0 | 90° angle |
Real-world uses
Cross Product (u × v) A vector perpendicular to both inputs (3D only).
The cross product takes two 3D vectors and produces a third vector that is perpendicular to both. Its magnitude equals the area of the parallelogram spanned by u and v.
Key formulas & rules
- •Formula: u × v = (u₂v₃−u₃v₂, u₃v₁−u₁v₃, u₁v₂−u₂v₁)
- •Result is perpendicular to both u and v
- •Anti-commutative: u × v = −(v × u)
- •|u × v| = |u||v|sin θ = area of parallelogram
- •If u × v = 0 → u and v are parallel
- •Only defined in 3D (and 7D in special cases)
Examples
| Input | Output | Note |
|---|---|---|
| (1,0,0) × (0,1,0) | (0,0,1) | x̂ × ŷ = ẑ |
| (0,1,0) × (1,0,0) | (0,0,−1) | Order matters! |
| (1,1,0) × (1,1,0) | (0,0,0) | Parallel vectors |
| (2,0,0) × (0,3,0) | (0,0,6) | Area = 6 |
Real-world uses
Magnitude (|u|) The length of a vector — its distance from origin.
The magnitude is the Euclidean length of the vector. It generalizes the Pythagorean theorem to any number of dimensions.
Key formulas & rules
- •2D: |u| = √(u₁² + u₂²)
- •3D: |u| = √(u₁² + u₂² + u₃²)
- •Always non-negative: |u| ≥ 0
- •|u| = 0 if and only if u is the zero vector
- •Unit vector: û = u / |u| (length 1)
- •Triangle inequality: |u+v| ≤ |u| + |v|
Examples
| Input | Output | Note |
|---|---|---|
| u = (3,4) | 5 | 3-4-5 triangle |
| u = (1,1) | 1.4142 | √2 |
| u = (0,0,5) | 5 | Along z-axis |
| u = (1,2,2) | 3 | √(1+4+4) = 3 |
Real-world uses
Angle & Projection Angle between vectors and projection of one onto another.
The angle between vectors tells you how aligned they are. The projection of u onto v is the 'shadow' of u cast along the direction of v.
Key formulas & rules
- •cos θ = (u·v) / (|u||v|)
- •θ ranges from 0° to 180°
- •Projection scalar: comp_v(u) = (u·v) / |v|
- •Projection vector: proj_v(u) = ((u·v) / |v|²) · v
- •Residual u − proj_v(u) is perpendicular to v
- •θ = 0° → parallel; θ = 90° → perpendicular
Examples
| Input | Output | Note |
|---|---|---|
| (1,0) ↔ (1,1) | 45° | Halfway |
| (1,0) ↔ (0,1) | 90° | Perpendicular |
| (1,0) ↔ (−1,0) | 180° | Opposite |
| (3,4) ↔ (1,2) | 10.30° | Mostly aligned |
Real-world uses
Unit Vectors & Normalization Scale a vector to have length 1 while keeping direction.
A unit vector has magnitude 1 and preserves the original direction. Any non-zero vector can be normalized by dividing by its magnitude.
Key formulas & rules
- •û = u / |u|
- •|û| = 1 by construction
- •Standard basis: î = (1,0), ĵ = (0,1), k̂ = (0,0,1)
- •Unit vector encodes direction only, not magnitude
- •Two vectors are parallel if they share the same unit vector
- •Cannot normalize the zero vector
Examples
| Input | Output | Note |
|---|---|---|
| u = (3,4) | (0.6, 0.8) | Divide by 5 |
| u = (1,0) | (1, 0) | Already unit |
| u = (0,5,0) | (0, 1, 0) | Along y-axis |
| u = (1,1,1) | (0.577, 0.577, 0.577) | Divide by √3 |
Real-world uses
Modes & formulas
Addition
Vector addition is commutative and associative. Geometrically, it forms the diagonal of the parallelogram spanned by u and v.
Dot Product
u·v = 0 means perpendicular. u·v > 0 means acute angle. u·v < 0 means obtuse angle.
Cross Product
The cross product is anti-commutative. Its direction follows the right-hand rule. If u × v = 0, the vectors are parallel.
Magnitude
The magnitude is always non-negative. A magnitude of 0 means the zero vector.
Angle
The angle is only defined when neither vector has zero magnitude.