64
An Introduction to the Conjugate Gradient Method Without the Agonizing Pain Edition 1 1 4 Jonathan Richard Shewchuk August 4, 1994 School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213 Abstract The Conjugate Gradient Method is the most prominent iterative method for solving sparse systems of linear equations. Unfortunately, many textbook treatments of the topic are written with neither illustrations nor intuition, and their victims can be found to this day babbling senselessly in the corners of dusty libraries. For this reason, a deep, geometric understanding of the method has been reserved for the elite brilliant few who have painstakingly decoded the mumblings of their forebears. Nevertheless, the Conjugate Gradient Method is a composite of simple, elegant ideas that almost anyone can understand. Of course, a reader as intelligent as yourself will learn them almost effortlessly. The idea of quadratic forms is introduced and used to derive the methods of Steepest Descent, Conjugate Directions, and Conjugate Gradients. Eigenvectors are explained and used to examine the convergence of the Jacobi Method, Steepest Descent, and Conjugate Gradients. Other topics include preconditioning and the nonlinear Conjugate Gradient Method. I have taken pains to make this article easy to read. Sixty-six illustrations are provided. Dense prose is avoided. Concepts are explained in several different ways. Most equations are coupled with an intuitive interpretation. Supported in part by the Natural Sciences and Engineering Research Council of Canada under a 1967 Science and Engineering Scholarship and by the National Science Foundation under Grant ASC-9318163. The views and conclusions contained in this document are those of the author and should not be interpreted as representing the official policies, either express or implied, of NSERC, NSF, or the U.S. Government.

Painless Conjugate Gradient

Embed Size (px)

Citation preview

Page 1: Painless Conjugate Gradient

An Introduction tothe Conjugate Gradient Method

Without the Agonizing PainEdition 1 1

4

Jonathan Richard Shewchuk

August 4, 1994

School of Computer ScienceCarnegie Mellon University

Pittsburgh, PA 15213

Abstract

The Conjugate Gradient Method is the most prominent iterative method for solving sparse systems of linear equations.Unfortunately, many textbook treatments of the topic are written with neither illustrations nor intuition, and theirvictims can be found to this day babbling senselessly in the corners of dusty libraries. For this reason, a deep,geometric understanding of the method has been reserved for the elite brilliant few who have painstakingly decodedthe mumblings of their forebears. Nevertheless, the Conjugate Gradient Method is a composite of simple, elegant ideasthat almost anyone can understand. Of course, a reader as intelligent as yourself will learn them almost effortlessly.

The idea of quadratic forms is introduced and used to derive the methods of Steepest Descent, Conjugate Directions,and Conjugate Gradients. Eigenvectors are explained and used to examine the convergence of the Jacobi Method,Steepest Descent, and Conjugate Gradients. Other topics include preconditioning and the nonlinear Conjugate GradientMethod. I have taken pains to make this article easy to read. Sixty-six illustrations are provided. Dense prose isavoided. Concepts are explained in several different ways. Most equations are coupled with an intuitive interpretation.

Supported in part by the Natural Sciences and Engineering Research Council of Canada under a 1967 Science and EngineeringScholarship and by the National Science Foundation under Grant ASC-9318163. The views and conclusions contained in thisdocument are those of the author and should not be interpreted as representing the official policies, either express or implied, ofNSERC, NSF, or the U.S. Government.

Page 2: Painless Conjugate Gradient

Keywords: conjugate gradient method, preconditioning, convergence analysis, agonizing pain

Page 3: Painless Conjugate Gradient

Contents

1. Introduction 1

2. Notation 1

3. The Quadratic Form 2

4. The Method of Steepest Descent 6

5. Thinking with Eigenvectors and Eigenvalues 95.1. Eigen do it if I try ��������������������������������������������������������������������������� 95.2. Jacobi iterations ����������������������������������������������������������������������������� 115.3. A Concrete Example ������������������������������������������������������������������������� 12

6. Convergence Analysis of Steepest Descent 136.1. Instant Results ������������������������������������������������������������������������������� 136.2. General Convergence ����������������������������������������������������������������������� 17

7. The Method of Conjugate Directions 217.1. Conjugacy ����������������������������������������������������������������������������������� 217.2. Gram-Schmidt Conjugation ����������������������������������������������������������������� 257.3. Optimality of the Error Term ����������������������������������������������������������������� 26

8. The Method of Conjugate Gradients 30

9. Convergence Analysis of Conjugate Gradients 329.1. Picking Perfect Polynomials ����������������������������������������������������������������� 339.2. Chebyshev Polynomials ��������������������������������������������������������������������� 35

10. Complexity 37

11. Starting and Stopping 3811.1. Starting ��������������������������������������������������������������������������������������� 3811.2. Stopping ������������������������������������������������������������������������������������� 38

12. Preconditioning 39

13. Conjugate Gradients on the Normal Equations 41

14. The Nonlinear Conjugate Gradient Method 4214.1. Outline of the Nonlinear Conjugate Gradient Method ��������������������������������������� 4214.2. General Line Search ������������������������������������������������������������������������� 4314.3. Preconditioning ����������������������������������������������������������������������������� 47

A Notes 48

B Canned Algorithms 49B1. Steepest Descent ����������������������������������������������������������������������������� 49B2. Conjugate Gradients ������������������������������������������������������������������������� 50B3. Preconditioned Conjugate Gradients ��������������������������������������������������������� 51

i

Page 4: Painless Conjugate Gradient

B4. Nonlinear Conjugate Gradients with Newton-Raphson and Fletcher-Reeves ����������������� 52B5. Preconditioned Nonlinear Conjugate Gradients with Secant and Polak-Ribiere ������������� 53

C Ugly Proofs 54C1. The Solution to

�����Minimizes the Quadratic Form ������������������������������������� 54

C2. A Symmetric Matrix Has � Orthogonal Eigenvectors. ��������������������������������������� 54C3. Optimality of Chebyshev Polynomials ������������������������������������������������������� 55

D Homework 56

ii

Page 5: Painless Conjugate Gradient

About this Article

An electronic copy of this article is available by anonymous FTP to WARP.CS.CMU.EDU (IP address128.2.209.103) under the filename quake-papers/painless-conjugate-gradient.ps. APostScript file containing full-page copies of the figures herein, suitable for transparencies, is availableas quake-papers/painless-conjugate-gradient-pics.ps. Most of the illustrations werecreated using Mathematica.

c�

1994 by Jonathan Richard Shewchuk. This article may be freely duplicated and distributed so long asno consideration is received in return, and this copyright notice remains intact.

This guide was created to help students learn Conjugate Gradient Methods as easily as possible. Pleasemail me ([email protected]) comments, corrections, and any intuitions I might have missed; some ofthese will be incorporated into a second edition. I am particularly interested in hearing about use of thisguide for classroom teaching.

For those who wish to learn more about iterative methods, I recommend William L. Briggs’ “A MultigridTutorial” [2], one of the best-written mathematical books I have read.

Special thanks to Omar Ghattas, who taught me much of what I know about numerical methods, andprovided me with extensive comments on the first draft of this article. Thanks also to James Epperson,David O’Hallaron, James Stichnoth, Nick Trefethen, and Daniel Tunkelang for their comments.

To help you skip chapters, here’s a dependence graph of the sections:

1 Introduction

2 Notation

10 Complexity

13 Normal Equations

3 Quadratic Form

4 Steepest Descent 5 Eigenvectors

6 SD Convergence7 Conjugate Directions

8 Conjugate Gradients 9 CG Convergence

11 Stop & Start 12 Preconditioning 14 Nonlinear CG

This article is dedicated to every mathematician who uses figures as abundantly as I have herein.

iii

Page 6: Painless Conjugate Gradient

iv

Page 7: Painless Conjugate Gradient

1. Introduction

When I decided to learn the Conjugate Gradient Method (henceforth, CG), I read four different descriptions,which I shall politely not identify. I understood none of them. Most of them simply wrote down the method,then proved its properties without any intuitive explanation or hint of how anybody might have invented CGin the first place. This article was born of my frustration, with the wish that future students of CG will learna rich and elegant algorithm, rather than a confusing mass of equations.

CG is the most popular iterative method for solving large systems of linear equations. CG is effectivefor systems of the form � ����

(1)

where�

is an unknown vector,

is a known vector, and�

is a known, square, symmetric, positive-definite(or positive-indefinite) matrix. (Don’t worry if you’ve forgotten what “positive-definite” means; we shallreview it.) These systems arise in many important settings, such as finite difference and finite elementmethods for solving partial differential equations, structural analysis, circuit analysis, and math homework.

Iterative methods like CG are suited for use with sparse matrices. If�

is dense, your best course ofaction is probably to factor

�and solve the equation by backsubstitution. The time spent factoring a dense�

is roughly equivalent to the time spent solving the system iteratively; and once�

is factored, the systemcan be backsolved quickly for multiple values of

. Compare this dense matrix with a sparse matrix of

larger size that fills the same amount of memory. The triangular factors of a sparse�

usually have manymore nonzero elements than

�itself. Factoring may be impossible due to limited memory, and will be

time-consuming as well; even the backsolving step may be slower than iterative solution. On the otherhand, most iterative methods are memory-efficient and run quickly with sparse matrices.

I assume that you have taken a first course in linear algebra, and that you have a solid understandingof matrix multiplication and linear independence, although you probably don’t remember what thoseeigenthingies were all about. From this foundation, I shall build the edifice of CG as clearly as I can.

2. Notation

Let us begin with a few definitions and notes on notation.

With a few exceptions, I shall use capital letters to denote matrices, lower case letters to denote vectors,and Greek letters to denote scalars.

�is an ����� matrix, and

�and

are vectors — that is, ��� 1 matrices.

Written out fully, Equation 1 is�������

11�

12 ����� �1 ��

21�

22�

2 �...

. . ....� � 1

� � 2 ����� � �����������������

1�2...� �������� � ������

12... �������� �

The inner product of two vectors is written��� �

, and represents the scalar sum ! �"$#1� " � " . Note that��� ���%�&� �

. If�

and�

are orthogonal, then��� ���

0. In general, expressions that reduce to 1 � 1 matrices,such as

��� �and

�'�(���, are treated as scalar values.

Page 8: Painless Conjugate Gradient

2 Jonathan Richard Shewchuk

-4 -2 2 4 6

-6

-4

-2

2

4

�1

�2

3�

1 ) 2�

2�

2

2�

1 ) 6�

2�+*

8

Figure 1: Sample two-dimensional linear system. The solution lies at the intersection of the lines.

A matrix�

is positive-definite if, for every nonzero vector�

,� � ���-,0 � (2)

This may mean little to you, but don’t feel bad; it’s not a very intuitive idea, and it’s hard to imagine howa matrix that is positive-definite might look differently from one that isn’t. We will get a feeling for whatpositive-definiteness is about when we see how it affects the shape of quadratic forms.

Finally, don’t forget the important basic identities . �0/�12�3�4/5� �6�and . �0/7198 1 �4/:8 1 ��8 1.

3. The Quadratic Form

A quadratic form is simply a scalar, quadratic function of a vector with the form; . �<1=� 12� � ���>*? � � )A@ (3)

where�

is a matrix,�

and

are vectors, and @ is a scalar constant. I shall show shortly that if�

is symmetricand positive-definite,

; . �<1 is minimized by the solution to� ����

.

Throughout this paper, I will demonstrate ideas with the simple sample problem�4�CB 3 22 6 D�E F�CB 2*

8 DGE @ � 0 � (4)

The system� �H�I

is illustrated in Figure 1. In general, the solution�

lies at the intersection pointof � hyperplanes, each having dimension � *

1. For this problem, the solution is�%�KJ

2 E * 2 L � . Thecorresponding quadratic form

; . �M1 appears in Figure 2. A contour plot of; . �<1 is illustrated in Figure 3.

Page 9: Painless Conjugate Gradient

The Quadratic Form 3

-4

-20

24

6

-6

-4

-2

0

2

4

0

50

100

150

-4

-20

24

6�1

�2

; . �<1�

1

Figure 2: Graph of a quadratic form N<OQPSR . The minimum point of this surface is the solution to TUPWVYX .

-4 -2 2 4 6

-6

-4

-2

2

4

�1

�2

Figure 3: Contours of the quadratic form. Each ellipsoidal curve has constant N<O$PZR .

Page 10: Painless Conjugate Gradient

4 Jonathan Richard Shewchuk

-4 -2 2 4 6

-8

-6

-4

-2

2

4

6

�1

�2

Figure 4: Gradient NZ[\O$PZR of the quadratic form. For every P , the gradient points in the direction of steepestincrease of N<O$PZR , and is orthogonal to the contour lines.

Because�

is positive-definite, the surface defined by; . �M1 is shaped like a paraboloid bowl. (I’ll have more

to say about this in a moment.)

The gradient of a quadratic form is defined to be

;^] . �M1=� ������__�`

1

; . �<1__�`2

