Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture...

31
Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November 29, 2019 1 / 31

Transcript of Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture...

Page 1: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

Lecture 12: QR algorithm

November 29, 2019

Numerical Linear Algebra Lecture 12 November 29, 2019 1 / 31

Page 2: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

1. Simultaneous iteration (SI)

Sometimes also called subspace iteration or orthogonal iteration orblock power iteration

Algorithm 1: Simultaneous iteration

Pick Q(0)n ∈ Cm×n with orthonormal columns

for k = 1, 2, 3, . . . ,

Z(k) = AQ(k−1)n

Q(k)n R

(k)n = Z(k) (QR factorization)

end

Here is an informal analysis of this method. Assume A = SΛS−1

is diagonalizable with Λ = diag{λ1, λ2, · · · , λm} and

|λ1| ≥ · · · ≥ |λn| > |λn+1| ≥ · · · ≥ |λm|.

Numerical Linear Algebra Lecture 12 November 29, 2019 2 / 31

Page 3: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

We have

SΛkS−1Q(0)n = λk

nSdiag

{(λ1

λn

)k

, · · · , 1, · · · ,(λm

λn

)k}S−1Q(0)

n .

Let [X

(k)n

X(k)c

]:= diag

{(λ1

λn

)k

, · · · , 1, · · · ,(λm

λn

)k}S−1Q(0)

n .

Since

∣∣∣∣ λi

λn

∣∣∣∣ ≥ 1 if i ≤ n, and

∣∣∣∣ λi

λn

∣∣∣∣ < 1 if i > n, we get X(k)c

approaches zero like

∣∣∣∣λn+1

λn

∣∣∣∣k, and X(k)n does not approach zero.

Numerical Linear Algebra Lecture 12 November 29, 2019 3 / 31

Page 4: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

Indeed, if X(0)n :=

[In 0

]S−1Q

(0)n has full rank (a generalization

of the assumption α1 ̸= 0 in power iteration), then X(k)n will have

full rank too. We can prove (the proof is left as an exercise)

span{Q(k)n } = span{AkQ(0)

n }.

Here, span{·} = range(·). Write S =[Sn Sc

]. Then

SΛkS−1Q(0)n = λk

n(SnX(k)n + ScX

(k)c ).

Thus span{Q(k)n } converges to

span{Q(k)n } = span{AkQ(0)

n } = span{SΛkS−1Q(0)n }

= span{SnX(k)n + ScX

(k)c }

→ span{SnX(k)n } = span{Sn},

the invariant subspace spanned by the first n eigenvectors.

Numerical Linear Algebra Lecture 12 November 29, 2019 4 / 31

Page 5: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

Note that if we follow only the first j < n columns of Q(k)n through

the iterations of the algorithm, they are identical to the columnsthat we would compute if we had started with only the first j

columns of Q(0)n instead of n columns.

In other words, simultaneous iteration is effectively running thealgorithm for j = 1, 2, · · · , n all at the same time.

So if all the first n eigenvalues have distinct absolute values, i.e.,

|λ1| > |λ2| > · · · > |λn|,

and if all the leading principal submatrices of

X(0)n :=

[In 0

]S−1Q(0)

n

have full rank, the same convergence analysis as before implies

that the first j ≤ n columns of Q(k)n converge to span{Sj}.

Numerical Linear Algebra Lecture 12 November 29, 2019 5 / 31

Page 6: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

Theorem 1

Consider running simultaneous iteration on matrix A ∈ Cm×m with

n = m and Q(0)n = I. If A = SΛS−1 is diagonalizable with

Λ = diag{λ1, λ2, · · · , λm}, |λ1| > |λ2| > · · · > |λm|,

and if all the leading principal submatrices of S−1 have full rank, then

A(k) := (Q(k)n )∗AQ

(k)n converges to the Schur form of A. The

eigenvalues will appear in decreasing order of absolute value.

