Vector Projection Formula
The projection of vector a onto vector b is found by scaling b according to how aligned a is with it. The scaling factor comes from the dot product, normalised by the magnitude squared of b.
projb(a) = (a · b / b · b) × b
In component form:
Projection factor = (a₁b₁ + a₂b₂ + ... + aₙbₙ) / (b₁² + b₂² + ... + bₙ²)
proj = factor × b
a— The vector being projectedb— The vector onto which a is projecteda · b— Dot product (scalar product) of vectors a and bb · b— Dot product of b with itself; equals the squared magnitude of b
Understanding the Derivation
The projection formula emerges from decomposing vector a into two parts: one parallel to b (the projection) and one perpendicular to it (the rejection).
- Start with the decomposition: a = proj + ort, where ort is orthogonal to b
- Express proj as a scalar multiple: proj = C × b, where C is the unknown factor
- Eliminate the rejection: Taking the dot product of both sides with b yields C × (b · b) = a · b, because (ort · b) = 0
- Solve for C: C = (a · b) / (b · b)
This scalar C represents how far along the direction of b the projection reaches.
Worked Example: 2D Projection
Project vector a = [3, 4] onto b = [1, 1].
- Dot product a · b: 3(1) + 4(1) = 7
- Dot product b · b: 1² + 1² = 2
- Projection factor: 7 / 2 = 3.5
- Projection vector: 3.5 × [1, 1] = [3.5, 3.5]
The projection is 3.5 times the unit direction of b, or equivalently, [3, 4] has a component of length 7 / √2 ≈ 4.95 along the direction of [1, 1].
Common Pitfalls and Caveats
Be aware of these common mistakes when computing or interpreting vector projections.
- Division by zero when b is the zero vector — If <strong>b</strong> = [0, 0] or [0, 0, 0], the denominator (b · b) becomes zero and the projection is undefined. Always verify that <strong>b</strong> is non-zero before calculating.
- Confusing projection with length of projection — The scalar factor (a · b) / (b · b) is not the same as the length of the projection. The length is |(a · b)| / |b|. The factor is the coefficient that scales <strong>b</strong> itself.
- Order matters for the sign — Projecting <strong>a</strong> onto <strong>b</strong> differs from projecting <strong>b</strong> onto <strong>a</strong>. A negative projection factor means <strong>a</strong> points partly in the opposite direction to <strong>b</strong>. Reversing the roles changes both the factor and the result.
- Dimensional mismatch between vectors — Both vectors must have the same number of dimensions. A 2D vector cannot be projected onto a 3D vector or vice versa without explicit padding or dimension reduction.
Applications in Physics and Data Science
Physics—Force decomposition: A cart on an incline experiences gravity. Its weight can be decomposed into a component along the slope (causing it to roll) and a component perpendicular (pressing into the surface). Vector projection quantifies each component, helping engineers design appropriate counterforces or friction requirements.
Data science—Linear regression and dimensionality reduction: In regression, projecting data onto a fitted line or plane yields predicted values. Principal component analysis projects high-dimensional data onto axes of maximum variance, enabling visualisation and noise reduction with minimal information loss. The projection factor determines how much of each data point aligns with the dominant direction.