Docsity

Numerical Linear Algebra, Lecture Notes - Mathematics - 6, Study notes of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
11 The Conjugate Gradient Method
We now construct an iterative method for symmetric positive definite matrices. Let A∈
Rn×nbe symmetric positive definite and b∈Rn. We wish to solve the linear system
Ax=b.
Associated with this system we have a function, f, given by
f(x):=1
2xTAx−xTb.
We can calculate the first order and second order derivatives as
∇f(x)=Ax−b,
Hf(x)=A,
here ∇f=(∂1f,...,∂bf) is the gradient of fand Hf =(∂2
ijf)ij is the Hessian matrix of
f. Since all higher order derivatives vanish, we can rewrite fas its Taylor polynomial of
degree two as
f(x)=f(y)+(x−y)T∇f(y)+ 1
2(x−y)THf(y)(x−y)
=f(y)+(x−y)T(Ay−b)+ 1
2(x−y)TA(x−y)
≥f(y)+(x−y)T(Ay−b),
where, in the last step, we have used that Ais positive definite. Thus, if∗y=x∗solves
Ax=b, we see that f(x)≥f(x∗), i.e. x∗minimises f. On the other hand, every minimiser
yof fhas to satisfy the necessary condition 0=∇f(y)=Ay−b. This is only possible
for y=x∗.
Theorem 11.1 Let A∈Rn×nbe symmetric and positive definite. The solution of the
system Ax=bis equivalent to the unique minimum of the function f(y):=1
2yTAy−yTb.
We wi l l n ow t r y t o find t h e m inim um of fby a simple iterative procedure of the form
xj+1 =xj+αjpj.
Here, xjis our current position. From this position we want to move into the direction
of pj. The step-length of our move is determined by αj. Of course, it will be our goal to
select the direction pjand the step-length αjin such a way that
f(xj+1)≤f(xj).
∗Throughout this section we will use x∗as the solution of Ax=b.
42
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Numerical Linear Algebra, Lecture Notes - Mathematics - 6 and more Study notes Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

11 The Conjugate Gradient Method

We now construct an iterative method for symmetric positive definite matrices. Let A ∈

R

n×n be symmetric positive definite and b ∈ R

n

. We wish to solve the linear system

Ax = b.

Associated with this system we have a function, f , given by

f (x) :=

x

T Ax − x

T b.

We can calculate the first order and second order derivatives as

∇f (x) = Ax − b,

Hf (x) = A,

here ∇f = (∂ 1 f,... , ∂bf ) is the gradient of f and Hf = (∂

2 ij f^ )ij^ is the Hessian matrix of

f. Since all higher order derivatives vanish, we can rewrite f as its Taylor polynomial of

degree two as

f (x) = f (y) + (x − y)

T ∇f (y) +

(x − y)

T Hf (y)(x − y)

= f (y) + (x − y)

T (Ay − b) +

(x − y)

T A(x − y)

≥ f (y) + (x − y)

T (Ay − b),

where, in the last step, we have used that A is positive definite. Thus, if

∗ y = x

∗ solves

Ax = b, we see that f (x) ≥ f (x

∗ ), i.e. x

∗ minimises f. On the other hand, every minimiser

y of f has to satisfy the necessary condition 0 = ∇f (y) = Ay − b. This is only possible

for y = x

∗ .

Theorem 11.1 Let A ∈ R

n×n be symmetric and positive definite. The solution of the

system Ax = b is equivalent to the unique minimum of the function f (y) :=

1 2

y

T Ay−y

T b.

We will now try to find the minimum of f by a simple iterative procedure of the form

xj+1 = xj + αj pj.

Here, xj is our current position. From this position we want to move into the direction

of pj. The step-length of our move is determined by αj. Of course, it will be our goal to

select the direction pj and the step-length αj in such a way that

f (xj+1) ≤ f (xj ).

∗Throughout this section we will use x∗ (^) as the solution of Ax = b.