Proof: See Demmel’s book: Theorem 4.8, Page 158, Appliednumerical linear algebra.

The entry A(k)j,j converges to λj like max

(∣∣∣∣λj+1

λj

∣∣∣∣k , ∣∣∣∣ λj

λj−1

∣∣∣∣k).

The block A(k)(j + 1 : m, 1 : j) converges to zero like

∣∣∣∣λj+1

λj

∣∣∣∣k.Numerical Linear Algebra Lecture 12 November 29, 2019 6 / 31

Page 7: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

2. QR algorithm without shifts

Algorithm 2: “Pure” QR algorithm

A(0) = Afor k = 1, 2, 3, . . . ,

Q(k)R(k) = A(k−1) (QR factorization)

A(k) = R(k)Q(k)

end

Proposition 2

We have A(k) = (Q(k))∗AQ(k), where Q(k) := Q(1)Q(2) · · ·Q(k).

Proof.

Note that A(k) = (Q(k))∗A(k−1)Q(k).

Numerical Linear Algebra Lecture 12 November 29, 2019 7 / 31

Page 8: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

Proposition 3

The QR factorization of the kth power of A is given by

Ak = Q(k)R(k),

where Q(k) := Q(1)Q(2) · · ·Q(k), and R(k) := R(k)R(k−1) · · ·R(1).

Proof.

We use induction. For k = 1, A = A(0) = Q(1)R(1) = Q(1)R(1).

Assume Ak−1 = Q(k−1)R(k−1). Then by A(k−1) = (Q(k−1))∗AQ(k−1),we have

Ak = AQ(k−1)R(k−1) = Q(k−1)A(k−1)R(k−1) = Q(k)R(k).

This completes the proof.

Numerical Linear Algebra Lecture 12 November 29, 2019 8 / 31

Page 9: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

Connection with power iteration: By Ak = Q(k)R(k), the first

column of Q(k) is the result of applying k steps of power iterationon A to the vector e1.

Connection with inverse iteration: By Q(k) = (A∗)−k(R(k))∗, the

last column of Q(k) is the result of applying k steps of inverseiteration on A∗ to the vector em.

Theorem 4

If A = SΛS−1 is diagonalizable with

Λ = diag{λ1, λ2, · · · , λm}, |λ1| > |λ2| > · · · > |λm|,

and if all the leading principal submatrices of S−1 have full rank, thenA(k) computed by “pure” QR algorithm converges to the Schur form ofA. The eigenvalues will appear in decreasing order of absolute value.

This theorem is a direct result of the following lemma.

Numerical Linear Algebra Lecture 12 November 29, 2019 9 / 31

Page 10: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

Lemma 5

The A(k) computed by “pure” QR algorithm is identical (we need an

assumption about QR factorization here) to the matrix (Q(k)n )∗AQ

(k)n

implicitly computed by running simultaneous iteration on matrix

A ∈ Cm×m with n = m and Q(0)n = I.

Proof.

We use induction. By Q(1)n = Q(1), we have A(1) = (Q

(1)n )∗AQ

(1)n .

Assume A(k−1) = (Q(k−1)n )∗AQ

(k−1)n . From simultaneous iteration, we

can write AQ(k−1)n = Q

(k)n R

(k)n . Then R

(k)n = (Q

(k)n )∗AQ

(k−1)n , and

A(k−1) = (Q(k−1)n )∗AQ(k−1)

n = (Q(k−1)n )∗Q(k)

n R(k)n = Q(k)R(k).

Thus

A(k) = R(k)Q(k) = (Q(k)n )∗AQ(k−1)

n (Q(k−1)n )∗Q(k)

n = (Q(k)n )∗AQ(k)

n .

This completes the proof.

Numerical Linear Algebra Lecture 12 November 29, 2019 10 / 31

Page 11: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

From earlier analysis, we know that the convergence rate of “pure”QR algorithm depends on the ratios of eigenvalues. To speedconvergence, we can use shift and invert techniques.

