Topic 6 Handout
Topic 6 Handout
Algebraic Methods 2
Gaussian Elimination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
LU Factorisation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Sparsity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Iterative Methods 24
Iterative method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Jacobi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Gauss-Seidel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Over-Relaxation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Conjugate-Gradient 36
Conjugate-Gradient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Eigenvalues 42
Eigenvalues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Approximation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Power method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Inverse power method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Deflation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Orthogonalisation 52
Orthogonality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Orthogonalisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
The QR Method 58
QR method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Householder
. . . . . . . . . . .matrices
............................................................................ 64
Givens matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Eigenvalue condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
1
Algebraic Methods 2 / 76
Matrix form
−9 5 −5 6 x4 −19
3 / 76
Gaussian Elimination
4 / 76
2
LU Factorisation
Define L by letting Lij be the multiple of row j subtracted from row i, and U the tableau matrix before
backsubstitution.
1 0 0 0 3 −7 −2 2
−1 1 0 0 0 −2 −1 2
L=
2 −5 1
, U =
0 0 0 1 1
−3 8 −3 1 0 0 0 −1
Notice that LU = A!
1 0 0 0 3 −7 −2 2 3 −7 −2 2
−1 1 0 0 0 −2 −1 2 −3 5 1 0
LU =
2 −5 1
= = A.
0 0 0 1 1 6 −4 2 −5
−3 8 −3 1 0 0 0 −1 −9 5 −5 6
Solving Ly = b gives y = (−9, −4, 5, 1)T . Notice that this y is the right-hand column of the tableau before
backsubstitution.
5 / 76
LU Factorisation
Factorization A = LU where L is unit lower triangular lii = 1, lij = 0 for j > i and U is upper triangular
uij = 0 for i > j .
6 / 76
LU Factorisation—Complexity
7 / 76
3
LU Factorisation—Pivoting
Let A(k−1 ) be the matrix obtained after working on the first k − 1 columns.
(k−1)
Pivoting If Akk is equal to zero, then Gaussian elimination needs to swap rows.
Obtain a factorisation P A = LU , were P is a permutation matrix.
(k−1) (k−1)
Partial pivoting Make the pivot element Akk the largest of Akj for j ≥ k .
8 / 76
Example Compute the LU-factorisation of A using partial pivoting and solve Ax = b where
2.11 −4.21 0.921 2.01
A = 1.09 0.987 0.832 , b = 4.21 .
4.01 10.2 −1.12 −3.09
9 / 76
10 / 76
4
LU Factorisation—Pivoting Example (Omit)
Example Obtain P A = LU with
0 0 1 2.11 −4.21 0.921 4.01 10.2 −1.12
P A = 1 0 0 1.09 0.987 0.832 = 2.11 −4.21 0.921
0 1 0 4.01 10.2 −1.12 1.09 0.987 0.832
1 0 0 4.01 10.2 −1.12
= 0.526 1 0 0 −9.58 1.51 = LU
0.272 0.186 1 0 0 0.855
11 / 76
12 / 76
5
LU Factorisation—Pivoting Example (Omit)
13 / 76
Sparsity
14 / 76
Sparsity
Example For the given tridiagonal matrix, the inverse is
−1
4 1 0 0 0 0.268 −0.072 0.019 −0.005 0.001
1 4 1 0 0 −0.072 0.287 −0.077 0.021 −0.005
0 1 4 1 0 = 0.019 −0.077 0.288 −0.077 0.019
0 0 1 4 1 −0.005 0.021 −0.077 0.287 −0.072
0 0 0 1 4 0.001 −0.005 0.019 −0.072 0.268
15 / 76
6
Sparsity
Example For the LU-factorisation
1 0 0 0 0 4.000 1 0 0 0
0.250 1 0 0 0
0 3.750 1 0 0
0
LU = 0.267 1 0 0 0 0 3.733 1 0
0 0 0.268 1 0 0 0 0 3.732 1
0 0 0 0.268 1 0 0 0 0 3.732
16 / 76
Symmetric matrices
Cholesky factorisation If A is positive definite, then there is an upper-triangular matrix U such that
A = U T U (or a lower-triangular matrix L such that A = LLT .)
17 / 76
18 / 76
7
Norms and Conditioning 19 / 76
21 / 76
Condition number
Conditioning For a given vector norm k · k and corresponding matrix norm, define the matrix condition
number K(A) := ||A|| × ||A−1 || .
Suppose x̃ is an approximate solution to Ax = b. Then
||x̃ − x|| = kA−1 (Ax̃ − Ax)k ≤ ||A−1 || ||Ax̃ − b||
so the error satisfies:
||Ax̃ − b||
||x̃ − x|| ≤ K(A) .
||A||
Further, since kAk · kxk ≥ kAxk = kbk, we have 1/kxk ≤ kAk/kbk, so the relative error satisfies:
||x̃ − x|| ||Ax̃ − b||
≤ K(A)
||x|| ||b||
8
22 / 76
Iterative refinement
Refinement Then
A(x − x̃) = Ax − Ax̃ = b − Ax̃ ≈ 0,
so
x = x̃ + A−1 (b − Ax̃).
Accuracy If A−1 b can be computed less accurately than Ax, refinement typically improves the accuracy of a
solution.
23 / 76
Iterative Methods 24 / 76
9
Jacobi method
Pn
Fixed-point formula We have j=1 aij xj = bi for i = 1, . . . , n.
Pn
Write aii xi + j=1,j6=i aij xj = bi . Rearranging gives
P
bi − j6=i aij xj
xi = .
aii
We can use this as the basis for an iterative method.
26 / 76
Jacobi method
27 / 76
10
Gauss-Seidel method
Gauss-Seidel Method Rather than update all the xi simultaneously, we can update in turn. Then
Pi−1 ′
Pn
bi − j=1 aij xj − j=i+1 aij xj
x′i = .
aii
In other words,
P Pn
for i = 1, . . . , n, set xi = bi − j6=i aij xj /aii = xi − j=1 aij xj − bi /aii .
This is more easily implemented in code:
for i=1:n, x(i)=x(i)-(A(i,:)*x-b(i))/A(i,i); end;
or using an explicit loop:
for i=1:n,
ri=-b(i);
for j=1:n, ri=ri+A(i,j)*x(j); end;
x(i)=x(i)-ri/A(i,i);
end;
28 / 76
Gauss-Seidel method
29 / 76
11
Gauss-Seidel method
Example For
3 −7 −2 2 −9 0
−3 5 1 0 5 0
A=
6 −4 2 −5,
b=
7 ,
x(0) =
0
−9 5 −5 6 −19 0
the Gauss-Seidel method gives
−3.000 6.778 −11.944 −4.857
1.000 (2) −2.500 (3) 6.950 (4) −6.925
x(1) =
3.500 , x = 3.083 , x =−30.958, x = 119.365
30 / 76
Gauss-Seidel method
Matrix form Write A = L + D + U , where L is strictly lower-triangular, D is diagonal and U is strictly upper
triangular.
i.e. Li,j = 0 if i ≤ j , Di,j = 0 if i 6= j , Ui,j = 0 if i ≥ j .
Note that L, U here are not the L and U of the LU factorisation!!
Then the Gauss-Seidel method is given by x′ = D −1 (b − Lx′ + U x), and rearranging gives
x′ = (L + D)−1 (b − U x)
= x − (L + D)−1 (Ax − b).
31 / 76
Convergence
Theorem An iterative method x′ = T x + r converges if ||T || < 1 for some matrix norm || · ||.
P
Definition A matrix A is diagonally-dominant if |aii | > j6=i |aij | for all i.
12
Preconditioning
Example Let
3 −7 −2 2 −9 0 0 −1 −1
−3 5 1 0 5 1 2 0 0
A=
6 −4 2 −5,
b=
7 ,
P =
0
.
0 1 0
−9 5 −5 6 −19 1 0 0 0
Then
3 −1 3 −1 12
−3 3 0 2 1
6 −4 2 −5 ,
PA =
7 .
Pb =
3 −7 −2 2 −9
Applying the Gauss-Seidel method to (P A)x = (P b) gives iterates:
4.0 6.9 1.7 −1.69 −2.63
4.3 (2) 4.0 (4) 1.0 (8) −1.15 (12) −1.76
x(1) =
0.2, x =2.9, x =4.2, x = 5.50 , x
=
5.86 .
33 / 76
13
Successive Over-Relaxation Method
Example Solve Ax = b using the successive over-relaxation method with
6 2 0 3
A= 3 5 −1 , b = 4 , x(0) = 0, ω = 1.1.
−2 1 4 1
35 / 76
Conjugate-Gradient 36 / 76
Conjugate-Gradient Method
Idea Construct sequence xk minimising residual ||Axk − b||2 in span{b, Ab, . . . , Ak−1 b}.
Use inner products
Pn Pn
hu, S, vi = i,j=1 ui Sij vj and hu, vi = hu, I, vi = i u i vi .
Algorithm
Initialise
x0 = 0, r0 = b − Ax0 , v1 = r0 ;
Iterate for k = 1, 2, . . .
sk = hrk−1 , rk−1 i/hrk−2 , rk−2 i, s1 unused.
vk = rk−1 + sk vk−1 , v1 = r0 ;
tk = hrk−1 , rk−1 i/hvk , A, vk i,
xk = xk−1 + tk vk ,
rk = rk−1 − A tk vk ,
Note rk = b − Axk and hvi , A, vj i = 0 for i 6= j .
37 / 76
14
Conjugate-Gradient Method
Example Solve Ax = b using the conjugate-gradient method, where
6 3 −1 3
A = 3 5 2 , b = 4 .
−1 2 4 1
0 3
x0 = 0, r0 = b = 4 ;
0 1
3
v1 = r0 = 4
1
hr0 , r0 i 26
t1 = = = 0.11818
hv1 , A, v1 i 220
0 3 0 0.35455 0.35455
x1 = x0 + t1 v1 = 0 + 0.11818 × 4 = 0 + 0.47273 = 0.47273
0 1 0 0.11818 0.11818
3 6 3 −1 0.35455 −0.427273
r1 = r0 − A t1 v1 = 4 − 3 5 2 × 0.47273 = 0.336364
1 −1 2 4 0.11818 −0.063636
38 / 76
Conjugate-Gradient Method
Example
3.00000 0.35455 −0.427273
v1 = 4.00000 , x1 = 0.47273 , r1 = 0.336364 .
1.00000 0.11818 −0.063636
hr1 , r1 i 0.29975
s2 = = = 0.011529
hr0 , r0 i 26.00000
−0.427273 3.00000 −0.39269
v2 = r1 + s2 v1 = 0.336364 + 0.011529 × 4.00000 = 0.38248
−0.063636 1.00000 −0.05211
hr1 , r1 i 0.29975
t2 = = = 0.46422
hv2 , A, v2 i 0.64572
0.355 −0.393 0.355 −0.1823 0.17225
x2 = x1 + t2 v2 = 0.473 + 0.464× 0.382 = 0.473 + 0.1776 = 0.65028
0.118 −0.052 0.118 −0.0242 0.09399
−0.4273 6 3 −1 −0.1823 0.109625
r2 = r1 − A t2 v2 = 0.3364 − 3 5 2 × 0.1776 = 0.043850
−0.0636 −1 2 4 −0.0242 −0.504277
39 / 76
15
Conjugate-Gradient Method
Example
−0.39269 0.17225 0.109625
v2 = 0.38248 , x2 = 0.65028 , r2 = 0.043850 .
−0.05211 0.09399 −0.504277
hr2 , r2 i 0.26824
s3 = = = 0.89486
hr1 , r1 i 0.29975
−0.24177
v3 = r2 + s3 v2 = 0.38612
−0.55091
hr2 , r2 i 0.26824
t3 = = = 0.42390
hv3 , A, v3 i 0.63278
0.06977
Solution x = x3 = x2 + t3 v3 = 0.81395
−0.13953
0.0
r3 = r2 − A t3 v3 = 0.0 = b − Ax (residual)
0.0
40 / 76
41 / 76
16
Approximating Eigenvalues 42 / 76
Triangular If A is a lower- or upper-triangular matrix, then the eigenvalues of A are the diagonal entries;
λi = aii
Diagonal If D is a diagonal matrix, then the eigenvectors are the standard unit basis vectors ei , with
Dei = dii ei .
Notation Often write eigenvalues in order, |λ1 | ≥ |λ2 | ≥ · · · ≥ |λn |, with corresponding eigenvectors vi .
43 / 76
Approximation theorems
Gersgorin Circle Theorem For i = 1, . . . , n, there exists an eigenvalue λi of A within the circle
Pn
{z ∈ C | |z − aii | ≤ j=1,j6=i |aij |}.
Similarly, for j = 1, . . . , n, there esists an eigenvalue λj of A in the circle
Pn
{z ∈ C | |z − ajj | ≤ i=1,i6=j |aij |}.
Example
10 −2 1
A=1 3 −1 .
0 1 −2
The eigenvalues λ1,2,3 satisfy:
|λ1 − 10| ≤ |−2|+|1| = 3, |λ2 − 3| ≤ |1|+|−1| = 2, |λ3 − (−2)| ≤ 1.
If λ1,2,3 are real, then λ1 ∈ [7, 13], λ2 ∈ [1, 5], λ3 ∈ [−3, −1].
By considering the first column, see |λ1 − 10| ≤ 1.
44 / 76
17
The power method
Theorem If A has an eigenvalue λ1 such that |λ1 | > |λi | for all other eigenvalues, then the power method
converges, with limn→∞ x(n) = v1 and limn→∞ µ(n) = λ1 .
Proof.
For simplicity, suppose Rn has basis {v1 , v2 , . . . , vn } of eigenvectors of A.
Write x = α1 v1 + α2 v2 + · · · + αn vn . Then
Ak x = Ak (α1 v1 + α2 v2 + · · · + αn vn )
= α1 Ak v1 + α2 Ak v2 + · · · + αn Ak vn
= α1 λk1 v1 + α2 λk2 v2 + · · · + αn λkn vn
= λk1 (α1 v1 + α2 (λ2 /λ1 )k v2 + · · · + αn (λn /λ1 )k vn .
Hence limk→∞ Ak x/λk1 = α1 v1 , so
Ak x Ak x/λk1 α1 v1
lim x(k) = lim k
= lim ± k
= ± = ± v̂1 .
k→∞ k→∞ ±||A x|| k→∞ ||Ak x/λ1 || ||α1 v1 ||
46 / 76
18
The power method
Example
1 2 0 1
A = 0 0 1 , x = 1 .
1 0 0 1
1 2 0 1 3 (0) 1 1.0000
y
y (0) = Ax(0) = 0 0 1 1 = 1 ; x(1) = (0) = 1/3 = 0.3333
1 0 0 1 1 ||y || ∞ 1/3 0.3333
1 2 0 1.0000 1.6667 (1) 1.0000
y
y (1) = Ax(1) = 0 0 1 0.3333 = 0.3333 ; x(2) = (1) = 0.2000
1 0 0 0.3333 1.0000 ||y || 0.6000
1 2 0 1.0000 1.4000 (2) 1.0000
y
y (2) = Ax(2) = 0 0 1 0.2000 = 0.6000 ; x(3) = (2) = 0.4286
1 0 0 0.6000 1.0000 ||y || 0.7143
1 2 0 1.0000 1.8571 (3) 1.0000
y
y (3) = Ax(3) = 0 0 1 0.4286 = 0.7143 ; x(4) = (3) = 0.3846
1 0 0 0.7143 1.0000 ||y || 0.5385
47 / 76
Alternative estimate
0.8415
(5) x(5) x(5)TAx(5)
v ≈ x̂ = (5) = 0.2561; λ ≈ µ̂(5) = (5)T (5) = x̂(5)TAx̂(5) = 1.661.
||x ||2 0.4756 x x
T
Actual eigenvalue/vector λ = 1.6841, v = 1.0000, 0.3514, 0.6216 or normalised
T
v̂ = 0.8138, 0.2859, 0.5059 .
48 / 76
19
Inverse power method
49 / 76
Example
2 −1 1
1
A = −1 3 −2 ; µ = 1.5. Use x(0) = 0.
1 2 3 0
0.5 −1 1 1 0 0 0.5 −1.0 1.0
A − µI = −1 1.5 −2 = −2.0 1 0 0 −0.5 0.0 = Lµ Uµ
1 2 1.5 2.0 −8.0 1 0 0 −0.5
−1
0.5 −1 1 50 28 4
(A − µI)−1 = −1 1.5 −2 = −4 −2 0
1 2 1.5 −28 −16 −2
50.0000 (0) 1.0000
y
y (0) = (A − µI)−1 x(0) = −4.0000 ; x(1) = (0) = −0.0800
−28.0000 ||y || −0.5600
45.5200 (1) 1.0000
y
y (1) = (A − µI)−1 x(1) = −3.8400 ; x(2) = (1) = −0.0844
−25.6000 ||y || −0.5624
45.3884 (2) 1.0000
y
y (2) = (A − µI)−1 x(2) = −3.8313 ; x(3) = (2) = −0.0844
−25.5255 ||y || −0.5624
Eigenvalue/vector λ ≈ (Ax(3) )1 = 1.5220, v ≈ (1.0000, −0.0844, −0.5624).
50 / 76
Deflation (Off-syllabus)
Wielandt deflation Define x by xj = ak,j / λ1 (v1 )k for some k . Then the k th row of B is identically 0, so
20
51 / 76
Orthogonalisation 52 / 76
Orthogonality
pPn
A vector v is normal if kvk2 := 2
Normal vectors i=1 vi = 1, equivalently if v · v = 1.
Orthonormal vectors Vectors {v1 , . . . , vn } are orthonormal if they are orthogonal and each is normal.
Gram-Schmidt orthogonalisation
Theorem The vi are an orthogonal set, and the ui are an orthonormal set, such that for all k = 1, . . . , m,
span{x1 , . . . , xk } = span{u1 , . . . , uk } = span{v1 , . . . , vk }.
Proof. Fix i and assume {u1 , . . . , ui−1 } are orthonormal. Then for i > j ,
Pi−1
vi · uj = xi · uj − k=1 (xi · uk )uk · uj = xi · uj − (xi · uj )(uj · uj ) = 0,
so ui · uj = (vi /kvi k) · uj = (vi · uj )/kvi k = 0.
54 / 76
Gram-Schmidt orthogonalisation
Example Apply the Gram-Schmidt orthogonalisation procedure to:
2 −1 1
x1 = −1 , x2 = 3 , x3 = −2 .
1 2 3
2 −1 2 0
x 2 · v1 −3
v1 = x1 = −1 ; v2 = x2 − v1 = 3 − −1 = 5/2 ;
v1 · v1 6
1 2 1 5/2
1 2 0 −4/3
x3 · v1 x3 · v2 7 5/2
v3 = x3 − v1 − v2 = −2 − −1 − 5/2 = −4/3 .
v1 · v1 v2 · v2 6 25/2
3 1 5/2 4/3
√ √ √
kv1 k = 6; kv2 k = 5/ 2; kv3 k = 4/ 3.
2 0 −1
v1 1 1 1
u1 = = √ −1 ; u2 = √ 1 ; u3 = √ −1 .
||v1 || 6 2 1 3
1 1
Check orthogonality:
2×0 + (−1)×1 + 1×1 −2 + 1 + 1
u1 · u2 = √ √ = 0; u1 · u3 = √ = 0; u2 · u3 = 0.
6× 2 18
21
55 / 76
QR factorisation
QR factorisation
Example Compute the QR-factorisation of:
2 −1 1
A = −1 3 −2
1 2 3
57 / 76
The QR Method 58 / 76
The QR method
The QR Method The QR method is an iterative algorithm for finding all the eigenvalues of A.
Set A(0) = A. Iteratively find Q(n) , R(n) such that A(n) = Q(n) R(n) and set A(n+1) = R(n) Q(n) .
Theorem Assuming eigenvalues of A have distinct absolute value, A(n) converges to an upper-triangular
matrix with the eigenvalues of A on the diagonal.
59 / 76
22
The QR method
Example Use the QR method to approximate eigenvalues of:
4 −1 1
A = −1 3 −2 .
1 −2 3
−0.9428 −0.3244 −0.0765 −4.2426 2.1213 −2.1213
(0) (0)
Q = 0.2357 −0.8111 0.5353 , R = 0 −3.0822 2.7578
−0.2357 0.4867 0.8412 0 0 1.3765
5.0000 −1.3765 −0.3244
A(1) = R(0) Q(0) = −1.3765 3.8421 0.6699
−0.3244 0.6699 1.1579
5.6667 −0.9406 0.0640
A(2) = R(1) Q(1) = −0.9406 3.3226 −0.1580
0.0640 −0.1580 1.0108
5.909 −0.514 −0.011 5.977 −0.263 0.002
(3) (4)
A = −0.514 3.090 0.045 A = −0.263 3.023 −0.014
−0.011 0.045 1.001 0.002 −0.014 1.000
Hence λ1 = 5.977 ± 0.265, λ2 = 3.023 ± 0.277, λ3 = 1.000 ± 0.016.
60 / 76
Conjugacies Note
A(k) = Q(k) R(k) = R(k−1) Q(k−1) ;
Q(k) A(k+1) = Q(k) R(k) Q(k) = A(k) Q(k) .
23
The QR method—Convergence (Non-examinable)
Then
P (k) e1 ∝ Ak e1 = α1,1 λk1 (v1 + (α1,j /α1,1 )(λj /λ1 )k vj ∼ v1 as k → ∞.
P
62 / 76
Shifted QR The QR method can be shifted i.e. applied to A(n) − µ(n) I for scalars µ(n) , as
A(n) − µ(n) I = Q(n) R(n) ; A(n+1) = R(n) Q(n) + µ(n) I .
This can accelerate convergence, especially when eigenvalues have nearly the same absolute value.
Partial QR The QR method can also be modified to find only some of the eigenvalues of A by iterating
Q(k) R(k) = AQ(k−1) , where the Q(k) are n-by-m matrices with orthonormal columns, and the R(k) are
m-by-m upper-triangular matrices.
63 / 76
64 / 76
24
Householder matrices (Advanced)
√
Example Take v = (0, 2, −1, 1)T , w = v/ 6,
1 0 0 0
3 0 0 0
0 − 1 2
− 32
3 3 1 0 −1 2 −2
H = =
0 32 2
3
1
3
3 0 2 2 1
0 − 32 1 2 0 −2 1 2
3 3
65 / 76
Note that if A is symmetric and upper-Hessenberg, then it is tridiagonal Ai,j = 0 for |i − j| > 1.
∗ ∗ 0 0 0
∗ ∗ ∗ 0 0
0 ∗ ∗ ∗ 0
0 0 ∗ ∗ ∗
0 0 0 ∗ ∗
Upper-Hessenberg form greatly increases the efficiency of the QR method; time O(n2 ) per step instead of
O(n3 ), and O(n) for symmetric matrices.
66 / 76
Conversion to upper-Hessenberg form First find a Householder matrix H = H1 such that H1T AH1 has first
column (H1T AH1 )i,1 = 0 for i ≥ 3:
Pn 2
1/2
1. Set α = i=2 ai,1 , v1 = 0, v2 = a2,1 ±α, vi = ai,1 for i ≥ 3.
Typically choose sign so that v2 = a2,1 + sgn(a2,1 )α.
1/2
2. Take w = v/r where r = ||v|| = 2α(α ± a2,1 ) .
3. Set H = 1 − 2wwT , so Hi,1 = 0 for i > 2.
Continue by applying the method to the sub-matrix (H1T AH1 )2:n,2:n to find a Householder matrix H2 such
that H2T H1T AH1 H2 has Hi,j = 0 for j = 1, 2 and i > j + 1.
67 / 76
25
Householder matrices (Advanced)
Example
4 1 −2 2
1 2 0 1
A= −2 0 3 −2 .
2 1 −2 −1
P4 2 1/2
√
α1 = − sgn(a21 ) i=2 a21 = − 9 = −3.
q √
r1 = ( 12 α1 (α1 − a2,1 ))1/2 = (− 12 α1 (a2,1 − α1 ))1/2 = 12 3(3 + 1) = 6.
0 0 0
1 − (−3) 4 1 2
v1 = −2 = −2 ; w1 = v1 /2r1 = √6 −1 .
2 2 1
1 0 0 0 3 0 0 0
0 − 1 2 − 2 1 0 −1 2 −2
H1 = I − 2w1 w1T = 0 2
3 3
2
3
1 =
3 3 3 3 0 2 2 1
0 − 32 13 2
3 0 −2 1 2
68 / 76
69 / 76
26
Givens matrices (Advanced)
70 / 76
71 / 76
1 0 0
5 5 11
5 12
G2 = 0
13 − 13 ; R = G−1
2 (G1 A) =
−1 0 13 3 .
12 5 0 0 −2
0 13 13
27
72 / 76
Example (continued)
RQ = RG1 G2 = (RG1 )G2
4 3
5 −5 0 1 0 0
5 5 11
5 12
= 0 13 3 35 4
0 0 13 − 13
5
0 0 −2 0 0 1 0 1213
5
13
1 0 0
7 1 11
4 2 0 5 − 12
= 7 5 10 5 3
13 13
0 0 −2 0 12 13
5
13
7 4
7 10 13 3 13
7.000 10.538 3.308
10
= 7 54 6 13 −9 6529
= 7.800 6.769 −8.446
0 −1 11 − 10 0 −1.846 −0.769
13 13
73 / 76
If A is tridiagonal, then A = QR with ri,j = 0 for i > j or j > i + 2, so R is banded with three nontrivial
bands on the main diagonal and above ( 3n nonzero entries).
However, Q is upper-Hessenberg, and has n2 /2 nonzero entries, even though it is the product of n − 1 Givens
rotations, which are sparse.
We therefore perform the QR-method using Givens rotations, and do not directly construct Q.
74 / 76
75 / 76
76 / 76
28