Algorithm Search⌘K

Proofs: QR algorithm

These are the human proofs of QR algorithm, at full length.

The Hessenberg QR algorithm terminates and returns a Schur form of a nearby matrix full

This proof shows: correctness, termination.

Notation of the page. Indices are 1-based. The steps of lines L8 and L9 are analysed in exact arithmetic; the rounding errors of a computed rotation are of order uu relative to the rows and columns it touches, and their accumulation into a backward error O(u)∥A∥O(u) \|A\| is the classical analysis of Wilkinson (1965, Chapter 3 and Chapter 8) and GVL Section 5.1 and Section 7.5, which we do not repeat. What we prove is that the structure is kept, that the deflations perturb AA by a bounded amount, that the loop terminates, that a CONVERGED result is a Schur form, and why the shifts give fast local convergence.

Lemma 1 (one step keeps Hessenberg form). Let WW be an unreduced upper Hessenberg m×mm \times m matrix and μ\mu a scalar. Let G1,…,Gm−1G_1, \dots, G_{m-1} be the rotations of line L8, where GiG_i acts in the plane (i,i+1)(i, i+1) and is chosen so that Gm−1∗⋯G1∗(W−μI)=RG_{m-1}^* \cdots G_1^* (W - \mu I) = R is upper triangular. Then RG1⋯Gm−1+μIR G_1 \cdots G_{m-1} + \mu I is upper Hessenberg, and it equals G∗WGG^* W G with G=G1⋯Gm−1G = G_1 \cdots G_{m-1} unitary.

Proof. Induction on the left rotations: before Gi∗G_i^* is applied, rows 1..i−11..i-1 are already triangular and the only nonzero entry below the diagonal in column ii is the original wi+1,iw_{i+1,i} (rows ii and i+1i+1 have zeros in columns <i< i, by the previous rotation and by the Hessenberg form). So Gi∗G_i^* can zero it, which is how it is chosen, and it does not touch columns <i< i. After all left rotations, RR is upper triangular. For the right rotations, multiplying a matrix whose column i+1i+1 has nonzeros only in rows ≤i+1\le i + 1 by GiG_i on the right mixes columns ii and i+1i+1, so it creates a nonzero only in position (i+1,i)(i+1, i). Applying G1,…,Gm−1G_1, \dots, G_{m-1} in order fills exactly the first subdiagonal, so RGR G is Hessenberg. Finally RG+μI=G∗(W−μI)G+μI=G∗WGR G + \mu I = G^*(W - \mu I) G + \mu I = G^* W G. □\square

Lemma 1 also shows that restricting the left rotations to columns i..ni..n and the right rotations to rows 1..i+11..i+1 (line L9 uses 1..i+21..i+2, which only adds zeros) computes the full products exactly.

Lemma 2 (the invariant). At every execution of line L3, QQ is unitary, HH is upper Hessenberg, hlo′,lo′−1=0h_{lo', lo'-1} = 0 for every row lo′lo' at which an entry was set to zero, hi+1,i=0h_{i+1,i} = 0 for all i≥hii \ge hi, and

QHQ∗=A+E,∥E∥2≤∑t∣ηt∣,Q H Q^* = A + E, \qquad \|E\|_2 \le \sum_t |\eta_t|,

where ηt\eta_t are the values that line L4 replaced by zero.

Proof. After line L1, QHQ∗=AQ H Q^* = A with E=0E = 0 (Hessenberg reduction is a unitary similarity). Line L4 replaces HH by H−η elel−1TH - \eta \, e_l e_{l-1}^T, which changes QHQ∗Q H Q^* by −η Qelel−1TQ∗-\eta \, Q e_l e_{l-1}^T Q^*, a matrix of 2-norm ∣η∣|\eta|; this adds a term to EE and keeps the Hessenberg form. A step of lines L8 and L9 acts on rows and columns lo..hilo..hi only, by the unitary G~=diag⁡(Ilo−1,G,In−hi)\tilde G = \operatorname{diag}(I_{lo-1}, G, I_{n-hi}). Because hlo,lo−1=0h_{lo,lo-1} = 0 and hhi+1,hi=0h_{hi+1,hi} = 0, HH is block upper triangular with the window as its middle diagonal block, so G~∗HG~\tilde G^* H \tilde G is block upper triangular with the same outer diagonal blocks, its middle block is G∗WGG^* W G, which is Hessenberg by Lemma 1, and the zero blocks below the diagonal stay zero. Replacing QQ by QG~Q \tilde G keeps QHQ∗Q H Q^* and the unitarity of QQ. The zero entries hl,l−1h_{l,l-1} outside the current window lie in a row or a column the step does not touch. □\square