3. QR algorithm with shifts

Algorithm 3: QR algorithm with shifts

A(0) = Afor k = 1, 2, 3, . . . ,

Pick a shift µ(k) near an eigenvalue of A

Q(k)R(k) = A(k−1) − µ(k)I (QR factorization)

A(k) = R(k)Q(k) + µ(k)Iend

Proposition 6

We have A(k) = (Q(k))∗AQ(k), where Q(k) := Q(1)Q(2) · · ·Q(k).

Numerical Linear Algebra Lecture 12 November 29, 2019 11 / 31

Page 12: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

Proposition 7

We have the factorization (for k ≥ 1)

(A− µ(k)I)(A− µ(k−1)I) · · · (A− µ(1)I) = Q(k)R(k),

where Q(k) := Q(1)Q(2) · · ·Q(k), and R(k) := R(k)R(k−1) · · ·R(1).

Proof.

We use induction. For k = 1, A− µ(1)I = Q(1)R(1) = Q(1)R(1).

Assume (A− µ(k−1)I)(A− µ(k−2)I) · · · (A− µ(1)I) = Q(k−1)R(k−1).

Then by A(k−1) = (Q(k−1))∗AQ(k−1), we have

(A− µ(k)I) · · · (A− µ(1)I) = (AQ(k−1) − µ(k)Q(k−1))R(k−1)

= (Q(k−1)A(k−1) − µ(k)Q(k−1))R(k−1)

= Q(k−1)(A(k−1) − µ(k)I)R(k−1) = Q(k)R(k).

This completes the proof.

Numerical Linear Algebra Lecture 12 November 29, 2019 12 / 31

Page 13: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

Connection with shifted power iteration: By

(A− µ(k)I)(A− µ(k−1)I) · · · (A− µ(1)I) = Q(k)R(k),

the first column of Q(k) is the result of applying k steps of shifted

power iteration on A− µ(j)I to the vector e1 using the shifts µ(j),j = 1 : k.

Connection with shifted inverse iteration: By

Q(k) = (A− µ(k)I)−∗(A− µ(k−1)I)−∗ · · · (A− µ(1)I)−∗(R(k))∗,

the last column of Q(k) is the result of applying k steps of shifted

inverse iteration on (A− µ(j)I)∗ to the vector em using the shiftsµ(j), j = 1 : k. If the shifts are good eigenvalue estimates, the lastcolumn of Q(k), i.e., Q(k)em, converges quickly to a lefteigenvector of A.

Numerical Linear Algebra Lecture 12 November 29, 2019 13 / 31

Page 14: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

Connection with Rayleigh quotient iteration: Choose

µ(1) = r(em), µ(k+1) = r(Q(k)em),

as the shift at every step. The eigenvalue and eigenvector estimatesµ(k+1) and Q(k)em are identical to those that are computed by theRayleigh quotient iteration on A∗ starting with em.

In the QR algorithm, the Rayleigh quotient r(Q(k)em) appears as

the (m,m) entry of A(k). So it comes for free! Actually, we have

A(k)mm = e∗mA(k)em = e∗m(Q(k))∗AQ(k)em = r(Q(k)em).

Then we can set µ(k+1) = A(k)mm. This is known as the Rayleigh

quotient shift. Q(k)em converges quadratically or cubically to aneigenvector.

Other issues: Wilkinson shift ...

Numerical Linear Algebra Lecture 12 November 29, 2019 14 / 31

Page 15: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

4. Practical issues on QR algorithm

Proposition 8

Hessenberg form is preserved by QR algorithm (we need an assumptionabout the involved QR factorizations).

Proof.

For the upper Hessenberg matrix H(k−1) − µ(k)I, it is easy to show thatthere exists a QR factorization Q(k)R(k) = H(k−1) − µ(k)I such thatQ(k) is upper Hessenberg. Then it is easy to confirm that R(k)Q(k)

remains upper Hessenberg and adding µ(k)I does not change this.

