Orthogonal Projection Calculator

Project vectors onto one, two, or more bases. See matrix solution, residual vector, and norm. Download a clean report for class or work use.

Calculator

Choose 2–5 coordinates per vector.
k must be ≤ d for a spanning set.
What this solves
Projects v onto span(b₁,…,bₖ) and returns the closest point in that subspace.

Input vector v

Basis vectors

b1
Provide 3 coordinates.
Reset

Formula used

Let v ∈ ℝᵈ and let B = [b₁ … bₖ] be the d×k matrix whose columns are the basis vectors. The orthogonal projection of v onto span(B) is:

c = (BᵀB)⁻¹ Bᵀ v
proj(v) = B c
residual = v − proj(v)
distance = ‖residual‖₂

When k = 1, this reduces to the classic scalar projection: proj(v onto b) = (v·b / b·b) b. For k ≥ 2, the calculator uses the matrix form above (least-squares projection).

How to use this calculator

  1. Select the vector dimension d (2–5).
  2. Choose how many basis vectors k you want (≤ d).
  3. Enter the coordinates of the input vector v.
  4. Enter each basis vector b₁…bₖ. Avoid dependent vectors.
  5. Press Submit to see projection, residual, distance, and coefficients.
  6. Use CSV/PDF export buttons to download the latest result.

Example data table

Case Dimension v Basis (columns) Projection Residual Distance
Line 2 [3, 4] b₁=[1, 1] [3.5, 3.5] [-0.5, 0.5] 0.707107
Plane 3 [2, 1, 3] b₁=[1,0,0], b₂=[0,1,0] [2, 1, 0] [0, 0, 3] 3.000000
Subspace 3 [1, 2, 3] b₁=[1,1,0], b₂=[0,1,1] [0.666667, 1.666667, 1.666667] [0.333333, 0.333333, 1.333333] 1.414214
Tip: If exports fail, compute once first to store a result.

Where orthogonal projection is used

Orthogonal projection turns a vector into its closest representative inside a chosen subspace. In graphics, it maps points to a line or plane for constraints and camera math. In data science, it isolates signal directions, such as removing a trend component. In engineering, it helps compare measurements against a model space.

Inputs and practical ranges

This calculator accepts dimensions from 2 to 5 and up to 5 basis vectors, with k ≤ d. Choose k=1 for a single direction, or larger k for a line, plane, or higher-dimensional span. For stable results, basis vectors should not be near-collinear and should avoid extremely large magnitude differences.

What the output numbers mean

The projection is the point in the subspace closest to v. The residual is the part left over, orthogonal to the span when the basis is independent. The distance equals ‖v − proj(v)‖₂ and measures how far v sits from the subspace. The coefficients show the linear combination of basis vectors that builds the projection.

Why the matrix method matters

With multiple basis vectors, direct “component-by-component” projection fails unless the basis is orthonormal. The calculator uses B(BᵀB)⁻¹Bᵀv, which matches the least-squares solution and produces the same result as solving the normal equations. If BᵀB is not invertible, it indicates dependent vectors and the tool asks you to revise the basis.

Workflow tips for reliable checks

Start by testing simple bases like standard unit vectors to confirm expected behavior. Then move to your real basis and confirm the residual direction: its dot product with each basis vector should be close to zero after rounding. Export CSV for spreadsheets and PDF for quick sharing, keeping a consistent dimension and basis set across comparisons.

FAQs

1) What is an orthogonal projection in simple terms?

It is the closest point to your vector that lies inside the chosen line, plane, or subspace. The difference between the vector and that point is the residual.

2) Do the basis vectors need to be orthonormal?

No. The calculator supports any independent basis. If vectors are not orthonormal, it uses the normal-equation matrix formula to compute the projection correctly.

3) Why do I get a rank-deficient warning?

It means the basis vectors are dependent or nearly dependent, so BᵀB cannot be inverted reliably. Replace a repeated vector or choose a more independent spanning set.

4) What do the coefficients represent?

They are the weights c in proj(v)=Bc. Each coefficient shows how much of a basis vector contributes to the projected point.

5) How can I quickly validate the result?

Compute the residual and check its dot product with each basis vector. For a valid orthogonal projection, these dot products should be approximately zero within rounding tolerance.

6) When should I use k=1 versus k>1?

Use k=1 to project onto a single direction (a line). Use k>1 to project onto a plane or higher-dimensional subspace spanned by multiple vectors.

Related Calculators

Row Reduction RREF CalculatorDiagonalization Checker CalculatorLU Decomposition Steps CalculatorQR Decomposition Steps Calculatormatrix calculator with variablesGauss-Jordan inverse calculatorPolynomial linear independence calculatorLinear independence of matrix calculatorComplex matrix inverse calculatorQR decomposition least squares

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.