; . �<1...__a`ab ; . �M1

� ����� � (5)

The gradient is a vector field that, for a given point�

, points in the direction of greatest increase of; . �<1 .

Figure 4 illustrates the gradient vectors for Equation 3 with the constants given in Equation 4. At the bottomof the paraboloid bowl, the gradient is zero. One can minimize

; . �<1 by setting; ] . �M1 equal to zero.

With a little bit of tedious math, one can apply Equation 5 to Equation 3, and derive; ] . �M1c� 12� � � ) 1

2���:*? � (6)

If�

is symmetric, this equation reduces to ; ] . �M1c�4� �d*? � (7)

Setting the gradient to zero, we obtain Equation 1, the linear system we wish to solve. Therefore, thesolution to

� �%�eis a critical point of

; . �M1 . If�

is positive-definite as well as symmetric, then this

Page 11: Painless Conjugate Gradient

The Quadratic Form 5

(c)

�1

�2

; . �<1�1

(d)

�1

�2

; . �<1�1

(a)

�1

�2

; . �<1�1

(b)

�1

�2

; . �<1�1

Figure 5: (a) Quadratic form for a positive-definite matrix. (b) For a negative-definite matrix. (c) For asingular (and positive-indefinite) matrix. A line that runs through the bottom of the valley is the set ofsolutions. (d) For an indefinite matrix. Because the solution is a saddle point, Steepest Descent and CGwill not work. In three dimensions or higher, a singular matrix can also have a saddle.

solution is a minimum of; . �M1 , so

���f�Hcan be solved by finding an

�that minimizes

; . �<1 . (If�

is notsymmetric, then Equation 6 hints that CG will find a solution to the system 1

2 . �6� ) �G1g�Y�h. Note that

12 . �6� ) �G1

is symmetric.)

Why do symmetric positive-definite matrices have this nice property? Consider the relationship between;at some arbitrary point i and at the solution point

�W�� 8 1 . From Equation 3 one can show (Appendix C1)that if

�is symmetric (be it positive-definite or not),; .ji 1=� ; . �M1 ) 1

2.ji *Y�<1 � � .ji *k�M1 � (8)

If�

is positive-definite as well, then by Inequality 2, the latter term is positive for all iYl�4�. It follows that�

is a global minimum of;

.

The fact that; . �M1 is a paraboloid is our best intuition of what it means for a matrix to be positive-definite.

If�

is not positive-definite, there are several other possibilities.�

could be negative-definite — the resultof negating a positive-definite matrix (see Figure 2, but hold it upside-down).

�might be singular, in which

case no solution is unique; the set of solutions is a line or hyperplane having a uniform value for;

. If�

is none of the above, then�

is a saddle point, and techniques like Steepest Descent and CG will likely fail.Figure 5 demonstrates the possibilities. The values of

and @ determine where the minimum point of the

paraboloid lies, but do not affect the paraboloid’s shape.

Why go to the trouble of converting the linear system into a tougher-looking problem? The methodsunder study — Steepest Descent and CG — were developed and are intuitively understood in terms ofminimization problems like Figure 2, not in terms of intersecting hyperplanes such as Figure 1.

Page 12: Painless Conjugate Gradient

6 Jonathan Richard Shewchuk

4. The Method of Steepest Descent

In the method of Steepest Descent, we start at an arbitrary point� m

0 n and slide down to the bottom of theparaboloid. We take a series of steps

� m1 n E � m 2 n E ����� until we are satisfied that we are close enough to the

solution�

.

When we take a step, we choose the direction in which;

decreases most quickly, which is the directionopposite

; ] . � m " n 1 . According to Equation 7, this direction is* ; ] . � m " n 1U�o*Y��� m " n .

Allow me to introduce a few definitions, which you should memorize. The error p m " n �q� m " n *A�is a

vector that indicates how far we are from the solution. The residual r m " n ��s*t��� m " n indicates how far weare from the correct value of

. It is easy to see that r m " n �u* � p m " n , and you should think of the residual as

being the error transformed by�

into the same space as. More importantly, r m " n �v* ; ] . � m " n 1 , and you

should also think of the residual as the direction of steepest descent. For nonlinear problems, discussed inSection 14, only the latter definition applies. So remember, whenever you read “residual”, think “directionof steepest descent.”

Suppose we start at� m

0 n �wJx*2 E * 2 L � . Our first step, along the direction of steepest descent, will fall

somewhere on the solid line in Figure 6(a). In other words, we will choose a point� m1 n �4� m

0 n )Ay r m 0 n � (9)

The question is, how big a step should we take?

A line search is a procedure that chooses y to minimize;

along a line. Figure 6(b) illustrates this task:we are restricted to choosing a point on the intersection of the vertical plane and the paraboloid. Figure 6(c)is the parabola defined by the intersection of these surfaces. What is the value of y at the base of theparabola?

From basic calculus, y minimizes;

when the directional derivative zz|{ ; . � m 1 n 1 is equal to zero. By thechain rule, zz|{ ; . � m 1 n 16� ; ] . � m 1 n 1 � zz|{ � m 1 n � ; ] . � m 1 n 1 � r m 0 n . Setting this expression to zero, we find that yshould be chosen so that r m 0 n and

; ] . � m 1 n 1 are orthogonal (see Figure 6(d)).

There is an intuitive reason why we should expect these vectors to be orthogonal at the minimum.Figure 7 shows the gradient vectors at various points along the search line. The slope of the parabola(Figure 6(c)) at any point is equal to the magnitude of the projection of the gradient onto the line (Figure 7,dotted arrows). These projections represent the rate of increase of

;as one traverses the search line.

;is

minimized where the projection is zero — where the gradient is orthogonal to the search line.

To determine y , note that; ] . �(m 1 n 1=�+* r m 1 n , and we haver � m 1 n r m 0 n �

0. s*Y� � m1 n 1 � r m 0 n �

0. o*Y� . � m 0 n )Ay r m 0 n 1}1 � r m 0 n �0. s*Y� � m

0 n 1 � r m 0 n * y . � r m 0 n 1 � r m 0 n �0. s*Y� � m

0 n 1 � r m 0 n � y . � r m 0 n 1 � r m 0 nr � m 0 n r m 0 n � y r � m 0 n . � r m 0 n 1y � r � m 0 n r m 0 nr � m 0 n � r m 0 n �

Page 13: Painless Conjugate Gradient

The Method of Steepest Descent 7

0.2 0.4 0.6

20406080

100120140

-4 -2 2 4 6

-6

-4

-2

2

4

-4 -2 2 4 6

-6

-4

-2

2

4

-2.50

2.55

-5-2.50

2.5050100150

-2.50

2.55

y

(c); . � m " n )Ay r m " n 1

�1

(d)�

2

� m1 n

�1

(a)�

2

� m0 n p m 0 n �

(b)

�1

�2

; . �M1�

1

Figure 6: The method of Steepest Descent. (a) Starting at ~j� 2 ��� 2 ��� , take a step in the direction of steepestdescent of N . (b) Find the point on the intersection of these two surfaces that minimizes N . (c) This parabolais the intersection of surfaces. The bottommost point is our target. (d) The gradient at the bottommost pointis orthogonal to the gradient of the previous step.

-2 -1 1 2 3

-3

-2

-1

1

2

�1

�2

Figure 7: The gradient NZ[ is shown at several locations along the search line (solid arrows). Each gradient’sprojection onto the line is also shown (dotted arrows). The gradient vectors represent the direction ofsteepest increase of N , and the projections represent the rate of increase as one traverses the search line.On the search line, N is minimized where the gradient is orthogonal to the search line.

Page 14: Painless Conjugate Gradient

8 Jonathan Richard Shewchuk

-4 -2 2 4 6

-6

-4

-2

2

4

�1

�2

� m0 n �

Figure 8: Here, the method of Steepest Descent starts at ~j� 2 ��� 2 ��� and converges at ~ 2 �9� 2 ��� .

Putting it all together, the method of Steepest Descent is:r m " n ��U*?���(m " n E (10)y m " n � r � m " n r m " nr � m " n � r m " n E (11)�(m "$�1 n �%�(m " n )Ay m " n r m " n � (12)

The example is run until it converges in Figure 8. Note the zigzag path, which appears because eachgradient is orthogonal to the previous gradient.

The algorithm, as written above, requires two matrix-vector multiplications per iteration. The computa-tional cost of Steepest Descent is dominated by matrix-vector products; fortunately, one can be eliminated.By premultiplying both sides of Equation 12 by

*��and adding

, we haver m "$� 1 n � r m " n * y m " n � r m " n � (13)

Although Equation 10 is still needed to compute r m 0 n , Equation 13 can be used for every iteration thereafter.The product

� r , which occurs in both Equations 11 and 13, need only be computed once. The disadvantageof using this recurrence is that the sequence defined by Equation 13 is generated without any feedback fromthe value of

� m " n , so that accumulation of floating point roundoff error may cause� m " n to converge to some

point near�

. This effect can be avoided by periodically using Equation 10 to recompute the correct residual.

Before analyzing the convergence of Steepest Descent, I must digress to ensure that you have a solidunderstanding of eigenvectors.

Page 15: Painless Conjugate Gradient

Thinking with Eigenvectors and Eigenvalues 9

5. Thinking with Eigenvectors and Eigenvalues

After my one course in linear algebra, I knew eigenvectors and eigenvalues like the back of my head. If yourinstructor was anything like mine, you recall solving problems involving eigendoohickeys, but you neverreally understood them. Unfortunately, without an intuitive grasp of them, CG won’t make sense either. Ifyou’re already eigentalented, feel free to skip this section.

Eigenvectors are used primarily as an analysis tool; Steepest Descent and CG do not calculate the valueof any eigenvectors as part of the algorithm1.

5.1. Eigen do it if I try

An eigenvector � of a matrix/

is a nonzero vector that does not rotate when/

is applied to it (exceptperhaps to point in precisely the opposite direction). � may change length or reverse its direction, but itwon’t turn sideways. In other words, there is some scalar constant � such that

/ � � ��� . The value � isan eigenvalue of

/. For any constant y , the vector y � is also an eigenvector with eigenvalue � , because/ . y � 1c� y / � � � y � . In other words, if you scale an eigenvector, it’s still an eigenvector.

Why should you care? Iterative methods often depend on applying/

to a vector over and over again.When

/is repeatedly applied to an eigenvector � , one of two things can happen. If �����S� 1, then

/ " � � � " �will vanish as � approaches infinity (Figure 9). If ����� , 1, then

/ " � will grow to infinity (Figure 10). Eachtime

/is applied, the vector grows or shrinks according to the value of ����� .

B v

B vv

2�

3�

Bv

Figure 9: � is an eigenvector of � with a corresponding eigenvalue of � 0 � 5. As � increases, ���\� convergesto zero.

Bvv B v B v2�

3�

Figure 10: Here, � has a corresponding eigenvalue of 2. As � increases, � �Q� diverges to infinity.

1However, there are practical applications for eigenvectors. The eigenvectors of the stiffness matrix associated with a discretizedstructure of uniform density represent the natural modes of vibration of the structure being studied. For instance, the eigenvectorsof the stiffness matrix associated with a one-dimensional uniformly-spaced mesh are sine waves, and to express vibrations as alinear combination of these eigenvectors is equivalent to performing a discrete Fourier transform.

Page 16: Painless Conjugate Gradient

10 Jonathan Richard Shewchuk

If/

is symmetric (and often if it is not), then there exists a set of � linearly independent eigenvectorsof/

, denoted � 1 E � 2 E ����� E � � . This set is not unique, because each eigenvector can be scaled by an arbitrarynonzero constant. Each eigenvector has a corresponding eigenvalue, denoted � 1 E � 2 E ����� E � � . These areuniquely defined for a given matrix. The eigenvalues may or may not be equal to each other; for instance,the eigenvalues of the identity matrix � are all one, and every nonzero vector is an eigenvector of � .

What if/

is applied to a vector that is not an eigenvector? A very important skill in understandinglinear algebra — the skill this section is written to teach — is to think of a vector as a sum of other vectorswhose behavior is understood. Consider that the set of eigenvectors �a� "�� forms a basis for � � (because asymmetric

/has � eigenvectors that are linearly independent). Any � -dimensional vector can be expressed

as a linear combination of these eigenvectors, and because matrix-vector multiplication is distributive, onecan examine the effect of

/on each eigenvector separately.

In Figure 11, a vector�

is illustrated as a sum of two eigenvectors � 1 and � 2. Applying/

to�

isequivalent to applying

/to the eigenvectors, and summing the result. On repeated application, we have/ " ���4/ " � 1 ) / " � 2

� � "1 � 1 ) � "2 � 2. If the magnitudes of all the eigenvalues are smaller than one,/ " �

willconverge to zero, because the eigenvectors that compose

�converge to zero when

/is repeatedly applied.

If one of the eigenvalues has magnitude greater than one,�

will diverge to infinity. This is why numericalanalysts attach importance to the spectral radius of a matrix:� . /�1=� max ��� " � E � " is an eigenvalue of

/.

If we want�

to converge to zero quickly, � . /�1 should be less than one, and preferably as small as possible.

B x

B x2�

3�

x

Bxv v1 2

�Figure 11: The vector P (solid arrow) can be expressed as a linear combination of eigenvectors (dashedarrows), whose associated eigenvalues are � 1 V 0 � 7 and � 2 VA� 2. The effect of repeatedly applying � to Pis best understood by examining the effect of � on each eigenvector. When � is repeatedly applied, oneeigenvector converges to zero while the other diverges; hence, ���\P also diverges.

It’s important to mention that there is a family of nonsymmetric matrices that do not have a full set of� independent eigenvectors. These matrices are known as defective, a name that betrays the well-deservedhostility they have earned from frustrated linear algebraists. The details are too complicated to describe inthis article, but the behavior of defective matrices can be analyzed in terms of generalized eigenvectors andgeneralized eigenvalues. The rule that

/ " �converges to zero if and only if all the generalized eigenvalues

have magnitude smaller than one still holds, but is harder to prove.

Here’s a useful fact: the eigenvalues of a positive-definite matrix are all positive. This fact can be provenfrom the definition of eigenvalue: / � � ���� � / � � ��� � � �By the definition of positive-definite, the � �(/ � is positive (for nonzero � ). Hence, � must be positive also.

Page 17: Painless Conjugate Gradient

Thinking with Eigenvectors and Eigenvalues 11

5.2. Jacobi iterations

Of course, a procedure that always converges to zero isn’t going to help you attract friends. Consider a moreuseful procedure: the Jacobi Method for solving

� �3�u. The matrix

�is split into two parts: � , whose

diagonal elements are identical to those of�

, and whose off-diagonal elements are zero; and � , whosediagonal elements are zero, and whose off-diagonal elements are identical to those of

�. Thus,

�� � ) � .We derive the Jacobi Method:� � � � � � * � � ) � � * � 8 1 � � ) � 8 1 � � /W� )A� E where

/ �+* � 8 1 � E � � � 8 1 � (14)

Because � is diagonal, it is easy to invert. This identity can be converted into an iterative method byforming the recurrence � m "��

1 n �/5�(m " n )¡� � (15)

Given a starting vector� m

0 n , this formula generates a sequence of vectors. Our hope is that each successivevector will be closer to the solution

�than the last.

�is called a stationary point of Equation 15, because if� m " n �%�

, then� m "��

1 n will also equal�

.

Now, this derivation may seem quite arbitrary to you, and you’re right. We could have formed anynumber of identities for

�instead of Equation 14. In fact, simply by splitting

�differently — that is,

by choosing a different � and � — we could have derived the Gauss-Seidel method, or the method ofSuccessive Over-Relaxation (SOR). Our hope is that we have chosen a splitting for which

/has a small

spectral radius. Here, I chose the Jacobi splitting arbitrarily for simplicity.

Suppose we start with some arbitrary vector� m

0 n . For each iteration, we apply/

to this vector, then add� to the result. What does each iteration do?

Again, apply the principle of thinking of a vector as a sum of other, well-understood vectors. Expresseach iterate

� m " n as the sum of the exact solution�

and the error term p m " n . Then, Equation 15 becomes� m "��1 n � /W� m " n )A�� / . � ) p m " n 1 )¡�� /W� )A� ) / p m " n� � ) / p m " n (by Equation 14) E¢ p m "�� 1 n � / p m " n � (16)

Each iteration does not affect the “correct part” of� m " n (because

�is a stationary point); but each iteration

does affect the error term. It is apparent from Equation 16 that if � . /�1 � 1, then the error term p m " n willconverge to zero as � approaches infinity. Hence, the initial vector

� m0 n has no effect on the inevitable

outcome!

Of course, the choice of�(m

0 n does affect the number of iterations required to converge to�

withina given tolerance. However, its effect is less important than that of the spectral radius � . /�1 , whichdetermines the speed of convergence. Suppose that �a£ is the eigenvector of

/with the largest eigenvalue

(so that � . /�1¤� �¥£ ). If the initial error p m 0 n , expressed as a linear combination of eigenvectors, includes acomponent in the direction of ��£ , this component will be the slowest to converge.

Page 18: Painless Conjugate Gradient

12 Jonathan Richard Shewchuk

-4 -2 2 4 6

-6

-4

-2

2

4

72

�1

�2

Figure 12: The eigenvectors of T are directed along the axes of the paraboloid defined by the quadraticform N<OQPSR . Each eigenvector is labeled with its associated eigenvalue. Each eigenvalue is proportional tothe steepness of the corresponding slope./

is not generally symmetric (even if�

is), and may even be defective. However, the rate of convergenceof the Jacobi Method depends largely on � . /71 ,which depends on

�. Unfortunately, Jacobi does not converge

for every�

, or even for every positive-definite�

.

5.3. A Concrete Example

To demonstrate these ideas, I shall solve the system specified by Equation 4. First, we need a method offinding eigenvalues and eigenvectors. By definition, for any eigenvector � with eigenvalue � ,� � � ��� � �'�¦�.§�'� *Y�G1 � � 0 �Eigenvectors are nonzero, so ��� *Y�

must be singular. Then,

det .§�'� *?�G1c�0 �

The determinant of ��� *¨�is called the characteristic polynomial. It is a degree � polynomial in �

whose roots are the set of eigenvalues. The characteristic polynomial of�

(from Equation 4) is

detB � * 3

*2*

2 � * 6 D � � 2 * 9 � ) 14� .§� * 7

1 .§� * 21 E

and the eigenvalues are 7 and 2. To find the eigenvector associated with � � 7,.§��� *Y�G1 � �CB 4*

2*2 1 D B � 1� 2 D �

0¢ 4 � 1*

2 � 2�

0 �

Page 19: Painless Conjugate Gradient

Convergence Analysis of Steepest Descent 13

Any solution to this equation is an eigenvector; say, � � J1 E 2 L � . By the same method, we find that

Jx*2 E 1 L �

is an eigenvector corresponding to the eigenvalue 2. In Figure 12, we see that these eigenvectors coincidewith the axes of the familiar ellipsoid, and that a larger eigenvalue corresponds to a steeper slope. (Negativeeigenvalues indicate that

;decreases along the axis, as in Figures 5(b) and 5(d).)

Now, let’s see the Jacobi Method in action. Using the constants specified by Equation 4, we have� m "$�1 n � * B 1

3 00 1

6 D B 0 22 0 D � m " n ) B 1

3 00 1

6 D B 2*8 D� B 0

* 23* 1

3 0 D � m " n ) B 23* 4

3 DThe eigenvectors of

/are

Jj©2 E 1 L � with eigenvalue

*�©2 ª 3, and

Jx*�©2 E 1 L � with eigenvalue

©2 ª 3.

These are graphed in Figure 13(a); note that they do not coincide with the eigenvectors of�

, and are notrelated to the axes of the paraboloid.

Figure 13(b) shows the convergence of the Jacobi method. The mysterious path the algorithm takes canbe understood by watching the eigenvector components of each successive error term (Figures 13(c), (d),and (e)). Figure 13(f) plots the eigenvector components as arrowheads. These are converging normally atthe rate defined by their eigenvalues, as in Figure 11.

I hope that this section has convinced you that eigenvectors are useful tools, and not just bizarre torturedevices inflicted on you by your professors for the pleasure of watching you suffer (although the latter is anice fringe benefit).

6. Convergence Analysis of Steepest Descent

6.1. Instant Results

To understand the convergence of Steepest Descent, let’s first consider the case where p m " n is an eigenvectorwith eigenvalue ��« . Then, the residual r m " n �u*�� p m " n �+* �'«�p m " n is also an eigenvector. Equation 12 givesp m "$� 1 n � p m " n ) r � m " n r m " nr � m " n � r m " n r m " n� p m " n ) r � m " n r m " n� « r � m " n r m " n . * �'«�p m " n 1�

0 �Figure 14 demonstrates why it takes only one step to converge to the exact solution. The point

� m " n lieson one of the axes of the ellipsoid, and so the residual points directly to the center of the ellipsoid. Choosingy m " n � � 8 1« gives us instant convergence.

For a more general analysis, we must express p m " n as a linear combination of eigenvectors, and weshall furthermore require these eigenvectors to be orthonormal. It is proven in Appendix C2 that if

�is

Page 20: Painless Conjugate Gradient

14 Jonathan Richard Shewchuk

-4 -2 2 4 6

-6

-4

-2

2

4

�1

(a)�

2

*0 � 470 � 47

-4 -2 2 4 6

-6

-4

-2

2

4

�1

(b)�

2

� m0 n �

-4 -2 2 4 6

-6

-4

2

4

�1

(c)�

2

p m 0 n -4 -2 2 4 6

-6

-4

-2

2

4

�1

(d)�

2

p m 1 n

-4 -2 2 4 6

-6

-4

-2

2

4

�1

(e)�

2

p m 2 n -4 -2 2 4 6

-6

-4

-2

2

4

�1

(f)�

2

Figure 13: Convergence of the Jacobi Method. (a) The eigenvectors of � are shown with their correspondingeigenvalues. Unlike the eigenvectors of T , these eigenvectors are not the axes of the paraboloid. (b) TheJacobi Method starts at ~�� 2 �9� 2 �¬� and converges at ~ 2 ��� 2 ��� . (c, d, e) The error vectors ­¯® 0 ° , ­¯® 1 ° , ­¯® 2 ° (solidarrows) and their eigenvector components (dashed arrows). (f) Arrowheads represent the eigenvectorcomponents of the first four error vectors. Each eigenvector component of the error is converging to zero atthe expected rate based on its eigenvalue.

Page 21: Painless Conjugate Gradient

Convergence Analysis of Steepest Descent 15

-4 -2 2 4 6

-6

-4

-2

2

4

�1

�2

Figure 14: Steepest Descent converges to the exact solution on the first iteration if the error term is aneigenvector.

symmetric, there exists a set of � orthogonal eigenvectors of�

. As we can scale eigenvectors arbitrarily,let us choose so that each eigenvector is of unit length. This choice gives us the useful property that� �£ �²± �´³ 1 E µ �¶ E

0 E µ l�¶ � (17)

Express the error term as a linear combination of eigenvectorsp m " n � �·£ # 1 ¸ £��a£ E (18)

where ¸ £ is the length of each component of p m " n . From Equations 17 and 18 we have the following identities:r m " n � *�� p m " n �+* · £ ¸ £¯�¥£a�a£ E (19)¹ p m " n ¹ 2 � p � m " n p m " n � · £ ¸ 2£ E (20)p � m " n � p m " n � . · £ ¸ £�� �£ 1 . · £ ¸ £��¥£º�a£ 1� · £ ¸ 2£ �¥£ E (21)¹ r m " n ¹ 2 � r � m " n r m " n � · £ ¸ 2£ � 2£ E (22)r � m " n � r m " n � · £ ¸ 2£ � 3£ � (23)

Page 22: Painless Conjugate Gradient

16 Jonathan Richard Shewchuk

-4 -2 2 4 6

-4

-2

2

4

6

�1

�2

Figure 15: Steepest Descent converges to the exact solution on the first iteration if the eigenvalues are allequal.

Equation 19 shows that r m " n too can be expressed as a sum of eigenvector components, and the length ofthese components are

* ¸ £¯�&£ . Equations 20 and 22 are just Pythagoras’ Law.

Now we can proceed with the analysis. Equation 12 givesp m "$� 1 n � p m " n ) r � m " n r m " nr � m " n � r m " n r m " n� p m " n ) ! £ ¸ 2£ � 2£! £ ¸ 2£ � 3£ r m " n (24)

We saw in the last example that, if p m " n has only one eigenvector component, then convergence isachieved in one step by choosing y m " n � � 8 1« . Now let’s examine the case where p m " n is arbitrary, but all theeigenvectors have a common eigenvalue � . Equation 24 becomesp m "$� 1 n � p m " n ) � 2 ! £ ¸ 2£� 3 ! £ ¸ 2£ . * �'p m " n 1�

0

Figure 15 demonstrates why, once again, there is instant convergence. Because all the eigenvalues areequal, the ellipsoid is spherical; hence, no matter what point we start at, the residual must point to the centerof the sphere. As before, choose y m " n � � 8 1.

Page 23: Painless Conjugate Gradient

Convergence Analysis of Steepest Descent 17

-6 -4 -2 2

-2

2

4

6

8

�1

�2

Figure 16: The energy norm of these two vectors is equal.

However, if there are several unequal, nonzero eigenvalues, then no choice of y m " n will eliminate all theeigenvector components, and our choice becomes a sort of compromise. In fact, the fraction in Equation 24is best thought of as a weighted average of the values of � 8 1£ . The weights ¸ 2£ ensure that longer componentsof p m " n are given precedence. As a result, on any given iteration, some of the shorter components of p m " nmight actually increase in length (though never for long). For this reason, the methods of Steepest Descentand Conjugate Gradients are called roughers. By contrast, the Jacobi Method is a smoother, because everyeigenvector component is reduced on every iteration. Steepest Descent and Conjugate Gradients are notsmoothers, although they are often erroneously identified as such in the mathematical literature.

6.2. General Convergence

To bound the convergence of Steepest Descent in the general case, we shall define the energy norm¹ p ¹9» � .¼p ��� p 1 1 ½ 2 (see Figure 16). This norm is easier to work with than the Euclidean norm, and is insome sense a more natural norm; examination of Equation 8 shows that minimizing

¹ p m " n ¹9» is equivalent to

Page 24: Painless Conjugate Gradient

18 Jonathan Richard Shewchuk

minimizing; . � m " n 1 . With this norm, we have¹ p m "$� 1 n ¹ 2» � p � m "$� 1 n � p m "$� 1 n� .¼p � m " n )ty m " n r � m " n 1�� .¼p m " n )Ay m " n r m " n 1 (by Equation 12)� p � m " n � p m " n ) 2 y m " n r � m " n � p m " n )Ay 2m " n r � m " n � r m " n (by symmetry of

�)� ¹ p m " n ¹ 2» ) 2

r � m " n r m " nr � m " n � r m " n ¾ * r � m " n r m " ng¿ )wÀ r � m " n r m " nr � m " n � r m " n�Á 2 r � m " n � r m " n� ¹ p m " n ¹ 2» * .Âr � m " n r m " n 1 2r � m " n � r m " n� ¹ p m " n ¹ 2» À 1* .Âr � m " n r m " n 1 2.Âr � m " n � r m " n 1 .¼p � m " n � p m " n 1 Á� ¹ p m " n ¹ 2» À 1* . ! £ ¸ 2£ � 2£ 1 2. ! £ ¸ 2£ � 3£ 1 . ! £ ¸ 2£ �¥£ 1 Á (by Identities 21, 22, 23)� ¹ p m " n ¹ 2»(à 2 E à 2 � 1

* . ! £ ¸ 2£ � 2£ 1 2. ! £ ¸ 2£ � 3£ 1 . ! £ ¸ 2£ �¥£ 1 (25)

The analysis depends on finding an upper bound forÃ

. To demonstrate how the weights and eigenvaluesaffect convergence, I shall derive a result for � � 2. Assume that � 1 Ä � 2. The spectral condition numberof�

is defined to be Å � � 1 ª²� 2 Ä 1. The slope of p m " n (relative to the coordinate system defined by theeigenvectors), which depends on the starting point, is denoted Æ � ¸ 2 ª ¸ 1. We haveà 2 �

1* . ¸ 2

1 � 21 ) ¸ 2

2 � 221 2. ¸ 2

1 � 1 ) ¸ 22 � 2

1 . ¸ 21 � 3

1 ) ¸ 22 � 3

21�

1* .¼Å 2 ) Æ 2 1 2.¼Å ) Æ 2

1 .¼Å 3 ) Æ 21 (26)

The value ofÃ

, which determines the rate of convergence of Steepest Descent, is graphed as a functionof Æ and Å in Figure 17. The graph confirms my two examples. If p m 0 n is an eigenvector, then the slope Æis zero (or infinite); we see from the graph that

Ãis zero, so convergence is instant. If the eigenvalues are

equal, then the condition number Å is one; again, we see thatÃ

is zero.

Figure 18 illustrates examples from near each of the four corners of Figure 17. These quadratic formsare graphed in the coordinate system defined by their eigenvectors. Figures 18(a) and 18(b) are exampleswith a large condition number. Steepest Descent can converge quickly if a fortunate starting point is chosen(Figure 18(a)), but is usually at its worst when Å is large (Figure 18(b)). The latter figure gives us our bestintuition for why a large condition number can be bad:

; . �<1 forms a trough, and Steepest Descent bouncesback and forth between the sides of the trough while making little progress along its length. In Figures 18(c)and 18(d), the condition number is small, so the quadratic form is nearly spherical, and convergence is quickregardless of the starting point.

Holding Å constant (because�

is fixed), a little basic calculus reveals that Equation 26 is maximizedwhen Æ �vÇ Å . In Figure 17, one can see a faint ridge defined by this line. Figure 19 plots worst-casestarting points for our sample matrix

�. These starting points fall on the lines defined by ¸ 2 ª ¸ 1

�ÈÇ Å . An

Page 25: Painless Conjugate Gradient

Convergence Analysis of Steepest Descent 19

0

5

10

15

20

1

20

40

60

80

100

0

0.2

0.4

0.6

0.8

0

5

10

15

20ÆÅÃ

ÆFigure 17: Convergence É of Steepest Descent as a function of Ê (the slope of ­¯® � ° ) and Ë (the conditionnumber of T ). Convergence is fast when Ê or Ë are small. For a fixed matrix, convergence is worst whenÊ�V?Ì¤Ë .

-4 -2 2 4

-4

-2

2

4

6

-4 -2 2 4

-4

-2

2

4

6

-4 -2 2 4

-4

-2

2

4

6

-4 -2 2 4

-4

-2

2

4

6

� 1

(c)� 2

� 1

(d)� 2

� 1

(a)� 2

� 1

(b)� 2

Figure 18: These four examples represent points near the corresponding four corners of the graph inFigure 17. (a) Large Ë , small Ê . (b) An example of poor convergence. Ë and Ê are both large. (c) Small Ëand Ê . (d) Small Ë , large Ê .

Page 26: Painless Conjugate Gradient

20 Jonathan Richard Shewchuk

-4 -2 2 4 6

-6

-4

-2

2

4

�1

�2� m

0 n

Figure 19: Solid lines represent the starting points that give the worst convergence for Steepest Descent.Dashed lines represent steps toward convergence. If the first iteration starts from a worst-case point, so doall succeeding iterations. Each step taken intersects the paraboloid axes (gray arrows) at precisely a 45 Íangle. Here, Ë5V 3 � 5.

upper bound forÃ

(corresponding to the worst-case starting points) is found by setting Æ 2 � Å 2:à 2 Î 1* 4 Å 4Å 5 ) 2 Å 4 ) Å 3� Å 5 * 2 Å 4 ) Å 3Å 5 ) 2 Å 4 ) Å 3� .¼Å * 1

1 2.¼Å ) 112à ΠŠ* 1Å ) 1� (27)

Inequality 27 is plotted in Figure 20. The more ill-conditioned the matrix (that is, the larger its conditionnumber Å ), the slower the convergence of Steepest Descent. In Section 9.2, it is proven that Equation 27 isalso valid for � ,

2, if the condition number of a symmetric, positive-definite matrix is defined to beÅ � ��ÏoÐ ` ª²��Ï " � Ethe ratio of the largest to smallest eigenvalue. The convergence results for Steepest Descent are¹ p m " n ¹9» ÎvÑ Å * 1Å ) 1 Ò " ¹ p m 0 n ¹9» E and (28)