Lemma 3 (the size of the deflation perturbation). Each zeroed value satisfies ∣η∣≤u(∣hl−1,l−1∣+∣hl,l∣)≤2 u ∥H∥F|\eta| \le u(|h_{l-1,l-1}| + |h_{l,l}|) \le \sqrt 2 \, u \, \|H\|_F, at most n−1n - 1 values are nonzero, and so ∥E∥2≤2(n−1)u (∥A∥F+∥E∥F)\|E\|_2 \le \sqrt 2 (n - 1) u \, (\|A\|_F + \|E\|_F), which gives ∥E∥2=O(nu)∥A∥F\|E\|_2 = O(n u) \|A\|_F when nun u is small. If both diagonal entries are zero, the implementation uses the threshold u∥H1∥Fu \|H_1\|_F, where H1H_1 is the Hessenberg matrix of line L1, and the same bound holds.

Proof. The first inequality is the test of line L4, and ∣x∣+∣y∣≤2(∣x∣2+∣y∣2)1/2|x| + |y| \le \sqrt 2 (|x|^2 + |y|^2)^{1/2}. By Lemma 2, an entry hl,l−1h_{l,l-1} that has been set to zero is never changed again, so each of the n−1n - 1 subdiagonal positions contributes at most once a nonzero η\eta. Since HH is unitarily similar to A+EA + E, ∥H∥F=∥A+E∥F≤∥A∥F+∥E∥F\|H\|_F = \|A + E\|_F \le \|A\|_F + \|E\|_F. □\square

Theorem 4 (termination). For every input, the loop of line L3 ends after at most n(maxit+1)n (\mathrm{maxit} + 1) passes.

Proof. Each pass through the loop body either executes line L5, which lowers hihi by one and resets itsits to 0, or reaches line L6, which raises itsits by one and returns once its>maxitits > \mathrm{maxit}. So the pair (hi,−its)(hi, -its) decreases in the lexicographic order at each pass, hihi takes at most nn values, and for each value of hihi at most maxit+1\mathrm{maxit} + 1 passes raise itsits. □\square

Theorem 5 (a CONVERGED result is a Schur form). If line L10 returns, then T=HT = H is upper triangular, QQ is unitary, and QTQ∗=A+EQ T Q^* = A + E with EE as in Lemmas 2 and 3. In particular the diagonal entries of TT are the eigenvalues of A+EA + E.

Proof. Line L10 is reached with hi=1hi = 1. The value of hihi only decreases at line L5, when lo=hilo = hi, and that happens only when line L4 has found l=hil = hi, that is, set hhi,hi−1=0h_{hi, hi-1} = 0. So every subdiagonal entry hi,i−1h_{i, i-1} for i=2,…,ni = 2, \dots, n has been set to zero, and by Lemma 2 it has stayed zero. A Hessenberg matrix with zero subdiagonal is upper triangular. □\square

Proposition 6 (unshifted QR is subspace iteration). With μ=0\mu = 0 at every step and no deflation, let A0=HA_0 = H, Ak−1=QkRkA_{k-1} = Q_k R_k and Ak=RkQkA_k = R_k Q_k. Put Q^k=Q1⋯Qk\hat Q_k = Q_1 \cdots Q_k and R^k=Rk⋯R1\hat R_k = R_k \cdots R_1. Then Ak=Q^k∗A0Q^kA_k = \hat Q_k^* A_0 \hat Q_k and A0k=Q^kR^kA_0^k = \hat Q_k \hat R_k. With shifts μ1,…,μk\mu_1, \dots, \mu_k, the same argument gives ∏i=1k(A0−μiI)=Q^kR^k\prod_{i=1}^k (A_0 - \mu_i I) = \hat Q_k \hat R_k.

Proof. Ak=RkQk=Qk∗Ak−1QkA_k = R_k Q_k = Q_k^* A_{k-1} Q_k, which gives the first claim by induction. For the second, A0k=A0⋅A0k−1=A0Q^k−1R^k−1=Q^k−1Ak−1R^k−1=Q^k−1QkRkR^k−1=Q^kR^kA_0^k = A_0 \cdot A_0^{k-1} = A_0 \hat Q_{k-1} \hat R_{k-1} = \hat Q_{k-1} A_{k-1} \hat R_{k-1} = \hat Q_{k-1} Q_k R_k \hat R_{k-1} = \hat Q_k \hat R_k, using the first claim in the form A0Q^k−1=Q^k−1Ak−1A_0 \hat Q_{k-1} = \hat Q_{k-1} A_{k-1}. The shifted case is the same computation with A0−μkIA_0 - \mu_k I in place of A0A_0 at step kk. □\square

