Algorithm Search⌘K

Proofs: QZ algorithm

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

The QZ algorithm keeps an exact unitary equivalence, preserves the Hessenberg-triangular structure, and terminates with a generalized Schur form full

This proof shows: correctness, termination.

Exact arithmetic, except that the entries set to zero by the tests of lines L4 and L6 are tracked as perturbations. Notation of the page: HH, TT, QQ, ZZ are the working matrices, indices run from 11 to nn, ε=2u\varepsilon = 2u, and a rotation is G=(cs−sˉc)G = \begin{pmatrix} c & s \\ -\bar s & c \end{pmatrix} with c≥0c \ge 0 real and c2+∣s∣2=1c^2 + |s|^2 = 1, acting on two rows (from the left) or two columns (from the right). The quadratic convergence of the shifted iteration is not proved here; see the remark at the end.

Lemma 1 (rotations). For any f,gf, g, givens(f, g) returns a unitary GG with G(f,g)T=(r,0)TG (f, g)^T = (r, 0)^T. Consequently: (a) a row rotation of rows i,ji, j built from (f,g)=(mik,mjk)(f, g) = (m_{ik}, m_{jk}) zeroes mjkm_{jk}; (b) a column rotation of columns i,ji, j with the matrix GG built from givens(y, x), where (x,y)=(mki,mkj)(x, y) = (m_{ki}, m_{kj}), maps that row pair to (0,r)(0, r).

Proof. If g=0g = 0, G=IG = I. If f=0f = 0, c=0c = 0, s=1s = 1 and G(0,g)T=(g,0)TG (0, g)^T = (g, 0)^T. Otherwise, with ν=∣f∣2+∣g∣2\nu = \sqrt{|f|^2 + |g|^2} and ϕ=f/∣f∣\phi = f / |f|, c=∣f∣/νc = |f| / \nu and s=ϕgˉ/νs = \phi \bar g / \nu; then c2+∣s∣2=1c^2 + |s|^2 = 1, so GG∗=IG G^* = I, and the second component is −sˉf+cg=−ϕˉgf/ν+∣f∣g/ν=−∣f∣g/ν+∣f∣g/ν=0-\bar s f + c g = -\bar\phi g f / \nu + |f| g / \nu = -|f| g / \nu + |f| g / \nu = 0, using ϕˉf=∣f∣\bar\phi f = |f|. For (b), the new entry in column ii is xc−sˉyx c - \bar s y, which is the second component of G(y,x)TG (y, x)^T, hence zero. □\square

Lemma 2 (the invariant). Let H0=AH_0 = A, T0=BT_0 = B, Q=Z=IQ = Z = I at the start. After any sequence of the operations of the algorithm, QQ and ZZ are unitary and Q∗(A+E)Z=HQ^* (A + E) Z = H, Q∗(B+F)Z=TQ^* (B + F) Z = T, where E=∑τQτ(δτekτekτ−1T)Zτ∗E = \sum_\tau Q_\tau (\delta_\tau e_{k_\tau} e_{k_\tau - 1}^T) Z_\tau^* and F=∑σQσ(γσekσekσT)Zσ∗F = \sum_\sigma Q_\sigma (\gamma_\sigma e_{k_\sigma} e_{k_\sigma}^T) Z_\sigma^* collect the entries δτ\delta_\tau of HH and γσ\gamma_\sigma of TT that lines L4 and L6 set to zero, with Qτ,ZτQ_\tau, Z_\tau the values of Q,ZQ, Z at that moment. Hence ∥E∥F≤∑τ∣δτ∣\|E\|_F \le \sum_\tau |\delta_\tau| and ∥F∥F≤∑σ∣γσ∣\|F\|_F \le \sum_\sigma |\gamma_\sigma|.