Page 27: Painless Conjugate Gradient

The Method of Conjugate Directions 21

20 40 60 80 1000

0.2

0.4

0.6

0.8

1

Å

Ã

Figure 20: Convergence of Steepest Descent (per iteration) worsens as the condition number of the matrixincreases. ; . �(m " n 1�* ; . �M1; . � m 0 n 1Ó* ; . �M1 � 1

2 p � m " n � p m " n12 p � m 0 n � p m 0 n (by Equation 8)Î Ñ Å * 1Å ) 1 Ò 2

" �7. The Method of Conjugate Directions

7.1. Conjugacy

Steepest Descent often finds itself taking steps in the same direction as earlier steps (see Figure 8). Wouldn’tit be better if, every time we took a step, we got it right the first time? Here’s an idea: let’s pick a set oforthogonal search directions Ô m 0 n E Ô m 1 n E ����� E Ô m � 8 1 n . In each search direction, we’ll take exactly one step,and that step will be just the right length to line up evenly with

�. After � steps, we’ll be done.

Figure 21 illustrates this idea, using the coordinate axes as search directions. The first (horizontal) stepleads to the correct

�1-coordinate; the second (vertical) step will hit home. Notice that p m 1 n is orthogonal toÔ m 0 n . In general, for each step we choose a point� m "$�

1 n �4� m " n )Ay m " n Ô m " n � (29)

To find the value of y m " n , use the fact that p m "�� 1 n should be orthogonal to Ô m " n , so that we need never step in

Page 28: Painless Conjugate Gradient

22 Jonathan Richard Shewchuk

-4 -2 2 4 6

-6

-4

-2

2

4

�1

�2

