All lessons

Inner products and projection

Length and angle are extra structure, not part of independence alone.

Prerequisites: 07 · Independence: when a choice adds something, 09 · Rank and the information that disappears

Understand

Objectives

  • Derive the projection coefficient from perpendicular residual.
  • Compute a projection and verify its residual dot product.
  • Reject a zero direction or a nonorthogonal projection in the Euclidean nearest-point claim.

Start with something you can see

Draw u=(2,1) and the line through b=(1,1) and the origin. Predict the nearest point on that line to u. A right-angle drop gives p=(1.5,1.5), leaving residual (0.5,−0.5). It is not enough merely to land on the line: the error must be perpendicular to it. The MIT projection excerpt begins with this perpendicular error at 0:26. [1]

Give the idea a precise name

For vectors a and b in real Euclidean space, the dot product a·b sums their coordinate products; a·a is the square of its Euclidean length. Orthogonality means a·b=0; it is a different question from linear independence. To project a vector v onto the line spanned by a nonzero direction u, write the candidate as cu and require the residual v−cu to be perpendicular to u. Solving u·(v−cu)=0 gives the orthogonal-projection theorem:

projᵤ(v) = [(u·v)/(u·u)]u

The symbol projᵤ(v) is the point on the line nearest to v in Euclidean distance; u·v is a scalar, and u·u is positive because u≠0. The residual is perpendicular because u·(v−projᵤ(v))=0. This perpendicularity proves nearest distance: for any other line point cu, the squared distance is the squared residual length plus the squared distance along the line.

Work one small world

For v=(3,1) and u=(1,2), the dot products are u·v=5 and u·u=5, so the coefficient is 1. The projection is (1,2) and the residual is (2,−1); (1,2)·(2,−1)=0. For the opening sketch, b·(u−p)=(1,1)·(0.5,−0.5)=0.

Vector to projectLine directionProjectionResidualDot check
(2,1)(1,1)(1.5,1.5)(0.5,−0.5)0
(3,1)(1,2)(1,2)(2,−1)0

Counterexample to “every projection is nearest-point projection”: P(x,y)=(x+y,0) lands on the horizontal axis and satisfies P(P(v))=P(v), but P(0,1)=(1,0) is farther from (0,1) than (0,0) is. Its residual is not perpendicular to the axis. With u=(0,0), the displayed line-direction formula divides by zero; projection onto the zero subspace is separately the zero vector.

THE BRIDGEChanging from a Euclidean inner product to an indefinite bilinear form changes which length and inequality claims remain valid.
WHERE THIS IDEA STOPSThe nearest-point theorem requires a positive-definite Euclidean inner product and nonzero direction. Orthogonality does not follow from independence alone.

Experiment

Use the projection lab’s Initial vectors u=(2,1), b=(1,1) and calculate p=(1.5,1.5). Scale b by 2 and compare p; try Zero direction · invalid, then Nonorthogonal example. Read the residual dot product and distance in the numeric result.

Could two configurations have exactly the same independent sets but different angles?

Open the interactive experiment

Check & explain

  1. Project v=(4,3) onto u=(1,2). What is the second coordinate of the projection?

  2. What is the orthogonal projection of v=(3,6) onto the line in direction u=(0,4)?

    1. (0,6)
    2. (3,0)
    3. (0,0)

Teach back

Derive the coefficient for v=(3,1) and u=(1,2) from the perpendicular-error equation, then compare with the nonorthogonal P(x,y)=(x+y,0).

  • Name the Euclidean dot product and require nonzero direction.
  • Verify the residual is orthogonal.
  • Give a concrete closer point than P(0,1).

Read deeper

Interactive Linear Algebra

Dan Margalit & Joseph Rabinoff · Georgia Tech · Open textbook

Read §6.1 for dot products and §6.3 for orthogonal projection and residual.

Open the source

Mathematics for Machine Learning

Deisenroth, Faisal & Ong · Freely readable textbook

Read §§3.2, 3.4 and 3.8, printed pp.72, 76 and 81, for inner products, orthogonality and projections.

Open the source

15. Projections onto Subspaces

Gilbert Strang · MIT OpenCourseWare · Lecture excerpt · 0:26–20:00 of 49 min

Start at 0:26. Watch the short core 0:26–4:26; then the longer passage 0:26–20:00.

Open the source

Open the interactive lesson