Skip to main content

Least Squares

  • Situation: Fitting an inconsistent system
  • Learning targets: Least squares · Normal equations · Uniqueness
  • Convention: Declared field ℝ or ℂ; column vectors; rightmost matrix first; dimensionless data unless units stated · Finite-dimensional inner product spaces; first slot linear, second conjugate-linear; standard inner product for numerical examples

Core concepts​

  • Least squares: minimize ‖Ax−b‖²; fitted output as orthogonal projection onto range A
A target vector outside a plane with its orthogonal projection onto the plane and a perpendicular residual
Figure 1. Fitting an inconsistent system
  • Normal equations: A*(b−Ax̂)=0 ⇔ AAx̂=Ab; valid also with dependent columns

  • Uniqueness: fitted output always unique; coefficients unique exactly for full column rank; then x̂=(AA)⁻¹Ab

  • Conditioning: full-column-rank A giving κ₂(A*A)=κ₂(A)²; QR/SVD avoiding explicit normal-equation formation in sensitive computations

Worked example​

u=(1,1,0)T,v=(1,0,1)T,U={(x,y,z)T:x−y−z=0},e3=(0,0,1)Tu=(1,1,0)^T,\quad v=(1,0,1)^T,\quad U=\{(x,y,z)^T:x-y-z=0\},\quad e_3=(0,0,1)^T b=(2,0,1)T,n=(1,−1,−1)T,C=[u v],H=CTC=[2112]b=(2,0,1)^T,\quad n=(1,-1,-1)^T,\quad C=[u\ v],\quad H=C^TC=\begin{bmatrix}2&1\\1&2\end{bmatrix} q1=u/2,q2=(1,−1,2)T/6,Q0=[q1 q2],P=I−nnT/3q_1=u/\sqrt2,\quad q_2=(1,-1,2)^T/\sqrt6,\quad Q_0=[q_1\ q_2],\quad P=I-nn^T/3 C=[111001],CTC=[2112],CTb=[23],x^=[1/34/3]C=\begin{bmatrix}1&1\\1&0\\0&1\end{bmatrix},\quad C^TC=\begin{bmatrix}2&1\\1&2\end{bmatrix},\quad C^Tb=\begin{bmatrix}2\\3\end{bmatrix},\quad\widehat x=\begin{bmatrix}1/3\\4/3\end{bmatrix}

Practice​

  • Preparation: Paper or calculator; example inputs and ordered bases; exercise cases below as the calculation dataset
  • Prediction: Result, dimensions and applicable conditions before calculation
  • Calculation: First two exercises by hand → substitution into defining equations → exact and rounded checks separately
  • Record: Assumed inputs and calculated results; no physical measurements; optional software output recorded separately
  • Next step: Inputs, basis order and checked identities retained for the next chapter
CasePredictionExact result and reasonSoftware check
Cx^,∥b−Cx^∥2C\widehat x,\quad\Vert b-C\widehat x\Vert ^2
CT(b−Cx^)C^T(b-C\widehat x)
  • Optional extension: One changed input or removed hypothesis → recalculation → comparison of the conclusion

Exercises​

  1. Problem: Cx^,∥b−Cx^∥2C\widehat x,\quad\|b-C\widehat x\|^2
  2. Problem: CT(b−Cx^)C^T(b-C\widehat x)
  3. Problem: Line y=c₀+c₁t through data (0,1),(1,2),(2,2): least-squares coefficients
Answers and checks
  1. Answer: (5,1,4)T/3,1/3(5,1,4)^T/3,\quad1/3
  2. Answer: (0,0)T(0,0)^T
  3. Answer: [3335][c0c1]=[56]⇒(c0,c1)=(7/6,1/2)\begin{bmatrix}3&3\\3&5\end{bmatrix}\begin{bmatrix}c_0\\c_1\end{bmatrix}=\begin{bmatrix}5\\6\end{bmatrix}\Rightarrow(c_0,c_1)=(7/6,1/2)

Connections​