�(m0 n

�� m1 np m 1 nÔ m 0 n

Figure 21: The Method of Orthogonal Directions. Unfortunately, this method only works if you already knowthe answer.

the direction of Ô m " n again. Using this condition, we haveÔ � m " n p m "$� 1 n �0Ô � m " n .¼p m " n )¡y m " n Ô m " n 1Õ�0 (by Equation 29)y m " n � * Ô � m " n p m " nÔ � m " n Ô m " n � (30)

Unfortunately, we haven’t accomplished anything, because we can’t compute y m " n without knowing p m " n ;and if we knew p m " n , the problem would already be solved.

The solution is to make the search directions�

-orthogonal instead of orthogonal. Two vectors Ô m " n andÔ m £ n are�

-orthogonal, or conjugate, if Ô � m " n � Ô m £ n � 0 �Figure 22(a) shows what

�-orthogonal vectors look like. Imagine if this article were printed on bubble

gum, and you grabbed Figure 22(a) by the ends and stretched it until the ellipses appeared circular. Thevectors would then appear orthogonal, as in Figure 22(b).

Our new requirement is that p m "$� 1 n be�

-orthogonal to Ô m " n (see Figure 23(a)). Not coincidentally, thisorthogonality condition is equivalent to finding the minimum point along the search direction Ô m " n , as in

Page 29: Painless Conjugate Gradient

The Method of Conjugate Directions 23

-4 -2 2 4

-4

-2

2

4

�1

�2

(a)

-4 -2 2 4

-4

-2

2

4

�1

�2

(b)

Figure 22: These pairs of vectors are T -orthogonal ���9� because these pairs of vectors are orthogonal.

Steepest Descent. To see this, set the directional derivative to zero:ÔÔ y ; . � m "$� 1 n 1Õ�0; ] . � m "$� 1 n 1 � ÔÔ y � m "$� 1 n �0* r � m "$� 1 n Ô m " n �0Ô � m " n � p m "$� 1 n �0 �

Following the derivation of Equation 30, here is the expression for y m " n when the search directions are�-orthogonal: y m " n � * Ô � m " n � p m " nÔ � m " n � Ô m " n (31)� Ô � m " n r m " nÔ � m " n � Ô m " n � (32)

Unlike Equation 30, we can calculate this expression. Note that if the search vector were the residual, thisformula would be identical to the formula used by Steepest Descent.

Page 30: Painless Conjugate Gradient

24 Jonathan Richard Shewchuk

-4 -2 2 4 6

-6

-4

-2

2

4

�1

�2

� m0 n �� m

1 n p m 1 nÔ m 0 n

(a)

-4 -2 2 4 6

-6

-4

-2

2

4

�1

�2

p m 0 n(b)

Figure 23: The method of Conjugate Directions converges in Ö steps. (a) The first step is taken along somedirection ×¥® 0 ° . The minimum point P'® 1 ° is chosen by the constraint that ­Ø® 1 ° must be T -orthogonal to צ® 0 ° . (b)The initial error ­Ø® 0 ° can be expressed as a sum of T -orthogonal components (gray arrows). Each step ofConjugate Directions eliminates one of these components.

To prove that this procedure really does compute�

in � steps, express the error term as a linearcombination of search directions; namely, p m 0 n � � 8 1·£ # 0 Ù £¯Ô m £ n � (33)

The values of Ù £ can be found by a mathematical trick. Because the search directions are�

-orthogonal, itis possible to eliminate all the Ù £ values but one from Expression 33 by premultiplying the expression byÔ � m ± n � : Ô � m ± n � p m 0 n � · £ Ù m £ n Ô � m ± n � Ô m £ nÔ � m ± n � p m 0 n � Ù m ± n Ô � m ± n � Ô m ± n (by

�-orthogonality of Ô vectors)

Ù m ± n � Ô � m ± n � p m 0 nÔ � m ± n � Ô m ± n� Ô � m ± n � .¼p m 0 n ) ! ± 8 1"$#0 y m " n Ô m " n 1Ô � m ± n � Ô m ± n (by

�-orthogonality of Ô vectors)� Ô � m ± n � p m ± nÔ � m ± n � Ô m ± n (By Equation 29). (34)

By Equations 31 and 34, we find that y m " n �Ú* Ù m " n . This fact gives us a new way to look at the errorterm. As the following equation shows, the process of building up

�component by component can also be

Page 31: Painless Conjugate Gradient

The Method of Conjugate Directions 25

viewed as a process of cutting down the error term component by component (see Figure 23(b)).p m " n � p m 0 n ) " 8 1·£ # 0y m £ n Ô m £ n� � 8 1·£ # 0 Ù m £ n Ô m £ n * " 8 1·£ # 0 Ù m £ n Ô m £ n� � 8 1·£ #^" Ù m £ n Ô m £ n � (35)

After � iterations, every component is cut away, and p m �²n � 0; the proof is complete.

7.2. Gram-Schmidt Conjugation

All that is needed now is a set of�

-orthogonal search directions �¯Ô m " n � . Fortunately, there is a simple wayto generate them, called a conjugate Gram-Schmidt process.

Suppose we have a set of � linearly independent vectors Û 0 E Û 1 E ����� E Û � 8 1. The coordinate axes willdo in a pinch, although more intelligent choices are possible. To construct Ô m " n , take Û " and subtract outany components that are not

�-orthogonal to the previous Ô vectors (see Figure 24). In other words, setÔ m 0 n � Û 0, and for � , 0, set Ô m " n � Û " ) " 8 1·± # 0 Ü " ±ØÔ m ± n E (36)

where the Ü " ± are defined for � ,ݶ. To find their values, use the same trick used to find Ù £ :Ô � m " n � Ô m £ n � Û � " � Ô m £ n ) " 8 1·± # 0 Ü " ±ØÔ � m ± n � Ô m £ n

0� Û � " � Ô m £ n ) Ü " £¯Ô � m £ n � Ô m £ n E � , µ (by

�-orthogonality of Ô vectors)

Ü " £ � * Û � " � Ô m £ nÔ � m £ n � Ô m £ n (37)

The difficulty with using Gram-Schmidt conjugation in the method of Conjugate Directions is that allthe old search vectors must be kept in memory to construct each new one, and furthermore �.� 3 1 operations

u

u

u

u

+

*

1

(0)á

(0)á(1)á

Figure 24: Gram-Schmidt conjugation of two vectors. Begin with two linearly independent vectors â 0 andâ 1. Set ×¥® 0 ° Vkâ 0. The vector â 1 is composed of two components: â�ã , which is T -orthogonal (or conjugate)to ×¥® 0 ° , and âSä , which is parallel to צ® 0 ° . After conjugation, only the T -orthogonal portion remains, and×¥® 1 ° Vkâ�ã .

Page 32: Painless Conjugate Gradient

26 Jonathan Richard Shewchuk

-4 -2 2 4 6

-6

-4

-2

2

4

�1

�2

Figure 25: The method of Conjugate Directions using the axial unit vectors, also known as Gaussianelimination.

are required to generate the full set. In fact, if the search vectors are constructed by conjugation of the axialunit vectors, Conjugate Directions becomes equivalent to performing Gaussian elimination (see Figure 25).As a result, the method of Conjugate Directions enjoyed little use until the discovery of CG — which is amethod of Conjugate Directions — cured these disadvantages.

An important key to understanding the method of Conjugate Directions (and also CG) is to noticethat Figure 25 is just a stretched copy of Figure 21! Remember that when one is performing the methodof Conjugate Directions (including CG), one is simultaneously performing the method of OrthogonalDirections in a stretched (scaled) space.

7.3. Optimality of the Error Term

Conjugate Directions has an interesting property: it finds at every step the best solution within the boundsof where it’s been allowed to explore. Where has it been allowed to explore? Let å " be the � -dimensionalsubspace span �¯Ô m 0 n E Ô m 1 n E ����� E Ô m " 8 1 n � ; the value p m " n is chosen from p m 0 n ) å " . What do I mean by “bestsolution”? I mean that Conjugate Directions chooses the value from p m 0 n ) å " that minimizes

¹ p m " n ¹9» (seeFigure 26). In fact, some authors derive CG by trying to minimize

¹ p m " n ¹9» within p m 0 n ) å " .In the same way that the error term can be expressed as a linear combination of search directions

Page 33: Painless Conjugate Gradient

The Method of Conjugate Directions 27

(0)á(1)

áe (2)

áe(0)á

(1)á e

Figure 26: In this figure, the shaded area is ­Ø® 0 °&ç:è 2 Vk­¯® 0 °Sç span éê×¥® 0 ° �g×¥® 1 °�ë . The ellipsoid is a contour onwhich the energy norm is constant. After two steps, Conjugate Directions finds ­¯® 2 ° , the point on ­Ø® 0 °�ç�è 2

that minimizes ì|­¦ì}í .

(Equation 35), its energy norm can be expressed as a summation.¹ p m " n ¹9» � � 8 1·£ #^" � 8 1·± #^" Ù m £ n Ù m ± n Ô � m £ n � Ô m ± n (by Equation 35)� � 8 1·£ #^" Ù 2m £ n Ô � m £ n � Ô m £ n (by�

-orthogonality of Ô vectors).

Each term in this summation is associated with a search direction that has not yet been traversed. Any othervector p chosen from p m 0 n ) å " must have these same terms in its expansion, which proves that p m " n musthave the minimum energy norm.

Having proven the optimality with equations, let’s turn to the intuition. Perhaps the best way to visualizethe workings of Conjugate Directions is by comparing the space we are working in with a “stretched” space,as in Figure 22. Figures 27(a) and 27(c) demonstrate the behavior of Conjugate Directions in � 2 and � 3 ;lines that appear perpendicular in these illustrations are orthogonal. On the other hand, Figures 27(b) and27(d) show the same drawings in spaces that are stretched (along the eigenvector axes) so that the ellipsoidalcontour lines become spherical. Lines that appear perpendicular in these illustrations are

�-orthogonal.

In Figure 27(a), the Method of Conjugate Directions begins at� m

0 n , takes a step in the direction of Ô m 0 n ,and stops at the point

�(m1 n , where the error vector p m 1 n is

�-orthogonal to Ô m 0 n . Why should we expect

this to be the minimum point on� m

0 n ) å 1? The answer is found in Figure 27(b): in this stretched space,p m 1 n appears perpendicular to Ô m 0 n because they are�

-orthogonal. The error vector p m 1 n is a radius of theconcentric circles that represent contours on which

¹ p ¹9» is constant, so� m

0 n ) å 1 must be tangent at� m

1 nto the circle that

� m1 n lies on. Hence,

�(m1 n is the point on

�(m0 n ) å 1 that minimizes

¹ p m 1 n ¹9» .

This is not surprising; we have already seen in Section 7.1 that�

-conjugacy of the search direction andthe error term is equivalent to minimizing

;(and therefore

¹ p ¹9» ) along the search direction. However,after Conjugate Directions takes a second step, minimizing

¹ p ¹9» along a second search direction Ô m 1 n , whyshould we expect that

¹ p ¹9» will still be minimized in the direction of Ô m 0 n ? After taking � steps, why will; . � m " n 1 be minimized over all of� m

0 n ) å " ?

Page 34: Painless Conjugate Gradient

28 Jonathan Richard Shewchuk

�(m1 n

�r m 1 n

Ô m 0 n Ô m 1 n p m 1 n

� m0 n� m

0 n ) å 1

(a)

�r m 1 n� m

1 n� m

0 n

Ô m 0 n Ô m 1 n p m 1 n� m

0 n ) å 1

(b)

�� m

1 n � m2 nÔ m 0 n

�(m0 n ) å 2

� m0 n

r m 1 nÔ m 1 n� m

0 n ) å 1

(c)

��(m 2 nÔ m 1 n� m1 n

Ô m 0 n�(m

0 nr m 1 n �(m

0 n ) å 2

� m0 n ) å 1

(d)

Figure 27: Optimality of the Method of Conjugate Directions. (a) A two-dimensional problem. Lines thatappear perpendicular are orthogonal. (b) The same problem in a “stretched” space. Lines that appearperpendicular are T -orthogonal. (c) A three-dimensional problem. Two concentric ellipsoids are shown; Pis at the center of both. The line P'® 0 °îçfè 1 is tangent to the outer ellipsoid at P�® 1 ° . The plane P'® 0 °îçfè 2 istangent to the inner ellipsoid at P�® 2 ° . (d) Stretched view of the three-dimensional problem.

Page 35: Painless Conjugate Gradient

The Method of Conjugate Directions 29

In Figure 27(b), Ô m 0 n and Ô m 1 n appear perpendicular because they are�

-orthogonal. It is clear that Ô m 1 nmust point to the solution

�, because Ô m 0 n is tangent at

� m1 n to a circle whose center is

�. However, a

three-dimensional example is more revealing. Figures 27(c) and 27(d) each show two concentric ellipsoids.The point

� m1 n lies on the outer ellipsoid, and

� m2 n lies on the inner ellipsoid. Look carefully at these figures:

the plane� m

0 n ) å 2 slices through the larger ellipsoid, and is tangent to the smaller ellipsoid at� m

2 n . Thepoint

�is at the center of the ellipsoids, underneath the plane.

Looking at Figure 27(c), we can rephrase our question. Suppose you and I are standing at�(m

1 n , andwant to walk to the point that minimizes

¹ p ¹ on� m

0 n ) å 2; but we are constrained to walk along the searchdirection Ô m 1 n . If Ô m 1 n points to the minimum point, we will succeed. Is there any reason to expect that Ô m 1 nwill point the right way?

Figure 27(d) supplies an answer. Because Ô m 1 n is�

-orthogonal to Ô m 0 n , they are perpendicular in thisdiagram. Now, suppose you were staring down at the plane

� m0 n ) å 2 as if it were a sheet of paper; the

sight you’d see would be identical to Figure 27(b). The point� m

2 n would be at the center of the paper,and the point

�would lie underneath the paper, directly under the point

� m2 n . Because Ô m 0 n and Ô m 1 n are

perpendicular, Ô m 1 n points directly to� m

2 n , which is the point in� m

0 n ) å 2 closest to�

. The plane� m

0 n ) å 2

is tangent to the sphere on which� m

2 n lies. If you took a third step, it would be straight down from� m

2 n to�, in a direction

�-orthogonal to å 2.

Another way to understand what is happening in Figure 27(d) is to imagine yourself standing at thesolution point

�, pulling a string connected to a bead that is constrained to lie in

� m0 n ) å " . Each time the

expanding subspace å is enlarged by a dimension, the bead becomes free to move a little closer to you.Now if you stretch the space so it looks like Figure 27(c), you have the Method of Conjugate Directions.

Another important property of Conjugate Directions is visible in these illustrations. We have seen that,at each step, the hyperplane

� m0 n ) å " is tangent to the ellipsoid on which

� m " n lies. Recall from Section 4that the residual at any point is orthogonal to the ellipsoidal surface at that point. It follows that r m " n isorthogonal to å " as well. To show this fact mathematically, premultiply Equation 35 by

* Ô � m " n � :* Ô � m " n � p m £ n � * � 8 1·£ #^" Ù m £ n Ô � m " n � Ô m £ n (38)Ô � m " n r m £ n �0 E �o� µ (by

�-orthogonality of Ô -vectors). (39)

We could have derived this identity by another tack. Recall that once we take a step in a search direction,we need never step in that direction again; the error term is evermore

�-orthogonal to all the old search

directions. Because r m " n �u*�� p m " n , the residual is evermore orthogonal to all the old search directions.

Because the search directions are constructed from the Û vectors, the subspace spanned by Û 0 E ����� E Û " 8 1

is å " , and the residual r m " n is orthogonal to these previous Û vectors as well (see Figure 28). This is provenby taking the inner product of Equation 36 and r m £ n :Ô � m " n r m £ n � Û � " r m £ n ) " 8 1·± # 0 Ü " ±ïÔ � m ± n r m £ n (40)