Given a new direction pj , the best possible step-length in that direction can be determined

by looking at the minimum of f along the line xj +αpj. Hence, if we set φ(α) = f (xj +αpj )

the necessary condition for a minimum yields

0 = φ

′ (α) = p

T j ∇f^ (xj^ +^ αpj^ ) =^ p

T j [A(xj^ +^ αpj^ )^ −^ b] =^ p

T j Axj^ +^ αp

T j Apj^ −^ p

T j b.

Resolving this for α gives the new step-length as

αj =

p

T j (b^ −^ Axj^ )

p

T j Apj

p

T j rj

p

T j Apj

where we have define the residual of the jth step as rj = b − Axj. Thus we have the

following generic algorithm.

Algorithm 2: Generic Minimisation

Choose x 1 and p 1.

for j = 1, 2 ,... do

αj =

p

T j rj

pT j Apj

xj+1 = xj + αj pj

Choose next direction pj+

Note that we pick αj in such a way that

0 = p

T j (Axj+1^ −^ b) =^ −p

T j rj+1,^ (19)

showing that pj and rj+1 are orthogonal.

Obviously, we still have to determine how to choose the search directions. One possible

way is to pick the direction of steepest descent. It can be shown that this direction is given

by the negative gradient of the target function, i.e. by

pj = −∇f (xj ) = −(Axj − b) = rj.

This gives

Algorithm 3: Steepest Descent

Choose x 1

Set p 1 = b − Ax 1

for j = 1, 2 ,... do

αj =

p

T j pj

p

T j Apj xj+1 = xj + αj pj

pj+1 = b − Axj+

Thus, it would make sense to introduce a new coordinate system by setting y = A

1 / 2 x, in

which the function becomes g(y) = f (A

− 1 / 2 y) =

1 2

y

T y. Following this idea, we transform

the positions by setting yj = A

1 / 2 xj and the directions by sj = A

1 / 2 pj. If the new search

directions are orthogonal as shown in the right part of the figure above, we find the minimum

in two steps. Moreover, being orthogonal now translates back into 0 = s

T j sj+1^ =^ p

T j Apj+1.

Definition 11.3 The search directions p 1 ,... , pn ∈ R

n \ { 0 } are called A-conjugate for a

given positive definite and symmetric matrix A ∈ R

n×n if p

T j Apk^ = 0^ for all^1 ≤^ j^ &=^ k^ ≤^ n.

Remark 11.4 • Since A is positive definite, we have p

T j Apj^ >^0.

  • We can introduce an inner product via 〈x, y〉A := x

T Ay. With respect to this inner

product, the search directions are orthogonal.

  • A-conjugate directions are linearly independent.

For conjugate directions it turns out that the generic algorithm terminates after n steps,

so that the method is actually a direct method.

Theorem 11.5 Let A ∈ R

n×n be symmetric and positive definite. Let x 1 ∈ R

n be given

and assume that the search directions p 1 ,... , pn ∈ R

n \ { 0 } are A-conjugate. The generic

Algorithm 2 terminates after at most n steps with the solution x

∗ of Ax = b.

Proof: Since the search directions form a basis of R

n we can represent the vector x

∗ − x 1

in this basis, which means that we can find β 1 ,... , βn with

x

∗ = x 1 +

∑^ n

j=

βj pj.

Furthermore, from the generic algorithm, we can conclude that the iterations have the

representation

xk = x 1 +

∑^ k−^1

j=

αj pj , 1 ≤ k ≤ n + 1. (20)

Hence, it is sufficient to show that αi = βi for all 1 ≤ i ≤ n. We know that

αi =

p

T i ri

p

T i Api

To compute the βi’s, we first observe that

b − Ax 1 = A(x

∗ − x 1 ) =

∑^ n

j=

βj Apj

and hence

p

T i (b^ −^ Ax^1 ) =

∑^ n

j=

βj p

