Definition
The least squares problem seeks to minimize the residual error , where:

  • is a matrix with ,
  • is a given vector,
  • is the unknown vector to solve for.

This arises when the system is overdetermined (more equations than unknowns), and no exact solution exists. The solution is:
Intuition
The least squares solution minimizes the Euclidean distance between and the column space of . It projects onto the subspace spanned by the columns of , yielding the best approximation of that lies in the range of .

Key Properties

  1. Normal Equations:
    The least squares solution satisfies:

  2. Existence and Uniqueness:

    • A unique solution exists if is invertible (i.e., has full column rank).
    • If is not full rank, the solution is not unique, and the pseudoinverse is used.
  3. Orthogonality Condition:
    The residual is orthogonal to the column space of :

    Methods to Solve

  4. QR factorization:

    • Compute , where is orthogonal and is upper triangular. Solve:
  5. Normal Equations:

    • Solve directly.
    • This method is computationally less stable compared to QR or SVD.
  6. Singular Value Decomposition (SVD):

    • Decompose , where is diagonal. Solve using:

      where is the pseudoinverse of .
  7. Iterative Methods:

  8. Nearly Singular Matrix:

Applications

  1. Data Fitting:

    • Fit a model to data points by minimizing the sum of squared errors (e.g., linear regression).
  2. Signal processing:

    • Denoise signals or approximate functions using least squares.
  3. Control Systems:

    • Estimate system parameters in system identification.
  4. Computer Vision:

    • Solve problems like camera calibration and 3D reconstruction.
  5. Optimization:

    • Forms the basis for solving constrained optimization problems (e.g., quadratic programming).

Examples

  1. Simple Linear Regression:
    Fit a line to data points by solving the least squares problem:

    Solve for .

  2. Overdetermined System:
    Solve where:

    Using the normal equations:

    Solve to find .