0� Û � " r m £ n E �U� µ (by Equation 39) � (41)

There is one more identity we will use later. From Equation 40 (and Figure 28),Ô � m " n r m " n � Û � " r m " n � (42)

Page 36: Painless Conjugate Gradient

30 Jonathan Richard Shewchuk

dß r

(0)á(1)

á (2)á (2)

áuu1

u2� e

(2)á

Figure 28: Because the search directions ×¥® 0 ° �g×¥® 1 ° are constructed from the vectors â 0 �2â 1, they span thesame subspace è 2 (the gray-colored plane). The error term ­Ø® 2 ° is T -orthogonal to è 2, the residual 𯮠2 ° isorthogonal to è 2, and a new search direction צ® 2 ° is constructed (from â 2) to be T -orthogonal to è 2. Theendpoints of â 2 and ×¥® 2 ° lie on a plane parallel to è 2, because ×¥® 2 ° is constructed from â 2 by Gram-Schmidtconjugation.

To conclude this section, I note that as with the method of Steepest Descent, the number of matrix-vectorproducts per iteration can be reduced to one by using a recurrence to find the residual:r m "$� 1 n � * � p m "$� 1 n� * � .¼p m " n )¡y m " n Ô m " n 1� r m " n * y m " n � Ô m " n � (43)

8. The Method of Conjugate Gradients

It may seem odd that an article about CG doesn’t describe CG until page 30, but all the machinery is now inplace. In fact, CG is simply the method of Conjugate Directions where the search directions are constructedby conjugation of the residuals (that is, by setting Û " � r m " n ).

This choice makes sense for many reasons. First, the residuals worked for Steepest Descent, so why notfor Conjugate Directions? Second, the residual has the nice property that it’s orthogonal to the previoussearch directions (Equation 39), so it’s guaranteed always to produce a new, linearly independent searchdirection unless the residual is zero, in which case the problem is already solved. As we shall see, there isan even better reason to choose the residual.

Let’s consider the implications of this choice. Because the search vectors are built from the residuals, thesubspace span �ar m 0 n E r m 1 n E ����� E r m " 8 1 n � is equal to å " . As each residual is orthogonal to the previous searchdirections, it is also orthogonal to the previous residuals (see Figure 29); Equation 41 becomesr � m " n r m £ n � 0 E � l� µ � (44)

Interestingly, Equation 43 shows that each new residual r m " n is just a linear combination of the previousresidual and

� Ô m " 8 1 n . Recalling that Ô m " 8 1 nFñ å " , this fact implies that each new subspace å "�� 1 is formedfrom the union of the previous subspace å " and the subspace

� å " . Hence,å " �span �¯Ô m 0 n E � Ô m 0 n E � 2 Ô m 0 n E ����� E � " 8 1 Ô m 0 n ��span �ar m 0 n E � r m 0 n E � 2 r m 0 n E ����� E � " 8 1 r m 0 n � �

Page 37: Painless Conjugate Gradient

The Method of Conjugate Gradients 31

dßr

(0)á(1)

á(2)á(2)

árr(0)á(1)

áe(2)

á

Figure 29: In the method of Conjugate Gradients, each new residual is orthogonal to all the previousresiduals and search directions; and each new search direction is constructed (from the residual) to beT -orthogonal to all the previous residuals and search directions. The endpoints of ða® 2 ° and ×¥® 2 ° lie on aplane parallel to è 2 (the shaded subspace). In CG, ×¥® 2 ° is a linear combination of ða® 2 ° and ×¥® 1 ° .

This subspace is called a Krylov subspace, a subspace created by repeatedly applying a matrix to avector. It has a pleasing property: because

� å " is included in å "$� 1, the fact that the next residual r m "$� 1 nis orthogonal to å "$� 1 (Equation 39) implies that r m "$� 1 n is

�-orthogonal to å " . Gram-Schmidt conjugation

becomes easy, because r m "$� 1 n is already�

-orthogonal to all of the previous search directions except Ô m " n !Recall from Equation 37 that the Gram-Schmidt constants are Ü " £ �ò* r � m " n � Ô m £ n ª�Ô � m £ n � Ô m £ n ; let us

simplify this expression. Taking the inner product of r m " n and Equation 43,r � m " n r m £ � 1 n � r � m " n r m £ n * y m £ n r � m " n � Ô m £ ny m £ n r � m " n � Ô m £ n � r � m " n r m £ n * r � m " n r m £ � 1 nr � m " n � Ô m £ n � óôôõ ôôö1{S÷�øxù r � m " n r m " n E � � µ¦E* 1{S÷úø�û 1 ù r � m " n r m " n E � � µ ) 1 E

0 E otherwise � (By Equation 44.)

¢ Ü " £ � óõ ö 1{S÷�ø$û 1 ù ü}ý÷úøxù ü ÷�øxùz ý ÷úø$û 1 ù » z�÷�ø$û 1 ù E � � µ ) 1 E0 E � , µ ) 1 � (By Equation 37.)

As if by magic, most of the Ü " £ terms have disappeared. It is no longer necessary to store old search vectorsto ensure the

�-orthogonality of new search vectors. This major advance is what makes CG as important

an algorithm as it is, because both the space complexity and time complexity per iteration are reduced fromÞ�.Â� 2 1 to Þ�.Âþ 1 , where þ is the number of nonzero entries of�

. Henceforth, I shall use the abbreviationÜ m " n � Ü "Âÿ " 8 1. Simplifying further:

Ü m " n � r � m " n r m " nÔ � m " 8 1 n r m " 8 1 n (by Equation 32)� r � m " n r m " nr � m " 8 1 n r m " 8 1 n (by Equation 42) �

Page 38: Painless Conjugate Gradient

32 Jonathan Richard Shewchuk

-4 -2 2 4 6

-6

-4

-2

2

4

�1

�2

� m0 n �

Figure 30: The method of Conjugate Gradients.

Let’s put it all together into one piece now. The method of Conjugate Gradients is:Ô m 0 n � r m 0 n ��U*?���(m0 n E (45)y m " n � r � m " n r m " nÔ � m " n � Ô m " n (by Equations 32 and 42) E (46)� m "$�

1 n �4� m " n )Ay m " n Ô m " n Er m "$� 1 n � r m " n * y m " n � Ô m " n E (47)

Ü m "$� 1 n � r � m "$� 1 n r m "$� 1 nr � m " n r m " n E (48)Ô m "$� 1 n � r m "$� 1 n ) Ü m "$� 1 n Ô m " n � (49)

The performance of CG on our sample problem is demonstrated in Figure 30. The name “ConjugateGradients” is a bit of a misnomer, because the gradients are not conjugate, and the conjugate directions arenot all gradients. “Conjugated Gradients” would be more accurate.

9. Convergence Analysis of Conjugate Gradients

CG is complete after � iterations, so why should we care about convergence analysis? In practice,accumulated floating point roundoff error causes the residual to gradually lose accuracy, and cancellation

Page 39: Painless Conjugate Gradient

Convergence Analysis of Conjugate Gradients 33

error causes the search vectors to lose�

-orthogonality. The former problem could be dealt with as it wasfor Steepest Descent, but the latter problem is not easily curable. Because of this loss of conjugacy, themathematical community discarded CG during the 1960s, and interest only resurged when evidence for itseffectiveness as an iterative procedure was published in the seventies.

Times have changed, and so has our outlook. Today, convergence analysis is important because CG iscommonly used for problems so large it is not feasible to run even � iterations. Convergence analysis isseen less as a ward against floating point error, and more as a proof that CG is useful for problems that areout of the reach of any exact algorithm.

The first iteration of CG is identical to the first iteration of Steepest Descent, so without changes,Section 6.1 describes the conditions under which CG converges on the first iteration.

9.1. Picking Perfect Polynomials

We have seen that at each step of CG, the value p m " n is chosen from p m 0 n ) å " , whereå " �span �ar m 0 n E � r m 0 n E � 2 r m 0 n E ����� E � " 8 1 r m 0 n ��span � � p m 0 n E � 2 p m 0 n E � 3 p m 0 n E ����� E � " p m 0 n � �

Krylov subspaces such as this have another pleasing property. For a fixed � , the error term has the formp m " n ���� � ) "·£ # 1 � £ � £��� p m 0 n �The coefficients � £ are related to the values y m " n and Ü m " n , but the precise relationship is not important here.What is important is the proof in Section 7.3 that CG chooses the � £ coefficients that minimize

¹ p m " n ¹9» .

The expression in parentheses above can be expressed as a polynomial. Let � " .§� 1 be a polynomial ofdegree � . � " can take either a scalar or a matrix as its argument, and will evaluate to the same; for instance,if � 2 .§� 1 � 2 � 2 ) 1, then � 2 . ��1�� 2

� 2 ) � . This flexible notation comes in handy for eigenvectors, forwhich you should convince yourself that � " . ��1 � � � " .§� 1 � . (Note that

� � � ��� ,� 2 � � � 2 � , and so on.)

Now we can express the error term as p m " n � � " . �G1 p m 0 n Eif we require that � " . 0 1:� 1. CG chooses this polynomial when it chooses the � £ coefficients. Let’sexamine the effect of applying this polynomial to p m 0 n . As in the analysis of Steepest Descent, express p m 0 nas a linear combination of orthogonal unit eigenvectorsp m 0 n � �·£ # 1 ¸ £���£ Eand we find that p m " n � · £ ¸ £�� " .§�&£ 1 �a£� p m " n � · £ ¸ £�� " .§�&£ 1 �&£��a£¹ p m " n ¹ 2» � · £ ¸ 2£ J � " .§�&£ 1 L 2 �&£ �

Page 40: Painless Conjugate Gradient

34 Jonathan Richard Shewchuk

2 7

-1-0.75-0.5

-0.25

0.250.5

0.751

2 7

-1-0.75-0.5

-0.25

0.250.5

0.751

2 7

-1-0.75-0.5

-0.25

0.250.5

0.751

2 7

-1-0.75-0.5

-0.25

0.250.5

0.751

�(c)� 2 .§� 1

�(d)� 2 .§� 1

�(a)� 0 .§� 1

�(b)� 1 .§� 1

Figure 31: The convergence of CG after � iterations depends on how close a polynomial � � of degree � canbe to zero on each eigenvalue, given the constraint that � � O 0 R V 1.

CG finds the polynomial that minimizes this expression, but convergence is only as good as the convergenceof the worst eigenvector. Letting Λ . ��1 be the set of eigenvalues of

�, we have¹ p m " n ¹ 2» Î min ø max��

Λm » n J � " .§� 1 L 2 · £ ¸ 2£ �&£�

min ø max��Λm » n J � " .§� 1 L 2 ¹ p m 0 n ¹ 2» � (50)

Figure 31 illustrates, for several values of � , the � " that minimizes this expression for our sample problemwith eigenvalues 2 and 7. There is only one polynomial of degree zero that satisfies � 0 . 0 1�� 1, and thatis � 0 .§� 1d� 1, graphed in Figure 31(a). The optimal polynomial of degree one is � 1 .§� 1�� 1

*2� ª 9,

graphed in Figure 31(b). Note that � 1 . 2 16� 5 ª 9 and � 1 . 7 1F�´*5 ª 9, and so the energy norm of the error

term after one iteration of CG is no greater than 5 ª 9 its initial value. Figure 31(c) shows that, after twoiterations, Equation 50 evaluates to zero. This is because a polynomial of degree two can be fit to threepoints ( � 2 . 0 1s� 1, � 2 . 2 1¤� 0, and � 2 . 7 1¤� 0). In general, a polynomial of degree � can fit � ) 1 points,and thereby accommodate � separate eigenvalues.

The foregoing discussing reinforces our understanding that CG yields the exact result after � iterations;and furthermore proves that CG is quicker if there are duplicated eigenvalues. Given infinite floating pointprecision, the number of iterations required to compute an exact solution is at most the number of distincteigenvalues. (There is one other possibility for early termination:

� m0 n may already be

�-orthogonal to

some of the eigenvectors of�

. If eigenvectors are missing from the expansion of� m

0 n , their eigenvaluesmay be omitted from consideration in Equation 50. Be forewarned, however, that these eigenvectors maybe reintroduced by floating point roundoff error.)

Page 41: Painless Conjugate Gradient

Convergence Analysis of Conjugate Gradients 35

-1 -0.5 0.5 1

-2-1.5

-1-0.5

0.51

1.52

-1 -0.5 0.5 1

-2-1.5

-1-0.5

0.51

1.52

-1 -0.5 0.5 1

-2-1.5

-1-0.5

0.51

1.52

-1 -0.5 0.5 1

-2-1.5

-1-0.5

0.51

1.52

Ã

10 . Ã 1Ã

49 . Ã 1

Ã

2 . Ã 1Ã

5 . Ã 1

Figure 32: Chebyshev polynomials of degree 2, 5, 10, and 49.

We also find that CG converges more quickly when eigenvalues are clustered together (Figure 31(d))than when they are irregularly distributed between ��Ï " � and ��ÏoÐ ` , because it is easier for CG to choose apolynomial that makes Equation 50 small.

If we know something about the characteristics of the eigenvalues of�

, it is sometimes possible tosuggest a polynomial that leads to a proof of a fast convergence. For the remainder of this analysis, however,I shall assume the most general case: the eigenvalues are evenly distributed between ��Ï " � and ��ÏsÐ ` , thenumber of distinct eigenvalues is large, and floating point roundoff occurs.

9.2. Chebyshev Polynomials

A useful approach is to minimize Equation 50 over the rangeJ ��Ï " � E ��ÏoÐ ` L rather than at a finite number of

points. The polynomials that accomplish this are based on Chebyshev polynomials.

The Chebyshev polynomial of degree � is " . à 1c� 12 � . à )�� à 2

*11 " ) . Ã * � Ã 2

*11 "�� �

(If this expression doesn’t look like a polynomial to you, try working it out for � equal to 1 or 2.) SeveralChebyshev polynomials are illustrated in Figure 32. The Chebyshev polynomials have the property that� " . Ã 1 � Î 1 (in fact, they oscillate between 1 and

*1) on the domain

à ñ Jx*1 E 1 L , and furthermore that� " . à 1 � is maximum on the domain

à lñ Jx*1 E 1 L among all such polynomials. Loosely speaking, � " . à 1 �

increases as quickly as possible outside the boxes in the illustration.

Page 42: Painless Conjugate Gradient

36 Jonathan Richard Shewchuk

1 2 3 4 5 6 7 8

-1

-0.75

-0.5

-0.25

0.25

0.5

0.75

1

� 2 .§� 1

Figure 33: The polynomial � 2 O\�SR that minimizes Equation 50 for ��� ��� V 2 and ��������V 7 in the general case.This curve is a scaled version of the Chebyshev polynomial of degree 2. The energy norm of the error termafter two iterations is no greater than 0.183 times its initial value. Compare with Figure 31(c), where it isknown that there are only two eigenvalues.

It is shown in Appendix C3 that Equation 50 is minimized by choosing

� " .§� 1c� " ¾ ������ � � ø b 8 2������ 8 � ø b ¿ " ¾ ����� � � ø b ����� 8 � ø b ¿ �

