🎓 Linear Algebra 📊 Statistics / PCA 💻 Machine Learning 🔩 Engineering

Vector Projection Calculator

Project vector A onto vector B and decompose A into its parallel component (projection) and perpendicular component. Supports 2D–4D with full steps.

Quick Answer
proj_B(A) = (A·B / |B|²) × B · Perpendicular = A − proj_B(A) · Together they decompose A = proj + perp, where proj ⊥ perp.

Projecting vector A onto vector B

Vector A (to project)

x
y
z

Vector B (project onto)

x
y
z

How Vector Projection Works

Think of shining a light straight down onto vector B — the shadow of A on B is the projection. It's the "shadow" or "component" of A in the direction of B.

The key identity: A = proj_B(A) + perp where proj_B(A) is parallel to B and perp is perpendicular to B. These two components are orthogonal (perpendicular) to each other.

Applications

  • Gram-Schmidt: Each step subtracts projections to make vectors orthogonal — the foundation of QR decomposition.
  • Least Squares Regression: The fitted values ŷ = X(XᵀX)⁻¹Xᵀy are the projection of y onto the column space of X.
  • PCA / Dimensionality Reduction: Principal components are directions that maximize variance; projecting data onto them gives the reduced representation.
  • Physics — Inclined Planes: Decomposing gravity into components along and perpendicular to an inclined plane uses vector projection.

Frequently Asked Questions

Does the order matter? Is proj_A(B) = proj_B(A)?

No — they are different in general. proj_B(A) projects A onto the direction of B, giving a result parallel to B. proj_A(B) projects B onto the direction of A, giving a result parallel to A. They have the same scalar magnitude (A·B/|B| = A·B/|A| only when |A|=|B|=1), but different directions.

What happens when A and B are perpendicular?

When A ⊥ B, the dot product A·B = 0, so proj_B(A) = (0/|B|²)×B = 0. The projection is the zero vector — meaning A has no component along B. The entire A vector is the perpendicular component. This is used to verify orthogonality: if the projection is zero, the vectors are perpendicular.