Algorithm Search⌘K

Proofs: Normal equations

These are the human proofs of Normal equations, at full length.

The normal equations method returns the least squares solution, and its forward error is of order u kappa_2(A)^2 full

This proof shows: correctness, termination.

A∈Rm×nA \in \mathbb{R}^{m \times n} has m≥nm \ge n and full column rank, and b∈Rmb \in \mathbb{R}^m. Every loop of the algorithm has a fixed length, so it stops.

Exact arithmetic

Claim 1. xx minimizes ∥b−Ax∥2\|b - A x\|_2 if and only if ATAx=ATbA^T A x = A^T b, and the minimizer is unique.

Proof. Let r=b−Axr = b - A x. For each y∈Rny \in \mathbb{R}^n,

∥b−A(x+y)∥22=(r−Ay)T(r−Ay)=∥r∥22−2yTATr+∥Ay∥22.\|b - A(x + y)\|_2^2 = (r - A y)^T (r - A y) = \|r\|_2^2 - 2 y^T A^T r + \|A y\|_2^2.

If ATr=0A^T r = 0, the right side is ∥r∥22+∥Ay∥22≥∥r∥22\|r\|_2^2 + \|A y\|_2^2 \ge \|r\|_2^2, with equality only when Ay=0A y = 0, that is y=0y = 0 because the columns of AA are independent. So xx is the unique minimizer. If ATr≠0A^T r \ne 0, take y=tATry = t A^T r with t>0t > 0 small: the right side is ∥r∥22−2t∥ATr∥22+t2∥AATr∥22<∥r∥22\|r\|_2^2 - 2t\|A^T r\|_2^2 + t^2 \|A A^T r\|_2^2 < \|r\|_2^2, so xx is not a minimizer. □\square

Claim 2. C=ATAC = A^T A is symmetric positive definite, so line L3 succeeds and returns an upper triangular RR with positive diagonal and RTR=CR^T R = C.

Proof. CT=ATA=CC^T = A^T A = C, and vTCv=∥Av∥22>0v^T C v = \|A v\|_2^2 > 0 for v≠0v \ne 0. The column Cholesky algorithm computes, for j=1,…,nj = 1, \ldots, n, rjj=(cjj−∑k<jrkj2)1/2r_{jj} = (c_{jj} - \sum_{k<j} r_{kj}^2)^{1/2} and rji=(cji−∑k<jrkjrki)/rjjr_{ji} = (c_{ji} - \sum_{k<j} r_{kj} r_{ki})/r_{jj} for i>ji > j. By induction on jj, the first j−1j - 1 rows of RR satisfy the first j−1j - 1 rows of RTR=CR^T R = C, and the pivot cjj−∑k<jrkj2c_{jj} - \sum_{k<j} r_{kj}^2 equals the Schur complement sjs_j of the leading (j−1)×(j−1)(j-1) \times (j-1) block in the leading j×jj \times j block of CC. That block is positive definite, so det⁡\det of it is the product of the positive leading pivots times sjs_j, and sj>0s_j > 0. So no pivot is ≤0\le 0 and the square roots are real and positive. □\square

Theorem. NORMAL-EQUATIONS returns the least squares solution.

Proof. Lines L4 and L5 solve RTy=dR^T y = d and Rx=yR x = y, which are possible because the diagonal of RR is positive. Then Cx=RTRx=RTy=dC x = R^T R x = R^T y = d, so ATAx=ATbA^T A x = A^T b, and by Claim 1 xx is the unique minimizer. ■\blacksquare

Floating point

Assume the standard model with unit roundoff uu and mu<1m u < 1. Write ∥⋅∥\| \cdot \| for the 2-norm.

Step 1: forming CC and dd. Each c^ij\hat c_{ij} is an inner product of length mm, so ∣c^ij−cij∣≤γm∑k∣aki∣∣akj∣|\hat c_{ij} - c_{ij}| \le \gamma_m \sum_k |a_{ki}||a_{kj}| (Higham, Section 3.1). Hence C^=C+E1\hat C = C + E_1 with ∣E1∣≤γm∣A∣T∣A∣|E_1| \le \gamma_m |A|^T |A|, and in the same way d^=d+f\hat d = d + f with ∣f∣≤γm∣A∣T∣b∣|f| \le \gamma_m |A|^T |b|. For a nonnegative matrix the 2-norm is monotone in the entries, and ∥∣A∣∥≤∥A∥F≤n∥A∥\| |A| \| \le \|A\|_F \le \sqrt n \|A\|, so