This polynomial has the oscillating properties of Chebyshev polynomials on the domain ��Ï " � Î � Î ��ÏoÐ `(see Figure 33). The denominator enforces our requirement that � " . 0 1c� 1. The numerator has a maximumvalue of one on the interval between ��Ï " � and ��ÏoÐ ` , so from Equation 50 we have¹ p m " n ¹ » Î " Ñ ��ÏoÐ ` ) ��Ï " ���ÏoÐ ` * ��Ï " � Ò 8 1 ¹ p m 0 n ¹ »� " Ñ Å ) 1Å * 1 Ò 8 1 ¹ p m 0 n ¹9»�

2

�� À © Å ) 1© Å * 1 Á " )wÀ © Å * 1© Å ) 1 Á " �� 8 1 ¹ p m 0 n ¹9» � (51)

The second addend inside the square brackets converges to zero as � grows, so it is more common to expressthe convergence of CG with the weaker inequality¹ p m " n ¹9» Î 2 À © Å * 1© Å ) 1 Á " ¹ p m 0 n ¹9» � (52)

Page 43: Painless Conjugate Gradient

Complexity 37

20 40 60 80 1000

0.2

0.4

0.6

0.8

1

Å

Ã

Figure 34: Convergence of Conjugate Gradients (per iteration) as a function of condition number. Comparewith Figure 20.

The first step of CG is identical to a step of Steepest Descent. Setting � � 1 in Equation 51, we obtainEquation 28, the convergence result for Steepest Descent. This is just the linear polynomial case illustratedin Figure 31(b).

Figure 34 charts the convergence per iteration of CG, ignoring the lost factor of 2. In practice, CGusually converges faster than Equation 52 would suggest, because of good eigenvalue distributions or goodstarting points. Comparing Equations 52 and 28, it is clear that the convergence of CG is much quickerthan that of Steepest Descent (see Figure 35). However, it is not necessarily true that every iteration of CGenjoys faster convergence; for example, the first iteration of CG is an iteration of Steepest Descent. Thefactor of 2 in Equation 52 allows CG a little slack for these poor iterations.

10. Complexity

The dominating operations during an iteration of either Steepest Descent or CG are matrix-vector products.In general, matrix-vector multiplication requires Þ�.Âþ 1 operations, where þ is the number of non-zeroentries in the matrix. For many problems, including those listed in the introduction,

�is sparse andþ ñ Þ�.Â� 1 .

Suppose we wish to perform enough iterations to reduce the norm of the error by a factor of ; that is,¹ p m " n ¹ Î ¹ p m 0 n ¹ . Equation 28 can be used to show that the maximum number of iterations required toachieve this bound using Steepest Descent is� Î"! 1

2Å ln Ñ 1# Ò�$ E

whereas Equation 52 suggests that the maximum number of iterations CG requires is� Î%! 12© Å ln Ñ 2# Ò�$ �

Page 44: Painless Conjugate Gradient

38 Jonathan Richard Shewchuk

200 400 600 800 10000

5

10

15

20

25

30

35

40

Å

Ã

Figure 35: Number of iterations of Steepest Descent required to match one iteration of CG.

I conclude that Steepest Descent has a time complexity of Þ�.ÂþfÅ 1 , whereas CG has a time complexity ofÞ�.Âþ © Å 1 . Both algorithms have a space complexity of Þ�.Âþ 1 .Finite difference and finite element approximations of second-order elliptic boundary value problems

posed on Ô -dimensional domains often have Å ñ Þ�.Â� 2 ½ z 1 . Thus, Steepest Descent has a time complexity ofÞ�.Â� 2 1 for two-dimensional problems, versus Þ�.Â� 3 ½ 2 1 for CG; and Steepest Descent has a time complexityof Þ�.Â� 5 ½ 3 1 for three-dimensional problems, versus Þ�.Â� 4 ½ 3 1 for CG.

11. Starting and Stopping

In the preceding presentation of the Steepest Descent and Conjugate Gradient algorithms, several detailshave been omitted; particularly, how to choose a starting point, and when to stop.

11.1. Starting

There’s not much to say about starting. If you have a rough estimate of the value of�

, use it as the startingvalue

� m0 n . If not, set

� m0 n � 0; either Steepest Descent or CG will eventually converge when used to solve

linear systems. Nonlinear minimization (coming up in Section 14) is trickier, though, because there maybe several local minima, and the choice of starting point will determine which minimum the procedureconverges to, or whether it will converge at all.

11.2. Stopping

When Steepest Descent or CG reaches the minimum point, the residual becomes zero, and if Equation 11or 48 is evaluated an iteration later, a division by zero will result. It seems, then, that one must stop

Page 45: Painless Conjugate Gradient

Preconditioning 39

immediately when the residual is zero. To complicate things, though, accumulated roundoff error in therecursive formulation of the residual (Equation 47) may yield a false zero residual; this problem could beresolved by restarting with Equation 45.

Usually, however, one wishes to stop before convergence is complete. Because the error term is notavailable, it is customary to stop when the norm of the residual falls below a specified value; often, thisvalue is some small fraction of the initial residual (

¹ r m " n ¹ �& ¹ r m 0 n ¹ ). See Appendix B for sample code.

12. Preconditioning

Preconditioning is a technique for improving the condition number of a matrix. Suppose that ' is asymmetric, positive-definite matrix that approximates

�, but is easier to invert. We can solve

� �4� indirectly by solving ' 8 1 ����� ' 8 1 � (53)

If Å(.(' 8 1 �G1*) Å(. ��1 , or if the eigenvalues of ' 8 1 � are better clustered than those of�

, we can iterativelysolve Equation 53 more quickly than the original problem. The catch is that ' 8 1 � is not generallysymmetric nor definite, even if ' and

�are.

We can circumvent this difficulty, because for every symmetric, positive-definite ' there is a (notnecessarily unique) matrix � that has the property that ��� �u� ' . (Such an � can be obtained, forinstance, by Cholesky factorization.) The matrices ' 8 1 � and � 8 1 � � 8�� have the same eigenvalues. Thisis true because if � is an eigenvector of ' 8 1 � with eigenvalue � , then � � � is an eigenvector of � 8 1 � � 8��with eigenvalue � : . � 8 1 � � 8�� 1 . � � � 1U� . � � � 8�� 1 � 8 1 � � � � � ' 8 1 � � � �'� � � �

The system� ���

can be transformed into the problem� 8 1 � � 8���+��� � 8 1 E +��� � � � Ewhich we solve first for

+�, then for

�. Because � 8 1 � � 8�� is symmetric and positive-definite,

+�can be

found by Steepest Descent or CG. The process of using CG to solve this system is called the TransformedPreconditioned Conjugate Gradient Method:+Ô m 0 n � +r m 0 n � � 8 1 s* � 8 1 � � 8���+� m 0 n Ey m " n � +r � m " n +r m " n+Ô � m " n � 8 1

� � 8�� +Ô m " n E+� m "$�1 n � +� m " n )Ay m " n +Ô m " n E+r m "$� 1 n � +r m " n * y m " n � 8 1 � � 8�� +Ô m " n EÜ m "�� 1 n � +r � m "$� 1 n +r m "$� 1 n+r � m " n +r m " n E+Ô m "$� 1 n � +r m "$� 1 n ) Ü m "$� 1 n +Ô m " n �

Page 46: Painless Conjugate Gradient

40 Jonathan Richard Shewchuk

-4 -2 2 4 6

-8

-6

-4

-2

�1

�2

Figure 36: Contour lines of the quadratic form of the diagonally preconditioned sample problem.

This method has the undesirable characteristic that � must be computed. However, a few carefulvariable substitutions can eliminate � . Setting

+r m " n � � 8 1 r m " n and+Ô m " n � � � Ô m " n , and using the identities+� m " n � � � � m " n and � 8�� � 8 1 � ' 8 1, we derive the Untransformed Preconditioned Conjugate Gradient

Method: r m 0 n �o*Y� � m0 n EÔ m 0 n � ' 8 1 r m 0 n Ey m " n � r � m " n ' 8 1 r m " nÔ � m " n � Ô m " n E� m "$�

1 n �4� m " n )Ay m " n Ô m " n Er m "�� 1 n � r m " n * y m " n � Ô m " n EÜ m "�� 1 n � r � m "$� 1 n ' 8 1 r m "$� 1 nr � m " n ' 8 1 r m " n EÔ m "$� 1 n � ' 8 1 r m "$� 1 n ) Ü m "$� 1 n Ô m " n �The matrix � does not appear in these equations; only ' 8 1 is needed. By the same means, it is possible

to derive a Preconditioned Steepest Descent Method that does not use � .

The effectiveness of a preconditioner ' is determined by the condition number of ' 8 1 � , and occa-sionally by its clustering of eigenvalues. The problem remains of finding a preconditioner that approximates�

well enough to improve convergence enough to make up for the cost of computing the product ' 8 1 r m " nonce per iteration. (It is not necessary to explicitly compute ' or ' 8 1; it is only necessary to be able tocompute the effect of applying ' 8 1 to a vector.) Within this constraint, there is a surprisingly rich supplyof possibilities, and I can only scratch the surface here.

Page 47: Painless Conjugate Gradient

Conjugate Gradients on the Normal Equations 41

Intuitively, preconditioning is an attempt to stretch the quadratic form to make it appear more spherical,so that the eigenvalues are close to each other. A perfect preconditioner is ' �4�

; for this preconditioner,' 8 1 � has a condition number of one, and the quadratic form is perfectly spherical, so solution takes onlyone iteration. Unfortunately, the preconditioning step is solving the system ' �3�È

, so this isn’t a usefulpreconditioner at all.

The simplest preconditioner is a diagonal matrix whose diagonal entries are identical to those of�

. Theprocess of applying this preconditioner, known as diagonal preconditioning or Jacobi preconditioning, isequivalent to scaling the quadratic form along the coordinate axes. (By comparison, the perfect precondi-tioner ' ��

scales the quadratic form along its eigenvector axes.) A diagonal matrix is trivial to invert,but is often only a mediocre preconditioner. The contour lines of our sample problem are shown, afterdiagonal preconditioning, in Figure 36. Comparing with Figure 3, it is clear that some improvement hasoccurred. The condition number has improved from 3 � 5 to roughly 2 � 8. Of course, this improvement ismuch more beneficial for systems where �-, 2.

A more elaborate preconditioner is incomplete Cholesky preconditioning. Cholesky factorization is atechnique for factoring a matrix

�into the form ./. � , where . is a lower triangular matrix. Incomplete

Cholesky factorization is a variant in which little or no fill is allowed;�

is approximated by the product+. +. � , where+. might be restricted to have the same pattern of nonzero elements as

�; other elements of . are

thrown away. To use+. +. � as a preconditioner, the solution to

+. +. �10 � � is computed by backsubstitution(the inverse of

+. +. � is never explicitly computed). Unfortunately, incomplete Cholesky preconditioning isnot always stable.

Many preconditioners, some quite sophisticated, have been developed. Whatever your choice, it isgenerally accepted that for large-scale applications, CG should nearly always be used with a preconditioner.

13. Conjugate Gradients on the Normal Equations

CG can be used to solve systems where�

is not symmetric, not positive-definite, and even not square. Asolution to the least squares problem

min` ¹ ���>*? ¹ 2 (54)

can be found by setting the derivative of Expression 54 to zero:� � �����4� � � (55)

If�

is square and nonsingular, the solution to Equation 55 is the solution to� ����

. If�

is not square,and

��� �qis overconstrained — that is, has more linearly independent equations than variables — then

there may or may not be a solution to� ���È

, but it is always possible to find a value of�

that minimizesExpression 54, the sum of the squares of the errors of each linear equation.���(�

is symmetric and positive (for any�

,���(���(� ��� ¹ � � ¹ 2 Ä 0). If

� ����is not underconstrained,

then� � �

is nonsingular, and methods like Steepest Descent and CG can be used to solve Equation 55. Theonly nuisance in doing so is that the condition number of

�6�(�is the square of that of

�, so convergence is

significantly slower.

An important technical point is that the matrix�6�(�

is never formed explicitly, because it is less sparsethan

�. Instead,

� � �is multiplied by Ô by first finding the product

� Ô , and then� � � Ô . Also, numerical

Page 48: Painless Conjugate Gradient

42 Jonathan Richard Shewchuk

stability is improved if the value Ô � � � � Ô (in Equation 46) is computed by taking the inner product of� Ô

with itself.

14. The Nonlinear Conjugate Gradient Method

CG can be used not only to find the minimum point of a quadratic form, but to minimize any continuousfunction

; . �M1 for which the gradient; ]

can be computed. Applications include a variety of optimizationproblems, such as engineering design, neural net training, and nonlinear regression.

14.1. Outline of the Nonlinear Conjugate Gradient Method

To derive nonlinear CG, there are three changes to the linear algorithm: the recursive formula for the residualcannot be used, it becomes more complicated to compute the step size y , and there are several differentchoices for Ü .

In nonlinear CG, the residual is always set to the negation of the gradient; r m " n �+* ; ] . � m " n 1 . The searchdirections are computed by Gram-Schmidt conjugation of the residuals as with linear CG. Performing a linesearch along this search direction is much more difficult than in the linear case, and a variety of procedurescan be used. As with the linear CG, a value of y m " n that minimizes

; . � m " n )¡y m " n Ô m " n 1 is found by ensuringthat the gradient is orthogonal to the search direction. We can use any algorithm that finds the zeros of theexpression

J ; ] . � m " n )Ay m " n Ô m " n 1 L � Ô m " n .In linear CG, there are several equivalent expressions for the value of Ü . In nonlinear CG, these different

expressions are no longer equivalent; researchers are still investigating the best choice. Two choices are theFletcher-Reeves formula, which we used in linear CG for its ease of computation, and the Polak-Ribiereformula: Ü3214m "$� 1 n � r � m "�� 1 n r m "$� 1 nr � m " n r m " n E Ü 4m "$� 1 n � r � m "$� 1 n .Âr m "$� 1 n * r m " n 1r � m " n r m " n �

The Fletcher-Reeves method converges if the starting point is sufficiently close to the desired minimum,whereas the Polak-Ribiere method can, in rare cases, cycle infinitely without converging. However, Polak-Ribiere often converges much more quickly.

Fortunately, convergence of the Polak-Ribiere method can be guaranteed by choosing Ü � max � Ü 4 E 0 � .Using this value is equivalent to restarting CG if Ü 4 � 0. To restart CG is to forget the past searchdirections, and start CG anew in the direction of steepest descent.

Here is an outline of the nonlinear CG method:Ô m 0 n � r m 0 n �+* ; ] . � m 0 n 1 EFind y m " n that minimizes

; . �(m " n )ty m " n Ô m " n 1 E� m "$�1 n �4� m " n )Ay m " n Ô m " n Er m "$� 1 n �+* ; ] . � m "$� 1 n 1 EÜ m "$� 1 n � r � m "$� 1 n r m "�� 1 nr � m " n r m " n or Ü m "$� 1 n � max

³ r � m "$� 1 n .Âr m "$� 1 n * r m " n 1r � m " n r m " n E 0 5 E

Page 49: Painless Conjugate Gradient

The Nonlinear Conjugate Gradient Method 43Ô m "$� 1 n � r m "$� 1 n ) Ü m "$� 1 n Ô m " n �Nonlinear CG comes with few of the convergence guarantees of linear CG. The less similar

;is to a

quadratic function, the more quickly the search directions lose conjugacy. (It will become clear shortly thatthe term “conjugacy” still has some meaning in nonlinear CG.) Another problem is that a general function;

may have many local minima. CG is not guaranteed to converge to the global minimum, and may noteven find a local minimum if

;has no lower bound.

Figure 37 illustrates nonlinear CG. Figure 37(a) is a function with many local minima. Figure 37(b)demonstrates the convergence of nonlinear CG with the Fletcher-Reeves formula. In this example, CG isnot nearly as effective as in the linear case; this function is deceptively difficult to minimize. Figure 37(c)shows a cross-section of the surface, corresponding to the first line search in Figure 37(b). Notice that thereare several minima; the line search finds a value of y corresponding to a nearby minimum. Figure 37(d)shows the superior convergence of Polak-Ribiere CG.

Because CG can only generate � conjugate vectors in an � -dimensional space, it makes sense to restartCG every � iterations, especially if � is small. Figure 38 shows the effect when nonlinear CG is restartedevery second iteration. (For this particular example, both the Fletcher-Reeves method and the Polak-Ribieremethod appear the same.)

14.2. General Line Search

Depending on the value of; ]