Proposition 9

Hermitian tridiagonal form is preserved by QR algorithm.

Proof.

Hermitian + upper Hessenberg = tridiagonal.

Numerical Linear Algebra Lecture 12 November 29, 2019 15 / 31

Page 16: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

First phase: Reduction to Hessenberg or tridiagonal form

Numerical Linear Algebra Lecture 12 November 29, 2019 16 / 31

Page 17: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

Second phase: generate a sequence of Hessenberg (or tridiagonal)matrices that converge to a triangular (or diagonal) form.

Numerical Linear Algebra Lecture 12 November 29, 2019 17 / 31

Page 18: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

4.1. Implicit Q theorem

Definition 10

An upper Hessenberg matrix H is unreduced if all (j + 1, j) entries ofH are nonzero.

Theorem 11 (Consider the real case. The complex case is similar.)

Let A ∈ Rm×m. Suppose that QTAQ = H is unreduced upperHessenberg and Q is orthogonal. Then columns 2 to m of Q aredetermined uniquely (up to signs) by the first column of Q.

Implicit Q theorem implies that QR algorithm can be implementedcheaply on an upper Hessenberg matrix. The implementation willbe implicit in the sense that we do not explicitly compute the QRfactorization of an upper Hessenberg matrix each iteration butrather construct Q implicitly as a product of Givens rotations andother simple orthogonal/unitary matrices.

Numerical Linear Algebra Lecture 12 November 29, 2019 18 / 31

Page 19: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

Proof. (Implicit Q theorem).

Suppose that QTAQ = H and VTAV = G are unreduced upperHessenberg, Q and V are orthogonal, and the first columns of Q andV are equal. Let (X)i denote the ith column of X. Let W ≡ VTQ. ByGW = GVTQ = VTAQ = VTQH = WH, we have

G(W)i = W(H)i =∑i+1

j=1hji(W)j .

Thus, hi+1,i(W)i+1 = G(W)i −∑i

j=1 hji(W)j . Since (W)1 = e1 andG is upper Hessenberg, we can use induction on i to show that (W)i isnonzero in entries 1 to i only; i.e., W is upper triangular. Since W isalso orthogonal, then W is diagonal: W = diag{1,±1, · · · ,±1}, whichimplies

Vdiag{1,±1, · · · ,±1} = Q.

Numerical Linear Algebra Lecture 12 November 29, 2019 19 / 31

Page 20: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

4.2. Implicit single shift QR algorithm

To compute H(k) = (Q(k))TH(k−1)Q(k) from H(k−1) in the QRalgorithm, we will need only to

(1) compute the first column of Q(k) (which is parallel to the firstcolumn of H(k−1) − µ(k)I and so can be gotten just by normalizingthis column vector).

(2) choose other columns of Q(k) so Q(k) is orthogonal and H(k) isunreduced Hessenberg.

By the implicit Q theorem, we know that we will have computedH(k) correctly because Q(k) is unique up to signs, which do notmatter. (Signs do not matter because changing the signs of thecolumns of Q(k) is the same as changing H(k−1) − µ(k)I = Q(k)R(k)

to (Q(k)S(k))(S(k)R(k)), where S(k) = diag{±1,±1, · · · ,±1}. ThenH(k) = (S(k)R(k))(Q(k)S(k)) + µ(k)I = S(k)(R(k)Q(k) + µ(k)I)S(k),which is an orthogonal similarity that just changes the signs ofsome columns and rows of H(k).)

Numerical Linear Algebra Lecture 12 November 29, 2019 20 / 31

Page 21: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

To see how to use the implicit Q theorem to compute H(1) fromH(0) = H, we use a 5× 5 example.

1. QT1 =

c1 s1−s1 c1

11

1

, H1 = QT1 HQ1 =

× × × × ×× × × × ×+ × × × ×0 0 × × ×0 0 0 × ×

2. QT2 =

1

c2 s2−s2 c2

11

