Skip to content
Glacius
Linear algebraConcept reference

Projection onto a subspace

Projection onto a subspace with an orthonormal basis is the sum of each basis vector multiplied by its dot product with the input vector.

On this page 8 sections
  1. Overview
  2. Projection onto a subspace fits a target using several allowed directions together
  3. Use the supplied orthonormal basis u=(3/5,4/5,0), w=(0,0,1) and v=(5,0,2)
  4. With v=(2,3,4) and basis (1,0,0),(0,1,0), the projection is p=(2,3,0)
  5. The simple sum of dot-product contributions assumes orthonormal directions
  6. Key takeaway
  7. Sources & further reading
  8. Concept connections

01Projection onto a subspace fits a target using several allowed directions together#

Projection onto a subspace fits a target using several allowed directions together. When those directions are orthonormal, each dot product measures one independent coordinate, so we can fit their contributions separately and add them.

The target might be a list of measurements and the directions might be patterns your model can produce. The projected vector is the best fit inside their span. The residual is the part that these patterns cannot reproduce.

For orthonormal basis q1=(1,0,0)q_1=(1,0,0), q2=(0,1,0)q_2=(0,1,0), projecting v=(2,3,4)v=(2,3,4) retains (2,3,0)(2,3,0). Add the two line projections.

Oblique 3D view of S=span(e₁,e₂), the xy plane. The vector v=(2,3,4) reaches above S; its projection p=(2,3,0) lies in S. The residual r=v−p=(0,0,4) joins p to v and is perpendicular to every vector in S. The small corner denotes this 3D right angle; projected screen angles and lengths are not measurements.Oblique 3D view of S=span(e₁,e₂), the xy plane. The vector v=(2,3,4) reaches above S; its projection p=(2,3,0) lies in S. The residual r=v−p=(0,0,4) joins p to v and is perpendicular to every vector in S. The small corner denotes this 3D right angle; projected screen angles and lengths are not measurements.
Figure 1Oblique 3D view of S=span(e₁,e₂), the xy plane. The vector v=(2,3,4) reaches above S; its projection p=(2,3,0) lies in S. The residual r=v−p=(0,0,4) joins p to v and is perpendicular to every vector in S. The small corner denotes this 3D right angle; projected screen angles and lengths are not measurements.
Link to this figure ↗Download SVGDownload PNG

For an orthonormal basis q1,q2q_1,q_2, take coefficients c1=vq1c_1=v\cdot q_1 and c2=vq2c_2=v\cdot q_2. Each denominator qiqiq_i\cdot q_i is 11.

p=c1q1+c2q2p=c_1q_1+c_2q_2

For more basis vectors, add one such term per vector.

With orthonormal directions q1=(1,0,0)q_1=(1,0,0) and q2=(0,1,0)q_2=(0,1,0), target b=(2,3,4)b=(2,3,4) has coordinates 2 and 3. Rebuild the projection as 2q1+3q2=(2,3,0)2q_1+3q_2=(2,3,0). The residual (0,0,4)(0,0,4) is perpendicular to both directions. Reporting (2,3)(2,3) alone would report internal coordinates, not the three-entry projected vector.

Check your reasoning

Orthonormal basis u=(1,0,0)u=(1,0,0), w=(0,1,0)w=(0,1,0). Project v=(3,2,5)v=(3,-2,5).

  1. A(3,2,0)(3,2,0)
  2. B(3,2,0)(3,-2,0)
  3. C(0,0,5)(0,0,5)
Show answer and explanation
(3,2,0)(3,-2,0)

Add 3u2w3u-2w.

02Use the supplied orthonormal basis u=(3/5,4/5,0), w=(0,0,1) and v=(5,0,2)#

Use the supplied orthonormal basis u=(3/5,4/5,0)u=(3/5,4/5,0), w=(0,0,1)w=(0,0,1) and v=(5,0,2)v=(5,0,2). The first coefficient is 5(3/5)+0(4/5)=35(3/5)+0(4/5)=3. The second is vw=2v\cdot w=2.

cu=3,cw=2c_u=3,\qquad c_w=2

For u=(3/5,4/5,0)u=(3/5,4/5,0) and w=(0,0,1)w=(0,0,1), coefficients 3,23,2 give 3u=(9/5,12/5,0)3u=(9/5,12/5,0) and 2w=(0,0,2)2w=(0,0,2).

p=(9/5,12/5,2)p=(9/5,12/5,2)

The pair (3,2)(3,2) contains weights. The projection has three coordinates.

Check your reasoning

Orthonormal basis u=(1,0,0)u=(1,0,0), w=(0,0,1)w=(0,0,-1). For v=(2,4,3)v=(2,4,3), a learner uses coefficient 33 on ww. Repair that coefficient.

Show answer and explanation
-3

vw=3v\cdot w=-3.

03With v=(2,3,4) and basis (1,0,0),(0,1,0), the projection is p=(2,3,0)#

With v=(2,3,4)v=(2,3,4) and basis (1,0,0),(0,1,0)(1,0,0),(0,1,0), the projection is p=(2,3,0)p=(2,3,0). The residual vp=(0,0,4)v-p=(0,0,4) has dot product zero with both basis vectors.

A vector already in the span stays unchanged. A vector perpendicular to every basis vector projects to zero.

Check your reasoning

Unit modes u=(1,0,0)u=(1,0,0), w=(0,0,1)w=(0,0,1) are orthogonal. Dot readings are 2-2 for uu, 44 for ww. Retained vector?

  1. A(2,4,0)(-2,4,0)
  2. B(2,0,4)(2,0,4)
  3. C(2,0,4)(-2,0,4)
Show answer and explanation
(2,0,4)(-2,0,4)

Add 2u+4w-2u+4w.

04The simple sum of dot-product contributions assumes orthonormal directions#

The simple sum of dot-product contributions assumes orthonormal directions. For a general set of independent columns, first obtain suitable orthonormal directions or solve the appropriate least-squares system. Otherwise overlapping contributions can be counted twice.

Key takeaway

Take each dot product, weight its basis vector, and add all contributions.

  • Project a vector using a supplied orthonormal basis.

Sources & further reading

  1. [1]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Projection onto a subspace.” Math behind ML. /learn/la-space-projection