, it might be possible to use a fast algorithm to find the zeros of; ] � Ô . For

instance, if; ]

is polynomial in y , then an efficient algorithm for polynomial zero-finding can be used.However, we will only consider general-purpose algorithms.

Two iterative methods for zero-finding are the Newton-Raphson method and the Secant method. Bothmethods require that

;be twice continuously differentiable. Newton-Raphson also requires that it be

possible to compute the second derivative of; . � )Ay Ô 1 with respect to y .

The Newton-Raphson method relies on the Taylor series approximation; . � )Ay Ô 176 ; . �M1 )Ay98 ÔÔ y ; . � )ty Ô 1;: { # 0) y 2

2

B Ô 2Ô y 2

; . � )Ay Ô 1 D { # 0

(56)� ; . �M1 )Ay J ; ] . �M1 L � Ô ) y 2

2Ô � ; ] ] . �<1 ÔÔÔ y ; . � )Ay Ô 176 J ; ] . �<1 L � Ô )Ay Ô � ; ] ] . �<1 Ô � (57)

where; ] ] . �<1 is the Hessian matrix

;^] ] . �M1c� �������_ 2 <_�`1_�`

1

_ 2 <_�`1_�`

2����� _ 2 <_�`

1_�` b_ 2 <_�`

2_�`

1

_ 2 <_�`2_�`

2

_ 2 <_�`2_�` b

.... . .

..._ 2 <_�`ab¯_�`1

_ 2 <_�`ab¯_a`2

����� _ 2 <_�`ab�_�`ab�������� �

Page 50: Painless Conjugate Gradient

44 Jonathan Richard Shewchuk

-4

-20

24

6

-2

0

2

4

6

-250

0

250

500

-4

-20

24

6

(a)

�1

�2

; . �<1�

1

-4 -2 2 4 6

-2

2

4

6

�1

(b)�

2

� m0 n

-0.04 -0.02 0.02 0.04

-200

200

400

600

y

(c); . � m " n )Ay Ô m " n 1

-4 -2 2 4 6

-2

2

4

6

�1

(d)�

2

�(m0 n

Figure 37: Convergence of the nonlinear Conjugate Gradient Method. (a) A complicated function with manylocal minima and maxima. (b) Convergence path of Fletcher-Reeves CG. Unlike linear CG, convergencedoes not occur in two steps. (c) Cross-section of the surface corresponding to the first line search. (d)Convergence path of Polak-Ribiere CG.

Page 51: Painless Conjugate Gradient

The Nonlinear Conjugate Gradient Method 45

-4 -2 2 4 6

-2

2

4

6

�1

�2

�(m0 n

Figure 38: Nonlinear CG can be more effective with periodic restarts.

-1 -0.5 0.5 1 1.5 2

-1

-0.75

-0.5

-0.25

0.25

0.5

0.75

1

y��

Figure 39: The Newton-Raphson method for minimizing a one-dimensional function (solid curve). Startingfrom the point P , calculate the first and second derivatives, and use them to construct a quadratic approxi-mation to the function (dashed curve). A new point = is chosen at the base of the parabola. This procedureis iterated until convergence is reached.

Page 52: Painless Conjugate Gradient

46 Jonathan Richard Shewchuk

The function; . � )Ay Ô 1 is approximately minimized by setting Expression 57 to zero, givingy �+* ; ] � ÔÔ � ; ] ] Ô �

The truncated Taylor series approximates; . � )Yy Ô 1 with a parabola; we step to the bottom of the parabola

(see Figure 39). In fact, if;

is a quadratic form, then this parabolic approximation is exact, because; ] ]

isjust the familiar matrix

�. In general, the search directions are conjugate if they are

; ] ]-orthogonal. The

meaning of “conjugate” keeps changing, though, because; ] ]

varies with�

. The more quickly; ] ]

varieswith

�, the more quickly the search directions lose conjugacy. On the other hand, the closer

�(m " n is to thesolution, the less

; ] ]varies from iteration to iteration. The closer the starting point is to the solution, the

more similar the convergence of nonlinear CG is to that of linear CG.

To perform an exact line search of a non-quadratic function, repeated steps must be taken along the lineuntil

; ] � Ô is zero; hence, one CG iteration may include many Newton-Raphson iterations. The values of; ] � Ô and Ô �Ó; ] ] Ô must be evaluated at each step. These evaluations may be inexpensive if Ô ��; ] ] Ô can beanalytically simplified, but if the full matrix

; ] ]must be evaluated repeatedly, the algorithm is prohibitively

slow. For some applications, it is possible to circumvent this problem by performing an approximate linesearch that uses only the diagonal elements of

; ] ]. Of course, there are functions for which it is not possible

to evaluate; ] ]

at all.

To perform an exact line search without computing; ] ]

, the Secant method approximates the secondderivative of

; . � )Yy Ô 1 by evaluating the first derivative at the distinct points y �0 and y �?>

, where>

isan arbitrary small nonzero number:Ô 2Ô y 2

; . � )¡y Ô 1@6 J zz|{ ; . � )Ay Ô 1 L { #BA *ÝJ zz|{ ; . � )Ay Ô 1 L { # 0> > l� 0� J ; ] . � ) > Ô 1 L � Ô *ÝJ ; ] . �M1 L � Ô> E (58)

which becomes a better approximation to the second derivative as y and>

approach zero. If we substituteExpression 58 for the third term of the Taylor expansion (Equation 56), we haveÔÔ y ; . � )Ay Ô 1*6qJ ; ] . �<1 L � Ô ) y >DC J ; ] . � ) > Ô 1 L � Ô *%J ; ] . �M1 L � ÔFE �Minimize

; . � )Ay Ô 1 by setting its derivative to zero:y �u*G> J ; ] . �M1 L � ÔJ ; ] . � ) > Ô 1 L � Ô *ÝJ ; ] . �<1 L � Ô (59)

Like Newton-Raphson, the Secant method also approximates; . � )%y Ô 1 with a parabola, but instead

of choosing the parabola by finding the first and second derivative at a point, it finds the first derivative attwo different points (see Figure 40). Typically, we will choose an arbitrary

>on the first Secant method

iteration; on subsequent iterations we will choose� ) > Ô to be the value of

�from the previous Secant

method iteration. In other words, if we let yIH "�J denote the value of y calculated during Secant iteration � ,then

> H "$� 1J �+* y H "KJ .

Both the Newton-Raphson and Secant methods should be terminated when�

is reasonably close to theexact solution. Demanding too little precision could cause a failure of convergence, but demanding toofine precision makes the computation unnecessarily slow and gains nothing, because conjugacy will break

Page 53: Painless Conjugate Gradient

The Nonlinear Conjugate Gradient Method 47

-1 1 2 3 4

-1.5

-1

-0.5

0.5

1

y��

Figure 40: The Secant method for minimizing a one-dimensional function (solid curve). Starting from thepoint P , calculate the first derivatives at two different points (here, L V 0 and L V 2), and use them toconstruct a quadratic approximation to the function (dashed curve). Notice that both curves have the sameslope at L>V 0, and also at L>V 2. As in the Newton-Raphson method, a new point = is chosen at the baseof the parabola, and the procedure is iterated until convergence.

down quickly anyway if; ] ] . �<1 varies much with

�. Therefore, a quick but inexact line search is often

the better policy (for instance, use only a fixed number of Newton-Raphson or Secant method iterations).Unfortunately, inexact line search may lead to the construction of a search direction that is not a descentdirection. A common solution is to test for this eventuality (is r � Ô nonpositive?), and restart CG if necessaryby setting Ô � r .

A bigger problem with both methods is that they cannot distinguish minima from maxima. The resultof nonlinear CG generally depends strongly on the starting point, and if CG with the Newton-Raphson orSecant method starts near a local maximum, it is likely to converge to that point.

Each method has its own advantages. The Newton-Raphson method has a better convergence rate, and isto be preferred if Ô � ; ] ] Ô can be calculated (or well approximated) quickly (i.e., in Þ�.Â� 1 time). The Secantmethod only requires first derivatives of

;, but its success may depend on a good choice of the parameter

>.

It is easy to derive a variety of other methods as well. For instance, by sampling;

at three different points,it is possible to generate a parabola that approximates

; . � )¡y Ô 1 without the need to calculate even a firstderivative of

;.

14.3. Preconditioning

Nonlinear CG can be preconditioned by choosing a preconditioner ' that approximates; ] ]

and has theproperty that ' 8 1 r is easy to compute. In linear CG, the preconditioner attempts to transform the quadraticform so that it is similar to a sphere; a nonlinear CG preconditioner performs this transformation for a regionnear

� m " n .Even when it is too expensive to compute the full Hessian

; ] ], it is often reasonable to compute its diagonal

Page 54: Painless Conjugate Gradient

48 Jonathan Richard Shewchuk

-4 -2 2 4 6

-2

2

4

6

�1

�2

� m0 n

Figure 41: The preconditioned nonlinear Conjugate Gradient Method, using the Polak-Ribiere formula anda diagonal preconditioner. The space has been “stretched” to show the improvement in circularity of thecontour lines around the minimum.

for use as a preconditioner. However, be forewarned that if�

is sufficiently far from a local minimum, thediagonal elements of the Hessian may not all be positive. A preconditioner should be positive-definite, sononpositive diagonal elements cannot be allowed. A conservative solution is to not precondition (set ' � � )when the Hessian cannot be guaranteed to be positive-definite. Figure 41 demonstrates the convergence ofdiagonally preconditioned nonlinear CG, with the Polak-Ribiere formula, on the same function illustratedin Figure 37. Here, I have cheated by using the diagonal of

; ] ]at the solution point

�to precondition every

iteration.

A Notes

Conjugate Direction methods were probably first presented by Schmidt [14] in 1908, and were independentlyreinvented by Fox, Huskey, and Wilkinson [7] in 1948. In the early fifties, the method of Conjugate Gradientswas discovered independently by Hestenes [10] and Stiefel [15]; shortly thereafter, they jointly publishedwhat is considered the seminal reference on CG [11]. Convergence bounds for CG in terms of Chebyshevpolynomials were developed by Kaniel [12]. A more thorough analysis of CG convergence is provided byvan der Sluis and van der Vorst [16]. CG was popularized as an iterative method for large, sparse matricesby Reid [13] in 1971.

CG was generalized to nonlinear problems in 1964 by Fletcher and Reeves [6], based on work byDavidon [4] and Fletcher and Powell [5]. Convergence of nonlinear CG with inexact line searches wasanalyzed by Daniel [3]. The choice of Ü for nonlinear CG is discussed by Gilbert and Nocedal [8].

A history and extensive annotated bibliography of CG to the mid-seventies is provided by Golub andO’Leary [9]. Most research since that time has focused on nonsymmetric systems. A survey of iterativemethods for the solution of linear systems is offered by Barrett et al. [1].

Page 55: Painless Conjugate Gradient

Canned Algorithms 49

B Canned Algorithms

The code given in this section represents efficient implementations of the algorithms discussed in this article.

B1. Steepest Descent

Given the inputs�

,, a starting value

�, a maximum number of iterations �§ÏoÐ ` , and an error tolerance 5� 1: �NM 0rOM U*?���Ù M r � rÙ 0 M ÙWhile �U�¡� ÏsÐ ` and Ù , 2 Ù 0 doP M � ry M Qü ý�R� M � )Ay rIf � is divisible by 50rSM s*k� �else rSMCr * y PÙ MCr � r�TM � ) 1

This algorithm terminates when the maximum number of iterations �§ÏoÐ ` has been exceeded, or when¹ r m " n ¹ Î ¹ r m 0 n ¹ .The fast recursive formula for the residual is usually used, but once every 50 iterations, the exact residual

is recalculated to remove accumulated floating point error. Of course, the number 50 is arbitrary; for large� ,© � might be appropriate. If the tolerance is large, the residual need not be corrected at all (in practice,

this correction is rarely used). If the tolerance is close to the limits of the floating point precision of themachine, a test should be added after Ù is evaluated to check if Ù Î 2 Ù 0, and if this test holds true, the exactresidual should also be recomputed and Ù reevaluated. This prevents the procedure from terminating earlydue to floating point roundoff error.

Page 56: Painless Conjugate Gradient

50 Jonathan Richard Shewchuk

B2. Conjugate Gradients

Given the inputs�

,, a starting value

�, a maximum number of iterations �§ÏoÐ ` , and an error tolerance 5� 1: �NM 0rUM o*Y���ÔVMCrÙ � «XWYMKr � rÙ 0 M Ù � «XWWhile �c�¨�2ÏoÐ ` and Ù � «;W , 2 Ù 0 doP M � Ôy MZQ b\[(]z ý R� M � )Ay Ô

If � is divisible by 50rOM U*?���else rOM r * y PÙ_^a` z M Ù � «XWÙ � «;WbMCr � rÜ McQ bd[(]Qfe;g hÔiM r ) Ü Ô�NMK� ) 1

See the comments at the end of Section B1.

Page 57: Painless Conjugate Gradient

Canned Algorithms 51

B3. Preconditioned Conjugate Gradients

Given the inputs�

,, a starting value

�, a (perhaps implicitly defined) preconditioner ' , a maximum

number of iterations �§ÏoÐ ` , and an error tolerance �� 1:�NM 0rUM o*Y���ÔVMj' 8 1 rÙ � «XWYMKr � ÔÙ 0 M Ù � «XWWhile �c�¨�2ÏoÐ ` and Ù � «;W , 2 Ù 0 doP M � Ôy MZQ b\[(]z ý R� M � )Ay ÔIf � is divisible by 50rOM U*?���else rOM r * y Pk Mj' 8 1 rÙ_^a` z M Ù � «XWÙ � «;WbMCr � kÜ M Q bd[(]Q e;g hÔiM k ) Ü Ô�NMK� ) 1

The statement “ k Ml' 8 1 r ” implies that one should apply the preconditioner, which may not actuallybe in the form of a matrix.

See also the comments at the end of Section B1.

Page 58: Painless Conjugate Gradient

52 Jonathan Richard Shewchuk

B4. Nonlinear Conjugate Gradients with Newton-Raphson and Fletcher-Reeves

Given a function;

, a starting value�

, a maximum number of CG iterations �2ÏoÐ ` , a CG error tolerance �� 1, a maximum number of Newton-Raphson iterations µ ÏoÐ ` , and a Newton-Raphson error tolerance# � 1: �NM 0¶ M 0rUM * ; ] . �M1ÔVMCrÙ � «XWYMKr � rÙ 0 M Ù � «XWWhile �c�¨�2ÏoÐ ` and Ù � «;W , 2 Ù 0 doµ M 0Ù z MKÔ � ÔDo y M * H <_m m ` n J ý zz ý < m m m ` n z� M � )ty Ôµ M µ ) 1while µ � µ ÏsÐ ` and y 2 Ù z , # 2rSM * ; ] . �<1Ù_^a` z M Ù � «XWÙ � «;WbMCr � rÜ McQ bd[(]Q e;g hÔiM r ) Ü Ô¶ M ¶ ) 1If¶d� � or r � Ô Î 0ÔiMCr¶ M 0�NMK� ) 1

