Linear Algebra

Least Squares Solution (Ax ≈ b)

Find the least-squares solution x̂ = (AᵀA)⁻¹Aᵀb when Ax = b is inconsistent (overdetermined system).

Inputs
Matrix A (m×2)
Vector b (m×1)
AᵀA (2×2)
—
Aᵀb (2×1)
—
x̂ = (AᵀA)⁻¹Aᵀb
—
‖r‖² = ‖b − Ax̂‖²
—

Data Points & Best-Fit Line

Step-by-Step Work