, QT2 H1 =

× × × × ×× × × × ×0 × × × ×0 0 × × ×0 0 0 × ×

H2 = QT2 H1Q2 =

× × × × ×× × × × ×0 × × × ×0 + × × ×0 0 0 × ×

Numerical Linear Algebra Lecture 12 November 29, 2019 21 / 31

Page 22: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

3. QT3 =

1

1c3 s3−s3 c3

1

, QT3 H2 =

× × × × ×× × × × ×0 × × × ×0 0 × × ×0 0 0 × ×

H3 = QT3 H2Q3 =

× × × × ×× × × × ×0 × × × ×0 0 × × ×0 0 + × ×

4. QT4 =

1

11

c4 s4−s4 c4

, QT4 H3 =

× × × × ×× × × × ×0 × × × ×0 0 × × ×0 0 0 × ×

Numerical Linear Algebra Lecture 12 November 29, 2019 22 / 31

Page 23: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

H4 = QT4 H3Q4 =

× × × × ×× × × × ×0 × × × ×0 0 × × ×0 0 0 × ×

Altogether QTHQ = H4 is upper Hessenberg, where

Q = Q1Q2Q3Q4 =

c1 × × × ×s1 × × × ×

s2 × × ×s3 × ×

s4 c4

,

so the first column of Q is[c1 s1 0 · · · 0

]T, which by the

implicit Q theorem has uniquely determined the other columns ofQ (up to signs). We now choose the first column of Q to beproportional to the first column of H(0) − µ(1)I. This means Q isthe same (up to signs) as in the QR factorization of H(0) − µ(1)I.

Numerical Linear Algebra Lecture 12 November 29, 2019 23 / 31

Page 24: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

4.3. Implicit double shift QR algorithm

We describe how to maintain real arithmetic by shifting µ(k) andµ(k) in succession:

Q(k−1/2)R(k−1/2) = H(k−1) − µ(k)I

H(k−1/2) = R(k−1/2)Q(k−1/2) + µ(k)I

= (Q(k−1/2))∗H(k−1)Q(k−1/2)

Q(k)R(k) = H(k−1/2) − µ(k)I

H(k) = R(k)Q(k) + µ(k)I = (Q(k))∗H(k−1/2)Q(k)

= (Q(k−1/2)Q(k))∗H(k−1)Q(k−1/2)Q(k)

Numerical Linear Algebra Lecture 12 November 29, 2019 24 / 31

Page 25: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

Lemma 12

We can choose Q(k−1/2) and Q(k) such that

(1) Q(k−1/2)Q(k) is real,

(2) H(k) is therefore real,

(3) the first column of Q(k−1/2)Q(k) is easy to compute.

Proof. Since

Q(k)R(k) = H(k−1/2) − µ(k)I = R(k−1/2)Q(k−1/2) + (µ(k) − µ(k))I,

we get

Q(k−1/2)Q(k)R(k)R(k−1/2)

= Q(k−1/2)(R(k−1/2)Q(k−1/2) + (µ(k) − µ(k))I)R(k−1/2)

= Q(k−1/2)R(k−1/2)Q(k−1/2)R(k−1/2) + (µ(k) − µ(k))Q(k−1/2)R(k−1/2)

= (H(k−1) − µ(k)I)2 + (µ(k) − µ(k))(H(k−1) − µ(k)I)

= (H(k−1))2 − 2Re(µ(k))H(k−1) + |µ(k)|2I ≡ M.

Numerical Linear Algebra Lecture 12 November 29, 2019 25 / 31

Page 26: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

Thus, Q(k−1/2)Q(k)R(k)R(k−1/2) is the QR factorization of the realmatrix M, and therefore, Q(k−1/2)Q(k), as well as R(k)R(k−1/2), can bechosen real. This means that

H(k) = (Q(k−1/2)Q(k))∗H(k−1)Q(k−1/2)Q(k)

