Chapter 3
Chapter 3
The second assumption implies that there is a basis u(1) , u(2) , · · · , u(n) for Cn such that
Let x(0) be any element of Cn such that when x(0) is expressed as a linear combination of the basis
elements u(1) , u(2) , · · · , u(n) , and we assume that the coefficient of u(1) is not zero. Thus
and we form
x(1) = Ax(0) , x(2) = Ax(1) , · · · , x(k) = Ax(k−1) (3.4)
so that
x(k) = Ak x(0) . (3.5)
Without loss of generality, we will assume that all the coefficients aj of the vectors u(j) are absorbed,
i.e. we may write (3.5) as
x(0) = u(1) + u(2) + · · · + u(n) . (3.6)
47
48 NUM702S: Numerical Methods 2
and the vector within the brackets converges to u(1) . All the latter information can be written in
a compact form as
x(k) = λk1 u(1) + (k) with lim (k) = 0.
(3.10)
k→∞
In order to handle ratios, let assume that φ is an arbitrary linear mapping on Cn such that
φ(u(1) ) 6= 0. From Eq. (3.10) and by linearity of φ, we have
φ(x(k+1) )
lim rk = lim = λ1 (3.12)
k→∞ k→∞ φ(x(k) )
Indeed
φ(x(k+1) ) φ(u(1) ) + φ((k+1) )
rk = = λ1 , (3.13)
φ(x(k) ) φ(u(1) ) + φ((k) )
and since φ is linear, φ((k) ) and φ((k+1) ) → 0 as k → ∞ and the term in brackets in Eq. (3.13)
converges to 1, and thus we obtain Eq. (3.12).
where A is the target matrix, n is the matrix dimension, x is the eigenvalue and kmax is the
maximum number of iterations.
It is worth mentioning here that in practical implementation of the power method, the eigen-
vector x(k) may converge to zero or become unbounded. To avoid this, it is advisable to normalise
x(k) . Thus we obtain a modified Power method.
Solution
approximation to λ1 is
(1)
(1) x2 4
λ1 = (0)
= = 4.
x2 1
Further iterations are given by
1 1 −1 1 3
x(2) = Ax(1) = 1 2 1 4 = 11 (k = 2)
2 −1 1 2 0
(2)
(2) x2 11
λ1 = (1)
= = 2.75.
x2 4
1 1 −1 3 14
x(3) = Ax(2) = 1 2
1 11 = 25 (k = 2)
2 −1 1 0 −5
(3)
(3) x2 25
λ1 = (2)
= = 2.27.
x2 11
1 1 −1 14 44
x(4) = Ax(3) = 1 2 1 25 = 59 (k = 2)
2 −1 1 −5 −2
(4)
(4) x2 59
λ1 = (3)
= = 2.36.
x2 25
..
.
1731
x(8) = Ax(7) = 3152 (k = 2)
108
(8)
(8) x2 3152
λ1 = (7)
= = 2.5857.
x2 1219
4775
x(9) = Ax(8) = 8143 (k = 2)
418
(9)
(9) x2 8143
λ1 = (8)
= = 2.5834.
x2 3152
..
.
NUM702S: Numerical Methods 2 51
%pw_method_inf
function [sigma, x] = pw_method_inf(A,x_0,tol,max_N)
if (nargin <= 2)
disp(’tolerance undefined’)
return;
end
if (nargin == 3)
max_N = 20;
end
x = A*x_0;
[x_max, i] = max(abs(x));
sigma = x(i);
x = x/sigma;
j = 1;
while ( (norm(x_0 - x, inf) > tol) | ...
(norm(A*x - sigma*x, inf) > tol) | ...
(abs(sigma - sigma_0) > tol) & ...
( j <= max_N ) )
x_0 = x;
sigma_0 = sigma;
x = A*x_0;
[x_max, i] = max(abs(x));
sigma = x(i);
end
x = x/sigma;
j = j+1;
end
disp(’divergence likely’)
end
Remarks
The above theorem suggests a means of computing the smallest eigenvalue of A.
Let the eigenvalues of A satisfy the following
Eq. (3.15) implies that A is non-singular since 0 is not an eigenvalue. Thus the eigenvalues of A−1
are λ−1
j satisfying
|λ−1 −1 −1
n | > |λn−1 | ≥ · · · ≥ |λ1 | > 0. (3.16)
Now we can compute λ−1
n by applying the Power method to the inverse A
−1
from the procedure
of solving
Ax(k+1) = x(k) (3.17)
in contrast to Ax(k−1) = x(k) given by Eq. (3.14).
The above equation (3.17) is employed to avoid finding first the inverse A−1 and then using it in
x(k+1) = A−1 x(k) suggested by Eq. (3.14), which is not a very good computational approach.
Eq. (3.17) can be solved by the LU decomposition method.
Definition 3.1.5 The above method given by Eq. (3.17) and Theorem 3.1.3 is known as the in-
verse power method. it finds the smallest eigenvalue of A through the computation of the largest
eigenvalue of the inverse A−1 of A and then take the reciprocal.
Exercise
Use the Matlab code for the Power method to obtain the smallest eigenvalue of the matrix in
Example 3.1.2 with the same initial vector.
NUM702S: Numerical Methods 2 53
A = LU
The following theorem gives us a sufficient condition for the existence of the LU -Decomposition of
a square matrix.
using the Power and Inverse Power methods respectively with the initiale vector x(0) = (−1, 1, 1)T .
In summary, we have the following results for the two variants of the power method
will converge to the dominant eigenpair µ1 , Vj of matrix (A − αI)−1 . Finally the corresponding
eigenvalue for the matrix A is given by the calculation
1
λj = + α.
µ1
Example
Use the shifted-inverse power method to find the eigenpairs of the matrix
0 11 −5
A = −2 17 −7
−4 26 −10
Use the fact that the eigenvalues of A are λ1 = 4, λ2 = 2, and λ3 = 1 and select an appropriate
α and starting vector for each case.
NUM702S: Numerical Methods 2 55
Solution
Case-1: For the eigenvalue λ1 = 4, we select α = 4.2 and the starting vector x(0) = (1, 1, 1)T . We
then form the matrix A − 4.2I and compute the y(0) as the solution of the linear sytem
−4.2 11 −5 1
−2 12.8 −7 y(0) = x(0) = 1
−4 26 −14.2 1
Case-2: For the eigenvalue λ2 = 2, we select α = 2.1 and the starting vector x(0) = (1, 1, 1)T .
Proceeding in a manner similar to the above case, we obtain µ1 = −10 and V2 = (1/4, 1/2, 1)T .
Case-3: Similarly for the eigenvalue λ3 = 1, we select α = 0.875 and the starting vector x(0) =
(0, 1, 1)T . We obtain µ1 = 8 and V3 = (1/2, 1/2, 1)T .
3.3 QR Factorisation
Definition 3.3.1 Given a matrix A that can be written as
A = QR (3.18)
where Q is an orthogonal matrix, i.e Q−1 = QT , and R is an upper triangular matrix. Then the
above decomposition is called QR factorisation.
symmetric matrix.
QR algorithm is applicable to a symmetric and tridiagonal matrix. If this is not the case, the first
step consists of using another method called Householder’s method to construct a (symmetric)
tridiagonal matrix having the same eigenvalues as the given/target matrix.
A=
. . .
(3.19)
0 b 3 a 3 0
. .
.. . . . . . . . . bn
0 . . . 0 b n an
So that A(i+1) is symetric (and moreover similar) with the same eigenvalues as A(i) .
Besides, following the definition of R(i) and Q(i) , we also ensure that A(i+1) is tridiagonal.
By induction, A(i+1) has the same eigenvalues as A and A(i+1) tends to a diagonal matrix with the
eigenvalues of Acalong the diagonal.
Theorem 3.3.2 If A is a symmetric matrix and D is a diagonal matrix whose diagonal entries
are the eigenvalues of A, then there exists an orthogonal matrix Q such that
Example 3.3.3 Matlab has a built-in function for QR decomposition as seen in the following
example.
NUM702S: Numerical Methods 2 57
R =
-3.1623 -1.8974 -0.3162
0 -2.7203 -1.9851
0 0 2.4412
Example 3.3.4 Consider the following modification to the above example using the following com-
mands
>> B = [3 1 0;1 3 1]
B =
3 1 0
1 3 1
R1 =
-3.1623 -1.8974 -0.3162
0 2.5298 0.9487
The above example shows that for an m × n matrix B, the Matlab command
[Q R] = qr(B)
A = [x1 , x2 , x3 ]
• Orthogonal basis.
1 1 −3/2
4 1 −3/2
2 x3 · v1 1 x3 · v2 3/2
v3 = x3 − projv1 x3 − projv2 x3 =
2 − v1 · v1
−
1 v2 · v2
3/2
0 1 −3/2
4 1 2
2 1 0
2 − 2 1 − 0 = 0
=
0 1 −2
NUM702S: Numerical Methods 2 59
Thus
1 −3/2 2
1 3/2 0
0 0 0
v1 = , v2 =
, v = (orthogonal basis).
1 3/2 3 0
1 −3/2 −2
• Orthogonal basis
√
kv10 k = 2, kv20 k = 3, kv30 k = 2 2
Defining vi = vi0 /kvi0 k for i = 1, 2, 3, the orthogonal matrix Q = [v1 , v2 , v3 ] is given by
√
1/2 −1/2 1/ 2
1/2 1/2 0
Q= 1/2 1/2
0√
1/2 −1/2 −1/ 2
• Computation of R.
And therefore √
1/2 −1/2 1/ 2
1/2 1/2 2 5 4
0
A=
1/2 1/2 0 3 √0
0√
0 0 2 2
1/2 −1/2 −1/ 2
Thus
T c −s 1 a11 a21
Q = =p 2
s c a11 + a221 −a21 a11
NUM702S: Numerical Methods 2 61
Example 3.3.5 Find the QR factorisation of the following matrix using Givens rotation method
4 −3 5
A = 3 4 5
0 12 0
• Next, multiply the previous result by G23 to eliminate the 12 in the second column. There is no
need to multiply by G13 as there is already a zero in the (3,1) position. So
13 0 0 5 0 7
1
G23 = 0 5 12 then G23 G12 A = 0 13 5/13 = R
13
0 −12 5 0 0 −12/13
Thus
G23 G12 A = R ⇒ A = (G23 G12 )−1 R = (GT12 GT23 )R = QR
where
52 −15 36 5 0 7
1
Q= 39 20 −48 , R = 0 13 5/13 .
65
0 60 25 0 0 −12/13
H −1 = H
Thus we have
HH T = I or H −1 = H T (3.25)
Hence, H is orthogonal. Therefore
H −1 = H T = H (3.26)
Householder’s method usually begins by determining a transformation H (1) with the property that
A(2) = H (1) AH (1) has
(2)
aj,1 = 0, for j = 3, 4, . . . , n (3.27)
(2)
and by symmetricity, a1,j = 0.
The vector w = (w1 , w2 , · · · , wn )T is chosen such that Eq. (3.22) is satisfied. Then the process
continues until we we get
H (i) = I − 2w(i) (w(i) )T (3.28)
and
A(i+1) = H (i) A(i) H (i) (3.29)
where A(i+1) is a symmetric tridiagonal matrix.
Coming back to the practical implementation of w for the construction of H (1) . As mentioned
above, we choose of w such that wT w = 1 and in the matrix
Ĥ = In−1 − 2ŵŵT .
Squaring both sides of each of the equations and adding corresponding terms gives
n
X n
X
2
4r wj2 = (a21 − α) + 2
a2j1 .
j=2 j=3
α2 = (α, · · · , 0)(α, · · · , 0)T = (Ĥ ŷ)T Ĥ ŷ = ŷT ĤT Ĥŷ = ŷT ŷ.
Thus n
X
2
α = a2j1 ,
j=2
n
!1/2
X
α = −sign(a21 ) a2j1 ,
j=2
with this change of α and 2r2 , we solve Eq. (3.32) and Eq. (3.33) to obtain
a21 − α
w2 =
2r
and
aj1
wj = , for each j = 3, . . . , n.
2r
NUM702S: Numerical Methods 2 65
n
!1/2
X
α = −sign(a21 ) a2j1 ,
j=2
1/2
1 2 1
r= α − a21 α ,
2 2
w1 = 0,
a21 − α
w2 = , and
2r
aj1
wj = , for each j = 3, . . . , n.
2r
With this choice, (2) (2)
a11 a12 0 ··· 0
(2) (2) (2) (2)
a21 a22 a23 ··· a2n
(2) (2) (2)
A(2) = H (1) AH (1) 0 a32 a33
= ··· a3n
.. .. .. ..
. . . .
(2) (2)
0 an2 an3 ··· a(2)
nn
Having found H (1) and computed A(2) , the process is repeated for k = 2, 3, . . . , n − 2 as follows
!1/2
X n
(k) 2
α = −sign(ak+1,k ) ajk ,
j=k+1
1/2
1 2 1 (k)
r= α − ak+1,k α ,
2 2
(k) (k) (k)
w1 = w2 = · · · = wk = 0,
(k)
(k) ak+1,k − α
wk+1 = , and
2r
(k)
(k) ajk
wj = , for each j = k + 2, k + 3, . . . , n,
2r
H (k) = I − 2w(k) (w(k) )T , and
A(k+1) = H (k) A(k) H (k) ,
Continuing the process, the tridiagonal and symmetric matrix A(n−1) is formed, where
2 1 −2 −1
Solution
For the determination of H (1) we first need to compute α, r and then w.
4
!1/2 1/2
√
X 1 1
α = −(1) a2j1 = −3, r = 2
(−3) − (1)(−3) = 6,
j=2
2 2
√ √ √ !T
6 6 6
w= 0, ,− , ,
3 6 6
1 0 0 0√ !2 1
0 1 0 0 6 2 · (0, 2, −1, 1)
H (1) =
0
−2
0 1 06 −1
0 0 0 1 1
1 0 0 0
0 −1/3 2/3 −2/3
=
0
,
2/3 2/3 1/3
0 −2/3 1/3 2/3
then
4 −3 0 0
−3 10/3 1 4/3
A(2) = H (1) AH (1) =
0
.
1 5/3 −4/3
0 4/3 −4/3 −1
0 0 68/75 149/75
Consider the rotation matrix J(p, q, θ) similar to Givens matrix G(p, q, θ) with θ replaced with
−θ.
Since the Frobenius norm is invariant under orthogonal transformations, and only p and q columns
are reformed in matrix A0 , we have
n
X
0 2
off(A ) = kA0 k2F − a02
kk
k=1
n
X
= kAk2F − a02 02 02
kk − (app + aqq )
k6=p,q
X n
= kAk2F − a2kk − (a2pp + 2a2pq + a2qq )
k6=p,q
X n
= kAk2F − a2kk − 2a2pq
k=1
= off(A) − 2a2pq < off(A)2 .
2
68 NUM702S: Numerical Methods 2
Which shows that the size of the off-diagonal part decreases by applying the above similarity
transformation, that is, the off-diagonal elements of A0 are reducing to zero.
c2 − s 2
φ = cot(2θ) = . (3.36)
2cs
If apq 6= 0 and we have to generate a0pq = 0, then using the last equation (i.e Eq. (3.36)) in
Eq. (3.35), we have
0 = (c2 − s2 )apq + cs(app − aqq ). (3.37)
Eq. (3.37) yields
c2 − s 2 app − aqq
= . (3.38)
cs apq
which is used in Eq. (3.36) to solve for φ:
aqq − app
φ= . (3.39)
2apq
Less round-off error is generated if we use tan(θ) in the later computations. So we define
s
t = tan(θ) = . (3.40)
c
NUM702S: Numerical Methods 2 69
s2
1− 2 2
φ= c = 1−t
s 2t
2
c
which gives the equation
t2 + 2tφ − 1 = 0. (3.41)
The smaller root of Eq. (3.41) corresponds to the smaller angle of rotation |θ| ≤ π/4. Solving this
equation, we find that this root is
sign(φ)
t = −φ ± (φ2 + 1)1/2 = (3.42)
|φ| + (φ2 + 1)1/2
where (
1, if φ ≥ 0
sign(φ) =
−1, otherwise
Hence, c and s are found to be
1
c= 2
(t + 1)1/2 (3.43)
s = ct
Example 3.5.1 Use the Jacobi method to find the eigen-pairs of the matrix
√
√1 2 √2
A = 2 √3 2
2 2 1
app = 1, aqq = 1
apq = aqp = 2
1 −1 2apq π
θ = tan = (from Eq. (3.39))
2 aqq − app 4
1
c=s= √
2
70 NUM702S: Numerical Methods 2
p = 1, q = 2
apq = aqp = 2
app = aqq = 3
θ = π/4.
1 1
√ −√ 0
2 2
1 1
J2 = √
√ 0
2 2
0 0 1
5 0 0
A2 = J2T A1 J2 = 0 1 0
0 0 −1
Therefore: λ1 = 5, λ2 = 1, λ3 = −1.
The eigenvectors are the columns of the matrix
√
1/2
√ −1/2
√ −1/ 2
J = J1 J2 = 1/ 2 1/ 2
0√
1/2 −1/2 1/ 2
Hence
√
v1 = [1/2 1/ 2 1/2]T is the eigenvector associated with λ1 = 5,
√
v2 = [−1/2 1/ 2 − 1/2]T is the eigenvector associated with λ2 = 1 and
√ √
v3 = [−1/ 2 0 1/ 2]T is the eigenvector associated with λ3 = −1.