T i Apj^ =^ βip

T i Api,

because the directions are A-conjugate. This gives the explicit representation

βi =

pT i (b − Ax 1 )

pT i Api

pT i r 1

pT i Api

, 1 ≤ i ≤ n,

which differs, at first sight, from the αi’s in the numerator. Fortunately, from (20) we can

conclude that

ri = r 1 +

∑^ i−^1

j=

αj Apj

and hence

p

T i ri^ =^ p

T i r^1 −

∑^ i−^1

j=

αj p

T i Apj^ =^ p

T i r^1

employing again the fact that the directions are A-conjugate.Thus we have αi = βi for all

i.!

It remains to answer the question on how the search directions are actually determined.

Obviously, we do not want to determine them a priori but while we iterate, hoping for our

iteration to terminate significantly before the iteration step becomes n.

Assume we already have created directions p 1 ,... pj. In the case of Axj+1 = b we can

terminate the algorithm and hence do not need to compute another direction. Otherwise,

we could try to compute the next direction by setting

pj+1 = b − Axj+1 +

j ∑

k=

βjkpk = rj+1 +

j ∑

k=

βjkpk,

where we can determine the coefficients from the j conditions

0 = p

T j+1Api^ =^ r

T j+1Api^ +

j ∑

k=

βjkp

T k Api

= r

T j+1Api^ +^ βjip

T i Api,^1 ≤^ i^ ≤^ j.

as

βji = −

r

T j+1Api

pT i Api

, 1 ≤ i ≤ j.

Surprisingly, βj 1 ,... , βj,j− 1 vanish automatically, as we will see later on, so that only the

coefficient

βj+1 = βj,j = −

r

T j+1Apj

pT j Apj

which finishes the induction step for (2). Similarly, we proceed for (1). First of all, we

have

p

T i+1Apj^ = (r

T i+1 +^ βi+1p

T i )Apj^ =^ r

T i+1Apj^ +^ βi+1p

T i Apj^.

In the case of j = i this leads to

p

T i+1Api^ =^ r

T i+1Api^ −^

r

T i+1Api

pT i Api

p

T i Api^ = 0.

In the case of j ≤ i − 1 we first observe that αj = 0 particularly means p

T j rj^ =^ r

T j rj^ = 0,

which is equivalent to rj = 0. Thus if αj = 0 the iteration would have stopped before.

We hence may assume that αj &= 0 such that we can use (21) to gain the representation

Apj = (rj − rj+1)/αj. Together with (2) for i + 1 this leads to

p

T i+1Apj^ =^ r

T i+1Apj^ =^

αj

r

T i+1(rj^ −^ rj+1) = 0.

This proves (1) for i+1. Finally, for (3) we use the fact that f (x) =

1 2

x

T Ax−b

T x attains its

minimum in the direction of pi at xi+1. This means that the function ϕ(t) = f (xi+1 + tpi)

satisfies ϕ

′ (0) = 0, which, using the chain rule, is equivalent to

0 = ϕ

′ (0) = p

T i ∇f^ (xi+1) =^ p

T i (Axi+1^ −^ b) =^ −p

T i ri+1.

From this, we can conclude that

p

T i+1ri+1^ =^ r

T i+1ri+1^ +^ βi+1p

T i ri+1^ =^ r

T i+1ri+1,

which finalises our induction step.

For the computation of the next iteration step, we need that pi+1 &= 0. If this is not the

case the method terminates. Since 0 = p

T i+1ri+1^ =^ ‖ri+1‖

2 2 and hence^ ri+1^ =^0 =^ b^ −^ Axi+

we have produced a solution. If the method does not terminate early then, after n steps, we

have created n conjugate directions and Theorem 11.5 shows that xn+1 is the true solution

x

∗

.!

It is possible to improve the preliminary version of the CG method. First of all, we can

get rid of the matrix vector multiplication in the definition of rj+1 by using (21).