∥E1∥≤nγm∥A∥2,∥f∥≤nγm∥A∥ ∥b∥.\|E_1\| \le n \gamma_m \|A\|^2, \qquad \|f\| \le \sqrt n \gamma_m \|A\|\,\|b\|.

Step 2: the Cholesky solve. If the Cholesky factorization of C^\hat C runs to completion, the computed x^\hat x satisfies (C^+E2)x^=d^(\hat C + E_2)\hat x = \hat d with ∣E2∣≤γ3n+1∣R^T∣∣R^∣|E_2| \le \gamma_{3n+1} |\hat R^T||\hat R| (Higham, Chapter 10). Since ∥∣R^T∣∣R^∣∥≤n∥R^∥2\| |\hat R^T||\hat R| \| \le n \|\hat R\|^2 and ∥R^∥2=∥R^TR^∥≤∥C^∥(1+O(nu))\|\hat R\|^2 = \|\hat R^T \hat R\| \le \|\hat C\|(1 + O(n u)), this gives ∥E2∥≤cnu∥C∥+O(u2)\|E_2\| \le c_n u \|C\| + O(u^2) with cn=O(n2)c_n = O(n^2).

Step 3: perturbation. So (C+E)x^=d+f(C + E)\hat x = d + f with E=E1+E2E = E_1 + E_2, ∥E∥≤ϵ1∥A∥2\|E\| \le \epsilon_1 \|A\|^2, ϵ1=(nm+cn)u+O(u2)\epsilon_1 = (n m + c_n) u + O(u^2), using ∥C∥=∥A∥2\|C\| = \|A\|^2. Subtracting Cx=dC x = d gives C(x^−x)=f−Ex^C(\hat x - x) = f - E\hat x, and ∥C−1∥=1/σn2\|C^{-1}\| = 1/\sigma_n^2, so

∥x^−x∥≤1σn2(ϵ1∥A∥2∥x^∥+nγm∥A∥ ∥b∥),∥x^−x∥∥x^∥≤κ2(A)2(ϵ1+nγm∥b∥∥A∥ ∥x^∥).\|\hat x - x\| \le \frac{1}{\sigma_n^2}\bigl(\epsilon_1 \|A\|^2 \|\hat x\| + \sqrt n \gamma_m \|A\|\,\|b\|\bigr), \qquad \frac{\|\hat x - x\|}{\|\hat x\|} \le \kappa_2(A)^2 \left(\epsilon_1 + \sqrt n \gamma_m \frac{\|b\|}{\|A\|\,\|\hat x\|}\right).

The bound is in terms of ∥x^∥\|\hat x\|; if the right side is below 1/21/2, then ∥x^∥≤2∥x∥\|\hat x\| \le 2\|x\| and the same bound holds relative to ∥x∥\|x\| with an extra factor 22. This is the bound stated on the page, with cm,n=O(mn+n2)c_{m,n} = O(m n + n^2). ■\blacksquare

Termination of Cholesky. If C^\hat C is positive definite, the column algorithm completes in floating point whenever cn′u κ2(C^)<1c'_n u\, \kappa_2(\hat C) < 1 for a modest cn′c'_n (Higham, Chapter 10). When κ2(A)2u\kappa_2(A)^2 u is of order one this can fail, and the implementation then raises NotFullRank instead of returning a value.

What the tests check. The tests compare x^\hat x with the exact rational least squares solution and assert ∥x^−x∥∞/∥x∥∞≤4(m+n)nu κ1(ATA)(1+∥b∥1/(∥A∥1∥x∥∞))\|\hat x - x\|_\infty/\|x\|_\infty \le 4(m+n) n u\, \kappa_1(A^T A)(1 + \|b\|_1/(\|A\|_1\|x\|_\infty)), which has the form of Step 3 with the 1-norm quantities, computed exactly, in place of the 2-norm ones; κ2(A)2=κ2(ATA)≤κ1(ATA)\kappa_2(A)^2 = \kappa_2(A^T A) \le \kappa_1(A^T A) for the symmetric matrix ATAA^T A.

Back to Normal equations