Proof. Induction on the operations. A row rotation GG replaces H,T,QH, T, Q by GH,GT,QG∗G H, G T, Q G^*; then (QG∗)∗(A+E)Z=GH(Q G^*)^* (A + E) Z = G H, and QG∗Q G^* is unitary. A column rotation RR replaces H,T,ZH, T, Z by HR,TR,ZRH R, T R, Z R, and Q∗(A+E)(ZR)=HRQ^* (A + E) (Z R) = H R. The assignments to zero of entries that the rotation has just made zero (lines L1, L7, L9, L10) change nothing in exact arithmetic. Setting hk,k−1=δh_{k,k-1} = \delta to zero replaces HH by H−δekek−1T=Q∗(A+E+Qδekek−1TZ∗)ZH - \delta e_k e_{k-1}^T = Q^* (A + E + Q \delta e_k e_{k-1}^T Z^*) Z, which extends EE by one term; likewise for TT. Each term is QτQ_\tau times a matrix of Frobenius norm ∣δτ∣|\delta_\tau| times Zτ∗Z_\tau^*, and unitary factors preserve the Frobenius norm, so the triangle inequality gives the bounds. □\square

Lemma 3 (Hessenberg-triangular reduction). After line L1, TT is upper triangular and HH is upper Hessenberg.