Moreover, from (21) it follows that Apj =

1 αj (rj^ −^ rj+1) such that

βj+1 = −

r

T j+1Apj

p

T j Apj

αj

r

T j+1rj^ −^ r

T j+1rj+

p

T j Apj

r

T j+1rj+

p

T j Apj

p

T j Apj

p

T j rj

r

T j+1rj+

r

T j rj

This leads to a version of the CG method, which can easily be run on a parallel computer,

and which contains only one matrix-vector multiplication and three inner products and

three scalar-vector multiplications.

Algorithm 5: CG method

Choose x 1.

Set p 1 = r 1 = b − Ax 1 and j = 1.

while ‖rj ‖ 2 > & do

αj = ‖rj ‖

2 2 /p

T j Apj^ % store^ Apj

xj+1 = xj + αj pj

rj+1 = rj − αj Apj

βj+1 = ‖rj+1‖

2 2 /‖rj^ ‖

2 2 % store^ ‖rj+1‖

2 2 pj+1 = rj+1 + βj+1pj

j = j + 1

In the following theorems we show some of the properties of the CG algorithm.

We will investigate convergence in the energy norm ‖x‖A =

〈x, x〉.

Definition 11.7 Let A ∈ R

n×n and p ∈ R

n be given. For i ∈ N we define the ith Krylov-

space to A and p as

Ki(p, A) = span{p, Ap,... , A

i− 1 p}

In general, we only have dim(Ki(p, A)) ≤ i, since p could, for example, be from the null

space of A. Fortunately, in our situation things are much better.

Lemma 11.8 Let A ∈ R

n×n be symmetric and positive definite. Let pi and ri be the

vectors created during the CG iterations. Then,

Ki(p 1 , A) = span{p 1 ,... , pi} = span{r 1 ,... , ri}

for 1 ≤ i ≤ n. In particular, we have dim(Ki(p 1 , A)) = i.

Proof: For i = 1 this follows because of p 1 = r 1. For general i + 1 it follows by employing

the relation pi+1 = ri+1 + βi+1pi = ri − αiApi + βi+1pi, which is a consequence of (21).!

Recall that the true solution x

∗ of Ax = b and the iterations xi of the CG method can be

written as

x

∗ = x 1 +

∑^ n

j=

αj pj and xi = x 1 +

∑^ i−^1

j=

αj pj.

Moreover, by Lemma 11.8, it is possible to represent an arbitrary element x ∈ x 1 +

Ki− 1 (p 1 , A) by

x = x 1 +

∑^ i−^1

j=

βj pj.

Theorem 11.11 Let A ∈ R

n×n be symmetric and positive definite, having the eigenvalues

0 < λ 1 <... < λn. If x

∗ denotes the solution of Ax = b and if xi denotes the iterations

from the CG method, then

‖x

∗ − xi‖A ≤ min P ∈πi− 1 P (0)=

max 1 ≤j≤n

|P (λj )|‖x

∗ − x 1 ‖A.

Proof: Let us express an arbitrary x ∈ x 1 + Ki− 1 (p 1 , A) as

x = x 1 +

∑^ i−^1

j=

βj A

j− 1 p 1 =: x 1 + Q(A)p 1

introducing the polynomial Q(t) =

∑i− 1

j=

αj t

j− 1 ∈ πi− 2 , where we set Q = 0 for i = 1. This

gives

‖x

∗ − x‖

2 A =^ ‖x

∗ − x 1 − Q(A)p 1 ‖

2 A

= (x

∗ − x 1 − Q(A)p 1 )

T A(x

∗ − x 1 − Q(A)p 1 )

= (x

∗ − x 1 )

T (I − Q(A)A)A(I − Q(A)A)(x

∗ − x 1 )

=: (x

∗ − x 1 )

T P (A)AP (A)(x

∗ − x 1 ),

since p 1 = A(x

∗ − x 1 ) and since the matrix I − Q(A)A is symmetric. For the polynomial

