Linear Algebra Advanced

Least Squares Solver (Ax = b)

Solve Ax = b via QR factorization with Householder reflectors — handles exact square systems and overdetermined least-squares problems step by step.

Exact & overdetermined systems
Householder QR decomposition
Live
Enter the system [A | b]
Augmented matrix [A | b] — the gold column is b
QR Factorization & Least Squares
QRx = b → Rx = Qᵀb → solve by back-substitution

Any matrix A can be factored as A = QR where Q is orthogonal (Qᵀ = Q⁻¹) and R is upper triangular. To solve Ax = b, substitute and back-substitute through the triangular system.

For overdetermined systems (more equations than unknowns), no exact solution exists. QR finds the least-squares solution x̂ that minimizes ‖Ax − b‖₂ — the best approximate fit.

Least squares is everywhere — linear regression, curve fitting, GPS positioning. The normal equations AᵀAx = Aᵀb give the same answer but QR is numerically more stable.
When To Use QR / Least Squares
  • Solving square systems Ax = b exactly
  • Overdetermined systems with no exact solution
  • Linear regression (fitting a line to data)
  • Numerically stable matrix inversion
  • Foundation for SVD and PCA

QR making sense but SVD still mysterious?

One-on-one linear algebra tutoring — from least squares through singular value decomposition, PCA, and numerical methods.

Book a Free Consultation →