also is real if H(k−1) is real. The first column of Q(k−1/2)Q(k) isproportional to the first column of

(H(k−1))2 − 2Re(µ(k))H(k−1) + |µ(k)|2I,

whose sparsity pattern is[× × × 0 · · · 0

]T.

Numerical Linear Algebra Lecture 12 November 29, 2019 26 / 31

Page 27: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

We provide a 6× 6 example. Assume H is upper Hessenberg andthe shifts are µ and µ.

1. Choose an orthogonal matrix

QT1 =

[Q̃T 00 I

], Q̃TQ̃ = I3,

where the first column of Q1 is proportional to the first column of

H2 − 2Re(µ)H+ |µ|2I,

so

QT1 H =

× × × × × ×× × × × × ×+ × × × × ×0 0 × × × ×0 0 0 × × ×0 0 0 0 × ×

, QT1 HQ1 =

× × × × × ×× × × × × ×+ × × × × ×+ + × × × ×0 0 0 × × ×0 0 0 0 × ×

Numerical Linear Algebra Lecture 12 November 29, 2019 27 / 31

Page 28: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

2. Choose a Householder reflector QT2 , which affects only rows 2,3,

and 4 of QT2 H1, zeroing out entries (3,1) and (4,1) of H1 = QT

1 HQ1

(this means that QT2 is the identity matrix outside rows and columns 2

through 4):

QT2 H1 =

× × × × × ×× × × × × ×0 × × × × ×0 + × × × ×0 0 0 × × ×0 0 0 0 × ×

,

H2 = QT2 H1Q2 =

× × × × × ×× × × × × ×0 × × × × ×0 + × × × ×0 + + × × ×0 0 0 0 × ×

Numerical Linear Algebra Lecture 12 November 29, 2019 28 / 31

Page 29: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

3. Choose a Householder reflector QT3 , which affects only rows 3,4,

and 5 of QT3 H2, zeroing out entries (4,2) and (5,2) of H2 (this

means that QT3 is the identity matrix outside rows and columns 3

through 5):

QT3 H2 =

× × × × × ×× × × × × ×0 × × × × ×0 0 × × × ×0 0 + × × ×0 0 0 0 × ×

H3 = QT3 H2Q3 =

× × × × × ×× × × × × ×0 × × × × ×0 0 × × × ×0 0 + × × ×0 0 + + × ×

Numerical Linear Algebra Lecture 12 November 29, 2019 29 / 31

Page 30: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

4. Choose a Householder reflector QT4 , which affects only rows 4,5,

and 6 of QT4 H3, zeroing out entries (5,3) and (6,3) of H2 (this

means that QT4 is the identity matrix outside rows and columns 4

through 6):

QT4 H3 =

× × × × × ×× × × × × ×0 × × × × ×0 0 × × × ×0 0 0 × × ×0 0 0 + × ×

H4 = QT4 H3Q4 =

× × × × × ×× × × × × ×0 × × × × ×0 0 × × × ×0 0 0 × × ×0 0 0 + × ×

Numerical Linear Algebra Lecture 12 November 29, 2019 30 / 31

Page 31: Lecture 12: QR algorithm - Xiamen Universitymath.xmu.edu.cn/group/nona/nla/lecture12.pdf · Lecture 12: QR algorithm November 29, 2019 Numerical Linear Algebra Lecture 12 November

5. Choose a Givens rotation QT5

QT5 =

11

11

c s−s c

, QT5 H4 =

× × × × × ×× × × × × ×0 × × × × ×0 0 × × × ×0 0 0 × × ×0 0 0 0 × ×

H5 = QT5 H4Q5 =

× × × × × ×× × × × × ×0 × × × × ×0 0 × × × ×0 0 0 × × ×0 0 0 0 × ×

.

Altogether QTHQ is upper Hessenberg, where

Q = Q1Q2Q3Q4Q5 with Qe1 = Q1e1.

Numerical Linear Algebra Lecture 12 November 29, 2019 31 / 31