So the first jj columns of Q^k\hat Q_k are an orthonormal basis of A0kA_0^k applied to span⁡{e1,…,ej}\operatorname{span}\{e_1, \dots, e_j\}, which is subspace iteration. If ∣λj∣>∣λj+1∣|\lambda_j| > |\lambda_{j+1}| and the start subspace is not deficient, the subspace converges to the invariant subspace of the jj largest eigenvalues at the rate ∣λj+1/λj∣|\lambda_{j+1}/\lambda_j| (GVL Section 7.3), and the block (Ak)j+1:n,1:j(A_k)_{j+1:n, 1:j}, which is the single entry hj+1,jh_{j+1,j} for a Hessenberg matrix, goes to zero at that rate.

Proposition 7 (shifted QR is inverse iteration on the last column). If H−μI=QRH - \mu I = Q R is nonsingular, then (H−μI)−∗en=Qen/rˉnn(H - \mu I)^{-*} e_n = Q e_n / \bar r_{nn}.

Proof. (H−μI)−∗=(QR)−∗=QR−∗(H - \mu I)^{-*} = (Q R)^{-*} = Q R^{-*}, and R−∗R^{-*} is lower triangular with last diagonal entry 1/rˉnn1 / \bar r_{nn}, so R−∗en=en/rˉnnR^{-*} e_n = e_n / \bar r_{nn}. □\square

The new last row of HH is en∗Q∗HQe_n^* Q^* H Q, and its diagonal entry qn∗Hqnq_n^* H q_n is the Rayleigh quotient of qnq_n. With the Rayleigh shift μ=hnn\mu = h_{nn} the step is therefore one step of Rayleigh quotient iteration for H∗H^* from ene_n, which explains the quadratic and, for Hermitian HH, cubic local rates.

Proposition 8 (the exact 2×22 \times 2 step). Let H=(abϵd)H = \begin{pmatrix} a & b \\ \epsilon & d \end{pmatrix} with ϵ≠0\epsilon \ne 0 and μ=d\mu = d. Then one step gives ∣h21′∣=∣ϵ∣2∣b∣/(∣a−d∣2+∣ϵ∣2)|h'_{21}| = |\epsilon|^2 |b| / (|a - d|^2 + |\epsilon|^2).

Proof. Let α=a−d\alpha = a - d and r=(∣α∣2+∣ϵ∣2)1/2>0r = (|\alpha|^2 + |\epsilon|^2)^{1/2} > 0. The rotation of line L8 has c=∣α∣/rc = |\alpha| / r and s=ϕϵˉ/rs = \phi \bar\epsilon / r with ∣ϕ∣=1|\phi| = 1 (for α=0\alpha = 0, c=0c = 0 and ∣s∣=1|s| = 1). Its second row (−sˉ,c)(-\bar s, c) applied to the columns of H−dI=(αbϵ0)H - d I = \begin{pmatrix} \alpha & b \\ \epsilon & 0 \end{pmatrix} gives the second row of RR as (0,−sˉb)(0, -\bar s b). Applying the right rotation of line L9, the new (2,1)(2, 1) entry is sˉ⋅(−sˉb)=−sˉ2b\bar s \cdot (-\bar s b) = -\bar s^2 b, of modulus ∣s∣2∣b∣=∣ϵ∣2∣b∣/r2|s|^2 |b| = |\epsilon|^2 |b| / r^2. Adding μ\mu back changes only the diagonal. □\square

So if a≠da \ne d the next subdiagonal entry is O(∣ϵ∣2)O(|\epsilon|^2), and if ∣b∣=∣ϵ∣|b| = |\epsilon|, as for a Hermitian HH, it is O(∣ϵ∣3)O(|\epsilon|^3). For a larger Hessenberg matrix, GVL Section 7.5.3 derives the same quadratic behaviour of hn,n−1h_{n,n-1} with the Rayleigh shift, under the assumption that the trailing entries have settled.

Remark (no global theorem). Propositions 6 to 8 are local statements. The cyclic permutation matrix is a fixed point of the step with μ=0\mu = 0, the Rayleigh shift and the Wilkinson shift, so no global convergence theorem holds for these shifts on general matrices; exceptional shifts break this example but are not known to give a provable bound. For symmetric tridiagonal matrices with the Wilkinson shift, Wilkinson (1968) proved convergence for every input. ■\blacksquare

Back to QR algorithm