This algorithm terminates when the maximum number of iterations �§ÏoÐ ` has been exceeded, or when¹ r m " n ¹ Î ¹ r m 0 n ¹ .Each Newton-Raphson iteration adds y Ô to

�; the iterations are terminated when each update y Ô falls

below a given tolerance (¹ y Ô ¹ Î #

), or when the number of iterations exceeds µ ÏsÐ ` . A fast inexact linesearch can be accomplished by using a small µ ÏoÐ ` and/or by approximating the Hessian

; ] ] . �<1 with itsdiagonal.

Nonlinear CG is restarted (by setting ÔDM r ) whenever a search direction is computed that is not adescent direction. It is also restarted once every � iterations, to improve convergence for small � .

The calculation of y may result in a divide-by-zero error. This may occur because the starting point� m

0 nis not sufficiently close to the desired minimum, or because

;is not twice continuously differentiable. In

the former case, the solution is to choose a better starting point or a more sophisticated line search. In thelatter case, CG might not be the most appropriate minimization algorithm.

Page 59: Painless Conjugate Gradient

Canned Algorithms 53

B5. Preconditioned Nonlinear Conjugate Gradients with Secant and Polak-Ribiere

Given a function;

, a starting value�

, a maximum number of CG iterations �2ÏoÐ ` , a CG error tolerance �� 1, a Secant method step parameter>

0, a maximum number of Secant method iterations µ ÏoÐ ` , and aSecant method error tolerance

# � 1:�NM 0¶ M 0rOM * ; ] . �<1Calculate a preconditioner ' 6 ; ] ] . �<1k Mn' 8 1 rÔiM kÙ � «;WoM r � ÔÙ 0 M Ù � «;WWhile �U�¨�§ÏoÐ ` and Ù � «XW , 2 Ù 0 doµ M 0Ù z M Ô � Ôy M *G>

0prq ü «;stM J ; ] . � ) > 0 Ô 1 L � ÔDo p M J ; ] . �<1 L � Ôy M y uuwvax [(y 8 u� M � )ty Ôprq ü «XstM pµ M µ ) 1while µ � µ ÏoÐ ` and y 2 Ù z , # 2rOM * ; ] . �M1Ù_^w` z M Ù � «;WÙ Ï " z M r � kCalculate a preconditioner ' 6 ; ] ] . �<1k Mj' 8 1 rÙ � «XWoMCr � kÜ M Q b\[(] 8 Q � ø hQ e;g h¶ M ¶ ) 1If¶d� � or Ü Î 0ÔzM k¶ M 0

else ÔzM k ) Ü Ô�NM � ) 1

This algorithm terminates when the maximum number of iterations �§ÏoÐ ` has been exceeded, or when¹ r m " n ¹ Î ¹ r m 0 n ¹ .Each Secant method iteration adds y Ô to

�; the iterations are terminated when each update y Ô falls below

a given tolerance (¹ y Ô ¹ Î # ), or when the number of iterations exceeds µ ÏoÐ ` . A fast inexact line search can

be accomplished by using a small µ ÏoÐ ` . The parameter>

0 determines the value of>

in Equation 59 for thefirst step of each Secant method minimization. Unfortunately, it may be necessary to adjust this parameter

Page 60: Painless Conjugate Gradient

54 Jonathan Richard Shewchuk

to achieve convergence.

The Polak-Ribiere Ü parameter is Q b\[�] 8 Q � ø hQ e;g h � ü ý ÷úøK{ 1 ù}| ÷úøK{ 1 ù 8 ü}ý÷úøK{ 1 ù}| ÷úøjùü ý ÷úøjù | ÷úøjù � ü}ý÷úø�{ 1 ù�~ û 1m ü ÷�ø�{ 1 ù 8 ü ÷úøjù nü ý ÷úøjù ~ û 1 ü ÷úøjù . Care must

be taken that the preconditioner ' is always positive-definite. The preconditioner is not necessarily in theform of a matrix.

Nonlinear CG is restarted (by setting Ô�M r ) whenever the Polak-Ribiere Ü parameter is negative. It isalso restarted once every � iterations, to improve convergence for small � .

Nonlinear CG presents several choices: Preconditioned or not, Newton-Raphson method or Secantmethod or another method, Fletcher-Reeves or Polak-Ribiere. It should be possible to construct any of thevariations from the versions presented above. (Polak-Ribiere is almost always to be preferred.)

C Ugly Proofs

C1. The Solution to� ���

Minimizes the Quadratic Form

Suppose�

is symmetric. Let�

be a point that satisfies��� �

and minimizes the quadratic form(Equation 3), and let p be an error term. Then; . � ) p 1Õ� 1

2. � ) p 1 � � . � ) p 1�*? � . � ) p 1 )A@ (by Equation 3)� 1

2

� � � � ) p � � � ) 12p � � p *? � �d*t � p )A@ (by symmetry of

�)� 1

2� � � �d*? � � )t@U) p � ) 1

2p � � p *? � p� ; . �<1 ) 1

2p � � p �

If�

is positive-definite, then the latter term is positive for all p�l� 0; therefore�

minimizes;

.

C2. A Symmetric Matrix Has � Orthogonal Eigenvectors.

Any matrix has at least one eigenvector. To see this, note that det . �u* �'� 1 is a polynomial in � , andtherefore has at least one zero (possibly complex); call it � » . The matrix

�* � » � has determinant zeroand is therefore singular, so there must be a nonzero vector � for which . �4* � » � 1 � � 0. The vector � isan eigenvector, because

� � � � » � .

Any symmetric matrix has a full complement of � orthogonal eigenvectors. To prove this, I willdemonstrate for the case of a 4 � 4 matrix

�and let you make the obvious generalization to matrices of

arbitrary size. It has already been proven that�

has at least one eigenvector � with eigenvalue � » . Let�1� ��ª ¹ � ¹ , which has unit length. Choose three arbitrary vectors

�2 E � 3 E � 4 so that the

� " are mutuallyorthogonal and all of unit length (such vectors can be found by Gram-Schmidt orthogonalization). Let� �´J �

1�

2�

3�

4 L . Because the� " are orthonormal,

� � � � � , and so� �?� � 8 1. Note also that for

Page 61: Painless Conjugate Gradient

Ugly Proofs 55�G�� 1, ���1 � ��� � ���� � � 1� ����3��� � 1

� 0. Thus,

� � � � � ����� ���1� �2� �3���4������ ��� � 1 � 2 � 3 � 4 � ������� ���1� �2� �3���4

������ � ��� � 1 � � 2 � � 3 � � 4 �� ����� ��� 0 0 0

00 �0

��������where � is a 3 � 3 symmetric matrix. � must have some eigenvalue � with eigenvalue ��� . Let �� be avector of length 4 whose first element is zero, and whose remaining elements are the elements of � . Clearly,

� � 1 � � �� � � � � � �� ������� � � 0 0 000 �0

������ �� � ��� ��¢¡In other words, � � �� � ��� � �� , and thus

� �� is an eigenvector of � . Furthermore, � �1 � �� �£1 0 0 0 ¤¥�� � 0, so � 1 and

� �� are orthogonal. Thus, � has at least two orthogonal eigenvectors!

The more general statement that a symmetric matrix has ¦ orthogonal eigenvectors is proven by induction.For the example above, assume any 3 � 3 matrix (such as � ) has 3 orthogonal eigenvectors; call them �� 1,�� 2, and �� 3. Then

� �� 1,� �� 2, and

� �� 3 are eigenvectors of � , and they are orthogonal because�

has orthonormal columns, and therefore maps orthogonal vectors to orthogonal vectors. Thus, � has 4orthogonal eigenvectors.

C3. Optimality of Chebyshev Polynomials

Chebyshev polynomials are optimal for minimization of expressions like Expression 50 because theyincrease in magnitude more quickly outside the range

£�§1 � 1 ¤ than any other polynomial that is restricted to

have magnitude no greater than one inside the range£�§

1 � 1 ¤ .The Chebyshev polynomial of degree ¨ ,© ��ª}«­¬ � 1

2 � ª}«o®�¯ « 2 ® 1 ¬ � ®°ª}« § ¯ « 2§

1 ¬ � � �can also be expressed on the region

£�§1 � 1 ¤ as© �aª}«­¬ � cos ª�¨ cos

� 1 «­¬ � §1 ±²«³± 1 ¡

From this expression (and from Figure 32), one can deduce that the Chebyshev polynomials have theproperty ´ © ��ª}«­¬ ´ ± 1 � §

1 ±³«9± 1

and oscillate rapidly between§

1 and 1:© �Tµ cos µ3¶¸·¨º¹*¹ � ª § 1 ¬w» � ¶ � 0 � 1 � ¡�¡�¡ � ¨¼¡

Page 62: Painless Conjugate Gradient

56 Jonathan Richard Shewchuk

Notice that the ¨ zeros of© � must fall between the ¨�® 1 extrema of

© � in the range£�§

1 � 1 ¤ . For an example,see the five zeros of

©5 ª}«­¬ in Figure 32.

Similarly, the function ½ �¼ª � ¬ � © �1¾À¿rÁFÂ�Ã�ÄB¿ ÁBÅ�Æ � 2 ¿¿ ÁFÂ�à � ¿ ÁFÅKÆ�Ç© � ¾�¿ ÁFÂ�à ÄB¿ ÁFÅKÆ¿ ÁFÂ�à � ¿ ÁFÅKÆ Çoscillates in the range È © ��ª_¿rÁFÂ�Ã_ÄB¿ ÁFÅKÆ¿rÁFÂ�à � ¿ ÁFÅKÆ ¬ � 1 on the domain

£ �ÊÉ �ÌË � ��ÉIͼΠ¤ . ½ ��ª � ¬ also satisfies the requirementthat

½ �aª 0 ¬ � 1.

The proof relies on a cute trick. There is no polynomial ÏÐ�¼ª � ¬ of degree ¨ such that ÏÐ��ª 0 ¬ � 1 and ÏÐ�is better than

½ � on the range£ � É �ÌË � � ɭͼΠ¤ . To prove this, suppose that there is such a polynomial; then,ÏÐ��ª � ¬ÐÑ © ��ª ¿rÁFÂaÃrÄB¿ ÁFÅKÆ¿rÁFÂ�à � ¿ ÁFÅKÆ ¬ � 1 on the range

£ �ÊÉ �ÌË � ��ÉIÍÒÎ ¤ . It follows that the polynomial

½ � § ÏÐ� has a zeroat � � 0, and also has ¨ zeros on the range

£ �ÊÉ ��Ë � ��ÉIͼΠ¤ . Hence,

½ � § ÏU� is a polynomial of degree ¨ withat least ¨1® 1 zeros, which is impossible. By contradiction, I conclude that the Chebyshev polynomial ofdegree ¨ optimizes Expression 50.

D Homework

For the following questions, assume (unless otherwise stated) that you are using exact arithmetic; there isno floating point roundoff error.

1. (Easy.) Prove that the preconditioned Conjugate Gradient method is not affected if the preconditioningmatrix is scaled. In other words, for any nonzero constant Ó , show that the sequence of steps�ÕÔ 0 Ö � �ÕÔ 1 Ö � ¡�¡�¡ taken using the preconditioner ÓB× is identical to the steps taken using the preconditioner× .

2. (Hard, but interesting.) Suppose you wish to solve � � �lØ for a symmetric, positive-definite¦Ù�Ú¦ matrix � . Unfortunately, the trauma of your linear algebra course has caused you to repressall memories of the Conjugate Gradient algorithm. Seeing you in distress, the Good Eigenfairymaterializes and grants you a list of the Û distinct eigenvalues (but not the eigenvectors) of � .However, you do not know how many times each eigenvalue is repeated.

Clever person that you are, you mumbled the following algorithm in your sleep this morning:

Choose an arbitrary starting point � Ô 0 ÖFor ¨TÜ 0 to Û § 1Ý Ô � Ö Ü Ø § � �ÕÔ � Ö

Remove an arbitrary eigenvalue from the list and call it � ��ÕÔ � Ä 1 Ö Üj�ÕÔ � Ö ® � � 1� Ý Ô � ÖNo eigenvalue is used twice; on termination, the list is empty.

(a) Show that upon termination of this algorithm, � Ô�Þ Ö is the solution to � � �°Ø . Hint: Read Section6.1 carefully. Graph the convergence of a two-dimensional example; draw the eigenvector axes,and try selecting each eigenvalue first. (It is most important to intuitively explain what thealgorithm is doing; if you can, also give equations that prove it.)

Page 63: Painless Conjugate Gradient

Homework 57

(b) Although this routine finds the exact solution after Û iterations, you would like each intermediateiterate � Ô � Ö to be as close to the solution as possible. Give a crude rule of thumb for how youshould choose an eigenvalue from the list on each iteration. (In other words, in what ordershould the eigenvalues be used?)

(c) What could go terribly wrong with this algorithm if floating point roundoff occurs?

(d) Give a rule of thumb for how you should choose an eigenvalue from the list on each iteration toprevent floating point roundoff error from escalating. Hint: The answer is not the same as thatof question (b).

Page 64: Painless Conjugate Gradient

58 Jonathan Richard Shewchuk

References

[1] Richard Barrett, Michael Berry, Tony Chan, James Demmel, June Donato, Jack Dongarra, VictorEijkhout, Roldan Pozo, Charles Romine, and Henk van der Vorst, Templates for the Solution of LinearSystems: Building Blocks for Iterative Methods, SIAM, Philadelphia, Pennsylvania, 1993.

[2] William L. Briggs, A Multigrid Tutorial, SIAM, Philadelphia, Pennsylvania, 1987.

[3] James W. Daniel, Convergence of the Conjugate Gradient Method with Computationally ConvenientModifications, Numerische Mathematik 10 (1967), 125–131.

[4] W. C. Davidon, Variable Metric Method for Minimization, Tech. Report ANL-5990, Argonne NationalLaboratory, Argonne, Illinois, 1959.

[5] R. Fletcher and M. J. D. Powell, A Rapidly Convergent Descent Method for Minimization, ComputerJournal 6 (1963), 163–168.

[6] R. Fletcher and C. M. Reeves, Function Minimization by Conjugate Gradients, Computer Journal 7(1964), 149–154.

[7] L. Fox, H. D. Huskey, and J. H. Wilkinson, Notes on the Solution of Algebraic Linear SimultaneousEquations, Quarterly Journal of Mechanics and Applied Mathematics 1 (1948), 149–173.

[8] Jean Charles Gilbert and Jorge Nocedal, Global Convergence Properties of Conjugate GradientMethods for Optimization, SIAM Journal on Optimization 2 (1992), no. 1, 21–42.

[9] Gene H. Golub and Dianne P. O’Leary, Some History of the Conjugate Gradient and Lanczos Algo-rithms: 1948–1976, SIAM Review 31 (1989), no. 1, 50–102.

[10] Magnus R. Hestenes, Iterative Methods for Solving Linear Equations, Journal of Optimization Theoryand Applications 11 (1973), no. 4, 323–334, Originally published in 1951 as NAML Report No. 52-9,National Bureau of Standards, Washington, D.C.

[11] Magnus R. Hestenes and Eduard Stiefel, Methods of Conjugate Gradients for Solving Linear Systems,Journal of Research of the National Bureau of Standards 49 (1952), 409–436.

[12] Shmuel Kaniel, Estimates for Some Computational Techniques in Linear Algebra, Mathematics ofComputation 20 (1966), 369–378.

[13] John K. Reid, On the Method of Conjugate Gradients for the Solution of Large Sparse Systems ofLinear Equations, Large Sparse Sets of Linear Equations (London and New York) (John K. Reid, ed.),Academic Press, London and New York, 1971, pp. 231–254.

[14] E. Schmidt, Title unknown, Rendiconti del Circolo Matematico di Palermo 25 (1908), 53–77.

[15] Eduard Stiefel, Uber einige Methoden der Relaxationsrechnung, Zeitschrift fur Angewandte Mathe-matik und Physik 3 (1952), no. 1, 1–33.

[16] A. van der Sluis and H. A. van der Vorst, The Rate of Convergence of Conjugate Gradients, NumerischeMathematik 48 (1986), no. 5, 543–560.