P we have P (t) = 1 −

∑i− 1

j=1 αj^ t

j showing particularly P (0) = 1. On the other hand, if

P ∈ πi− 1 with P (0) = 1 is given then we can define Q(t) = (P (t) − 1)/t ∈ πi− 2 , which

leads to an element from x 1 + Ki− 1 (p 1 , A), for which the calculation above holds. Thus,

Theorem 11.9 yields

‖x

∗ − xi‖

2 A ≤^ Pmin ∈π i− 1 P (0)=

(x

∗ − x 1 )

T P (A)AP (A)(x

∗ − x 1 ). (22)

Next, let w 1 ,... , wn be an orthonormal basis of R

n consisting of eigenvectors of A asso-

ciated to the eigenvalues λ 1 ,... , λn. Then, we can represent every vector using this basis

and with such a representation x

∗ − x 1 =

ρj wj we can conclude that

P (A)(x

∗ − x 1 ) =

n ∑

j=

ρj P (λj )wj

holds, which leads to

(x

∗ − x 1 )

T P (A)AP (A)(x

∗ − x 1 ) =

∑^ n

k,j=

ρkρj P (λj )

2 λj w

T k wj

∑^ n

j=

ρ

2 j P^ (λj^ )

2 λj ≤ max 1 ≤j≤n

P (λj )

2

∑^ n

j=

ρ

2 j λj

= max 1 ≤j≤n

P (λj )

2 ‖x

∗ − x 1 ‖

2 A.

Plugging this into (22) gives the desired inequality.!

Hence, we have converted the weighted, continuous L 2 approximation problem into a dis-

crete *∞ approximation problem. Since the eigenvalues are in general unknown, this can

be converted into a continuous L∞ approximation problem by further estimating

‖x − xi‖A ≤ min P ∈πi− 1 (R) P (0)=

‖P ‖L∞[λ 1 ,λn]‖x − x 1 ‖A,

where ‖P ‖L∞[a,b] = maxx∈[a,b] |P (x)|. Note that λ 1 and λn can be replaced by estimates

λ^ ˜ 1 ≤^ λ 1 and^

˜λ n ≥^ λn.

The solution of this approximation problem can be computed explicitly. Its solution in-

volves the Chebyshev polynomials defined by

Tn(t) = cos(n arccos(t)), t ∈ [0, 1].

Theorem 11.12 Let λn > λ 1 > 0. The problem min{‖P ‖L∞[λ 1 ,λn] : P ∈ πi− 1 , P (0) = 1}

has the solution

P

∗ (t) = Ti− 1

λn + λ 1 − 2 t

λn − λ 1

/Ti− 1

λn + λ 1

λn − λ 1

, t ∈ [λ 1 , λn].

The Chebyshev polynomials satisfy the following inequalities

t

t

)n

≤ Tn

1 + t

1 − t

, t ∈ [0, 1),

Tn(t) ≤ 1 , t ∈ [− 1 , 1].

To apply this estimates, we set γ = λ 1 /λn ∈ (0, 1) and use

λn + λ 1

λn − λ 1

1 + γ

1 − γ

as well as λn + λ 1 − 2 t

λn − λ 1

∈ [− 1 , 1], t ∈ [λ 1 , λ 2 ].

This altogether gives the final estimate on the convergence of the CG method. We have

‖x − xi‖A ≤ min P ∈πi− 1 P (0)=

‖P ‖L∞[λ 1 ,λn]‖x − x 1 ‖A

Ti− 1

λn+λ 1 − 2 t λn−λ 1

Ti− 1

λn+λ 1 λn−λ 1

) ‖x − x 1 ‖A

Ti− 1

1+γ 1 −γ

)‖x − x 1 ‖A

γ

γ

)i− 1

‖x − x 1 ‖A.

Finally using the fact that 1/γ = κ 2 (A) shows that we have the following result.