Orthogonal Projection Calculator

JJ Ben-Joseph headshot JJ Ben-Joseph

Orthogonal projection onto a subspace: what this calculator does

This calculator computes the orthogonal projection of a vector vR3 onto a subspace spanned by up to three basis vectors. It also lets you see the connection to the standard projection matrix formula used in linear algebra, least squares, and numerical methods.

You enter the components of v and up to three basis vectors b1,b2,b3. The tool then:

This is useful for visualizing projections in R3, checking homework, and understanding how least squares and Gram–Schmidt orthogonalization work under the hood.

How orthogonal projection works (formulas)

Let S be a subspace of R3 spanned by linearly independent vectors b1,,bk with 1k3. Stack these basis vectors as columns in a matrix

A=[b1 b2  bk],A3×k.

The orthogonal projection matrix onto the column space of A is

P=A(ATA)1AT.

Here:

At the vector level, you can also think of the projection as follows. We look for coefficients ck such that

p=Ac

is the closest vector in the subspace to v in the Euclidean norm. Solving the normal equations

ATAc=ATv

gives

c=(ATA-1ATv,,p=Ac=A(ATA-1ATv.

In MathML form, the projection matrix formula can be written as:

P = A ( AT A -1 ) AT

The matrix P has two key properties that characterize orthogonal projection:

The residual (or error) vector is

r=vp=(IP)v,

and it satisfies rS, meaning it is orthogonal to every vector in the subspace.

Interpreting the results

When you use the calculator, you will typically see at least two key outputs:

Geometrically, the projection p is the point in the subspace that is closest to v in Euclidean distance. The vector vp is perpendicular to the entire subspace, not just to one basis vector.

Numerically, you might also inspect:

If the subspace is a line (one basis vector), the projection is just the component of v along that line. If the subspace is a plane (two independent basis vectors), the projection is the point in the plane obtained by dropping a perpendicular from v to the plane.

Worked example in R3

Consider v=(1,2,3) and the subspace spanned by b1=(1,0,0) and b2=(0,1,0). This subspace is the xy-plane.

The matrix of basis vectors is

A=[b1b2]=100100.

Then

AT A= 1001, (AT A1)= 1001.

The projection matrix is

P=A(AT)(A)-1AT

Applying P to v gives

p=Pv=[100010000][123]=[120].

So the projection of v onto the xy-plane is p=(1,2,0). The orthogonal component is

vp=123120=003,

which points straight along the z-axis. Geometrically, this corresponds to dropping a perpendicular from the point 123 onto the xy-plane.

The calculator reproduces this example if you enter v=(1,2,3), set b1=(1,0,0), b2=(0,1,0), and either leave b3=(0,0,0) or at its default value representing the z-axis.

Comparison: single vector vs. subspace projection

Projecting onto a single vector is a special case of projection onto a subspace. The formulas simplify when there is only one basis vector, but the geometric idea is the same.

Case Setup Projection formula Typical use
Projection onto a single vector Subspace is span of one nonzero vector b. projb(v)=vTbbTbb Decomposing motion along a direction, resolving forces, simple geometry.
Projection onto a subspace Subspace is span of k independent vectors, collected as columns of A. projspan(A)(v)=A(ATA1)ATv Least squares, regression, dimensionality reduction, numerical linear algebra.

This calculator always uses the general subspace formula, so it works for both situations: if you only want to project onto a single direction, just provide one nonzero basis vector and leave the others at zero.

Limitations and assumptions of this calculator

The tool is designed to be simple and numerically stable for common educational and applied use cases. It makes several assumptions you should be aware of:

Being aware of these conditions will help you interpret the output correctly and avoid relying on the tool in cases it is not designed to handle.

Connections and applications

Orthogonal projection is more than a geometric curiosity. It underlies several core techniques:

The same matrix formula implemented by this calculator is used implicitly in these applications, often at a much larger scale. Working with concrete three-dimensional examples can make these abstract ideas more tangible.

Enter the components of the vector to be projected and up to three basis vectors defining the subspace (leave unused basis vectors as zeros). Vectors are assumed to be in R3.

Vector
Basis 1
Basis 2
Basis 3
Enter vector and basis values, then project to view the components.

Embed this calculator

Copy and paste the HTML below to add the Orthogonal Projection onto a Subspace Calculator to your website.