Member-only story
Math Explained to Programmers — Householder QR Decomposition
Refactor by Reflection — One API at a Time
Understanding Householder Reflection with Developer Language
Householder QR decomposition elegantly factors matrices into a product of an orthogonal matrix (Q) and an upper triangular matrix (R).
Given a matrix A, the decomposition is:
A = QR
We construct Q as a product of reflection matrices (Hᵢ):
Q = H₁H₂...Hₖ
And R is then obtained by applying these reflections in reverse order to the original matrix A:
R = Hₖ...H₂H₁A
Each Householder matrix Hᵢ is like a refactoring step where you set up a clean interface (an API boundary) to isolate and improve one part without disturbing the whole system.
Unlike Gram-Schmidt (which builds modules incrementally), Householder strategically places “mirrors” (to us developers: clear API boundaries) to restructure your monolithic system into well-separated components.
The Mirror Principle: How Householder Reflections Work
Mathematically, a Householder reflection matrix (H) is defined as:
H = I - 2vvᵀ / (vᵀv)
- v: a vector perpendicular (normal) to the “reflection mirror.”
- I: identity matrix (represents…