Proof. Phase 1 processes columns j=1,…,n−1j = 1, \dots, n - 1 and, for i=n,…,j+1i = n, \dots, j + 1, rotates rows i−1,ii - 1, i to zero tijt_{ij} (Lemma 1a). Rows i−1,i≥ji - 1, i \ge j have zeros in every column j′<jj' < j already, so these zeros stay; entries ti′jt_{i'j} with i′>ii' > i were zeroed before and are not touched. So at the end TT is upper triangular. Phase 2 processes columns j=1,…,n−2j = 1, \dots, n - 2 and, for i=n,…,j+2i = n, \dots, j + 2: (i) rotates rows i−1,ii - 1, i to zero hijh_{ij}; in columns j′<jj' < j both rows are zero (rows i−1≥j+1>j′+1i - 1 \ge j + 1 > j' + 1, and those columns are already Hessenberg), so they stay zero; in TT, row i−1i - 1 is zero before column i−1i - 1 and row ii before column ii, so the only new nonzero is ti,i−1t_{i,i-1}. (ii) Rotates columns i−1,ii - 1, i to zero ti,i−1t_{i,i-1} (Lemma 1b); rows below ii of TT are zero in both columns, so TT is upper triangular again; in HH the columns i−1,i≥j+1i - 1, i \ge j + 1 are not yet processed and column jj is untouched, so hij=0h_{ij} = 0 and all earlier zeros of HH stay. At the end HH is upper Hessenberg. □\square

Lemma 4 (the window). Suppose HH is Hessenberg, TT triangular, hlo,lo−1=0h_{lo,lo-1} = 0 (or lo=1lo = 1) and hhi+1,hi=0h_{hi+1,hi} = 0 (or hi=nhi = n). Then any rotation of two rows or two columns with indices in [lo,hi][lo, hi] leaves hlo,lo−1h_{lo,lo-1}, hhi+1,hih_{hi+1,hi} and every entry of HH and TT in rows >hi> hi and columns <lo< lo unchanged and zero.

Proof. A row rotation in [lo,hi][lo, hi] changes only rows in [lo,hi][lo, hi]; in columns <lo< lo these rows of HH and TT are zero (Hessenberg with hlo,lo−1=0h_{lo,lo-1} = 0, and triangular), and a rotation of two zeros gives zeros. A column rotation in [lo,hi][lo, hi] changes only columns in [lo,hi][lo, hi]; in rows >hi> hi these columns are zero, by hhi+1,hi=0h_{hi+1,hi} = 0 and the structure. □\square

Lemma 5 (the QZ step keeps the structure). If before line L9 HH is Hessenberg, TT is triangular with nonzero diagonal on [lo,hi][lo, hi], and hlo,lo−1=0h_{lo,lo-1} = 0, hhi+1,hi=0h_{hi+1,hi} = 0 (where they exist), then after line L10 the same holds, with the same zero subdiagonal entries outside (lo,hi](lo, hi].

Proof. By Lemma 4 the entries outside the window keep their zeros. Line L9 rotates rows lo,lo+1lo, lo + 1. In HH both rows are zero before column lolo (hlo,lo−1=0h_{lo,lo-1} = 0), so HH stays Hessenberg; in TT the only new nonzero is tlo+1,lot_{lo+1,lo}. We claim: before iteration kk of line L10, HH is Hessenberg and TT is triangular except for the entry (k+1,k)(k + 1, k). This holds for k=lok = lo. In iteration kk, the column rotation of columns k,k+1k, k + 1 zeroes tk+1,kt_{k+1,k} (Lemma 1b); the rows below k+1k + 1 of TT are zero in both columns, so TT is triangular. In HH, the rows below k+2k + 2 are zero in both columns, so the only possible new nonzero is hk+2,kh_{k+2,k}, and only if k+2≤hik + 2 \le hi (otherwise hk+2,k+1=hhi+1,hi=0h_{k+2,k+1} = h_{hi+1,hi} = 0 and hk+2,kh_{k+2,k} stays zero). If k+2≤hik + 2 \le hi, the row rotation of rows k+1,k+2k + 1, k + 2 zeroes hk+2,kh_{k+2,k} (Lemma 1a); in columns <k< k both rows of HH are zero, so HH is Hessenberg again; in TT, both rows are zero in columns ≤k\le k (because tk+1,kt_{k+1,k} was just zeroed), so the only new nonzero is tk+2,k+1t_{k+2,k+1}. This is the claim for k+1k + 1. After the last iteration k=hi−1k = hi - 1, TT is triangular and HH Hessenberg. □\square

Lemma 6 (deflation of an infinite eigenvalue). If at line L7 tkk=0t_{kk} = 0 for some k∈[lo,hi]k \in [lo, hi], then after the chase and the final rotation of rows lo,lo+1lo, lo + 1, HH is Hessenberg, TT is triangular, tlo,lo=0t_{lo,lo} = 0 and hlo+1,lo=0h_{lo+1,lo} = 0.

Proof. We show by downward induction on j=k,k−1,…,loj = k, k - 1, \dots, lo that HH is Hessenberg, TT triangular and tjj=0t_{jj} = 0. For j=kj = k this is the hypothesis. Going from jj to j−1j - 1: the column rotation of columns j−1,jj - 1, j maps (tj−1,j−1,tj−1,j)(t_{j-1,j-1}, t_{j-1,j}) to (0,r)(0, r) (Lemma 1b). Row jj of TT is zero in both columns (tj,j−1=0t_{j,j-1} = 0 and tjj=0t_{jj} = 0), and so are all rows below; so TT stays triangular, tjjt_{jj} stays 00, and now tj−1,j−1=0t_{j-1,j-1} = 0. In HH, the only possible new nonzero is hj+1,j−1h_{j+1,j-1}, when j+1≤hij + 1 \le hi. Then the row rotation of rows j,j+1j, j + 1 zeroes it (Lemma 1a); in columns <j−1< j - 1 both rows of HH are zero, so HH is Hessenberg; in TT, both rows are zero in columns ≤j\le j (as tjj=tj+1,j=0t_{jj} = t_{j+1,j} = 0), so TT stays triangular. At j=loj = lo, the rotation of rows lo,lo+1lo, lo + 1 zeroes hlo+1,loh_{lo+1,lo} (Lemma 1a). In HH, both rows are zero before column lolo, so HH stays Hessenberg; in TT, both rows are zero in column lolo (tlo,lo=0t_{lo,lo} = 0, tlo+1,lo=0t_{lo+1,lo} = 0) and before it, so TT stays triangular and tlo,lot_{lo,lo} stays 00. □\square

Theorem 7 (correctness and termination). The algorithm terminates. When it returns with converged true, S=HS = H and TT are upper triangular, QQ and ZZ are unitary, and Q∗(A+E)Z=SQ^* (A + E) Z = S, Q∗(B+F)Z=TQ^* (B + F) Z = T with ∥E∥F≤2(n−1)εmax⁡τ∥Hτ∥F\|E\|_F \le 2 (n - 1) \varepsilon \max_\tau \|H_\tau\|_F and ∥F∥F≤n(n−1)ε∥B∥F\|F\|_F \le n (n - 1) \varepsilon \|B\|_F, where HτH_\tau are the intermediate matrices, so ∥E∥F≤2(n−1)ε∥A∥F(1+O(nε))\|E\|_F \le 2 (n - 1) \varepsilon \|A\|_F (1 + O(n \varepsilon)). The generalized eigenvalues of the pencil (A+E,B+F)(A + E, B + F) are the pairs (sii,tii)(s_{ii}, t_{ii}).

Proof. Structure. Lemma 3 gives the structure after line L1. Lines L4 and L6 only set entries to zero, which keeps it. Lemma 6 keeps it at line L7, and Lemma 5 at lines L9 and L10, whose hypotheses hold because line L7 is reached only after all tkkt_{kk}, lo≤k≤hilo \le k \le hi, have been tested, and line L9 only when they are all nonzero.

Zero subdiagonal entries stay zero. All rotations act on indices inside a window [lo,hi][lo, hi] bounded by zero subdiagonal entries or the ends, so by Lemma 4 a zero hk,k−1h_{k,k-1} is never changed again. Inside the window all subdiagonal entries are nonzero by the choice of lolo.

Termination. Let NN be the number of nonzero entries hk,k−1h_{k,k-1} with 2≤k≤hi2 \le k \le hi, and consider Φ=N+hi\Phi = N + hi. Line L4 does not increase Φ\Phi. Line L5 decreases hihi by one, and the entry hhi,hi−1h_{hi,hi-1} it drops is zero, so Φ\Phi drops by one. Line L7 makes the nonzero hlo+1,loh_{lo+1,lo} zero (it is nonzero by the choice of lolo, and lo+1≤hilo + 1 \le hi because hhi,hi−1≠0h_{hi,hi-1} \ne 0), so NN and Φ\Phi drop by one. A QZ step leaves Φ\Phi unchanged and increases the step counter, which is capped. So the number of passes through the loop is at most 2n2n plus the cap, and each pass is finite.

Triangular result. If the loop ends with converged true, then hi=1hi = 1, and hihi was decreased from each value mm only when hm,m−1=0h_{m,m-1} = 0; these zeros persist, so HH is upper triangular. TT is upper triangular by the structure argument.

Backward error. By Lemma 2, ∥E∥F≤∑τ∣δτ∣\|E\|_F \le \sum_\tau |\delta_\tau|. Each subdiagonal position is set to zero at most once (it stays zero afterwards and the test only acts on nonzero entries), so there are at most n−1n - 1 terms, and each satisfies ∣δτ∣≤ε(∣hk−1,k−1∣+∣hkk∣)≤2ε∥Hτ∥F|\delta_\tau| \le \varepsilon (|h_{k-1,k-1}| + |h_{kk}|) \le 2 \varepsilon \|H_\tau\|_F, or ∣δτ∣≤ε∥A∥F|\delta_\tau| \le \varepsilon \|A\|_F when both diagonal entries are zero. Each diagonal entry of TT set to zero satisfies ∣γσ∣≤ε∥B∥F|\gamma_\sigma| \le \varepsilon \|B\|_F, and the test of line L6 is applied to at most nn entries in each pass that leads to line L7; by the termination argument there are at most n−1n - 1 such passes, so at most n(n−1)n (n - 1) terms. Finally ∥Hτ∥F=∥A+Eτ∥F\|H_\tau\|_F = \|A + E_\tau\|_F by unitary invariance, which gives the first-order bound. The last statement holds because det⁡((A+E)−λ(B+F))=det⁡(Q)det⁡(S−λT)det⁡(Z∗)=det⁡(QZ∗)∏i(sii−λtii)\det((A + E) - \lambda (B + F)) = \det(Q) \det(S - \lambda T) \det(Z^*) = \det(Q Z^*) \prod_i (s_{ii} - \lambda t_{ii}). □\square

Remark (what is cited, not proved). That one QZ step equals one step of the shifted QR algorithm on HT−1H T^{-1} and on T−1HT^{-1} H (when TT is nonsingular) follows from the implicit Q theorem; see GVL Section 7.7 and Watkins and Elsner (1994). It gives the quadratic local convergence of hhi,hi−1h_{hi,hi-1} for a simple eigenvalue with the shift of line L8; the tests measure it. There is no proof that every pencil converges within the cap, which is why the implementation reports converged. Backward stability in floating point, ∥E∥2=O(u∥A∥2)\|E\|_2 = O(u \|A\|_2) and ∥F∥2=O(u∥B∥2)\|F\|_2 = O(u \|B\|_2) including rounding, is due to Moler and Stewart (1973); the tests observe it.

Back to QZ algorithm