Skip to content
Infinitesimal Dynamics home
Notebook: 0 XP

Linear Algebra / Structure and decomposition

Projections and Least Squares

When a system has no solution, find the closest one. This is how lines are fitted to data.

3 min read · 2 sections · 1 checks

Contents 3 sections
  1. §1The normal equations
  2. §2Fitting a line
  3. ?Check yourself

By the end you can

  • Project a vector onto a subspace
  • Derive and solve the normal equations
  • Fit a line to data

Helps to know: Inner Products and Orthogonality, Subspaces, Rank and Nullity

§1The normal equations

If Ax=bA\mathbf{x} = \mathbf{b} is inconsistent, choose x^\hat{\mathbf{x}} so that the error b−Ax^\mathbf{b} - A\hat{\mathbf{x}} is perpendicular to every column of AA:

ATA x^=ATbA^{\mathsf T}A\,\hat{\mathbf{x}} = A^{\mathsf T}\mathbf{b}

Then Ax^A\hat{\mathbf{x}} is the projection of b\mathbf{b} onto the column space: the nearest reachable point.

§2Fitting a line

Example 1Best line through (0,1)(0,1), (1,2)(1,2), (2,4)(2,4)

  1. Model y=c+mxy = c + mx: rows (1,xi)(1, x_i), right side yiy_i.

Check yourself

  1. Q1
    In least squares, the residual b−Ax^\mathbf{b} - A\hat{\mathbf{x}} is orthogonal to…