The Conjugate Gradient Method for Solving Linear Systems of Equations

Similar documents
EECS 275 Matrix Computation

The Conjugate Gradient Method

the method of steepest descent

Notes on Some Methods for Solving Linear Systems

An Iterative Descent Method

Iterative Methods for Solving A x = b

Numerical Linear Algebra Primer. Ryan Tibshirani Convex Optimization

Conjugate Gradient Tutorial

1 Conjugate gradients

Iterative methods for Linear System of Equations. Joint Advanced Student School (JASS-2009)

Iterative methods for Linear System

Preconditioning Techniques Analysis for CG Method

Computational Linear Algebra

Applied Mathematics 205. Unit V: Eigenvalue Problems. Lecturer: Dr. David Knezevic

The amount of work to construct each new guess from the previous one should be a small multiple of the number of nonzeros in A.

Numerical Linear Algebra Primer. Ryan Tibshirani Convex Optimization /36-725

APPENDIX A. Background Mathematics. A.1 Linear Algebra. Vector algebra. Let x denote the n-dimensional column vector with components x 1 x 2.

Chapter 7 Iterative Techniques in Matrix Algebra

7.2 Steepest Descent and Preconditioning

Conjugate Gradient (CG) Method

From Stationary Methods to Krylov Subspaces

Conjugate Gradient Method

Solutions and Notes to Selected Problems In: Numerical Optimzation by Jorge Nocedal and Stephen J. Wright.

6.4 Krylov Subspaces and Conjugate Gradients

Computational Linear Algebra

Lecture Note 7: Iterative methods for solving linear systems. Xiaoqun Zhang Shanghai Jiao Tong University

Topics. The CG Algorithm Algorithmic Options CG s Two Main Convergence Theorems

Linear Solvers. Andrew Hazel

Conjugate gradient method. Descent method. Conjugate search direction. Conjugate Gradient Algorithm (294)

Notes on PCG for Sparse Linear Systems

Jordan Journal of Mathematics and Statistics (JJMS) 5(3), 2012, pp A NEW ITERATIVE METHOD FOR SOLVING LINEAR SYSTEMS OF EQUATIONS

Lecture Notes: Geometric Considerations in Unconstrained Optimization

CS137 Introduction to Scientific Computing Winter Quarter 2004 Solutions to Homework #3

Key words. conjugate gradients, normwise backward error, incremental norm estimation.

Lecture 9: Krylov Subspace Methods. 2 Derivation of the Conjugate Gradient Algorithm

MAC Module 1 Systems of Linear Equations and Matrices I

Lecture 2: Linear Algebra Review

Numerical Solution Techniques in Mechanical and Aerospace Engineering

Some minimization problems

Introduction - Motivation. Many phenomena (physical, chemical, biological, etc.) are model by differential equations. f f(x + h) f(x) (x) = lim

Numerical Methods for Inverse Kinematics

Direct Methods for Solving Linear Systems. Matrix Factorization

M.A. Botchev. September 5, 2014

Lecture 9: Numerical Linear Algebra Primer (February 11st)

Chapter 10 Conjugate Direction Methods

Jim Lambers MAT 610 Summer Session Lecture 2 Notes

Numerical Methods - Numerical Linear Algebra

Research Article Some Generalizations and Modifications of Iterative Methods for Solving Large Sparse Symmetric Indefinite Linear Systems

Math 5630: Conjugate Gradient Method Hung M. Phan, UMass Lowell March 29, 2019

Math 411 Preliminaries

Linear Systems of n equations for n unknowns

Gradient Descent. Sargur Srihari

Lecture 11: CMSC 878R/AMSC698R. Iterative Methods An introduction. Outline. Inverse, LU decomposition, Cholesky, SVD, etc.

A Review of Linear Algebra

Iterative techniques in matrix algebra

AM 205: lecture 8. Last time: Cholesky factorization, QR factorization Today: how to compute the QR factorization, the Singular Value Decomposition

Course Notes: Week 4

Lecture 1: Systems of linear equations and their solutions

The Conjugate Gradient Method

AMS526: Numerical Analysis I (Numerical Linear Algebra) Lecture 23: GMRES and Other Krylov Subspace Methods; Preconditioning

Preface to the Second Edition. Preface to the First Edition

Lec10p1, ORF363/COS323

you expect to encounter difficulties when trying to solve A x = b? 4. A composite quadrature rule has error associated with it in the following form

Matrix Basic Concepts

MATRICES. a m,1 a m,n A =

4.6 Iterative Solvers for Linear Systems

Numerical Linear Algebra

January 29, Non-linear conjugate gradient method(s): Fletcher Reeves Polak Ribière January 29, 2014 Hestenes Stiefel 1 / 13

Penalty and Barrier Methods. So we again build on our unconstrained algorithms, but in a different way.

CME 302: NUMERICAL LINEAR ALGEBRA FALL 2005/06 LECTURE 6

Lecture # 20 The Preconditioned Conjugate Gradient Method

Lecture 22. r i+1 = b Ax i+1 = b A(x i + α i r i ) =(b Ax i ) α i Ar i = r i α i Ar i

Some Notes on Linear Algebra

Numerical optimization. Numerical optimization. Longest Shortest where Maximal Minimal. Fastest. Largest. Optimization problems

EAD 115. Numerical Solution of Engineering and Scientific Problems. David M. Rocke Department of Applied Science

9.1 Preconditioned Krylov Subspace Methods

Chapter 4. Unconstrained optimization

Applied Mathematics 205. Unit II: Numerical Linear Algebra. Lecturer: Dr. David Knezevic

Stat 206: Linear algebra

Journal of Computational and Applied Mathematics. New matrix iterative methods for constraint solutions of the matrix

Lab 1: Iterative Methods for Solving Linear Systems

Linear Algebra Section 2.6 : LU Decomposition Section 2.7 : Permutations and transposes Wednesday, February 13th Math 301 Week #4

Basic Concepts in Linear Algebra

Next topics: Solving systems of linear equations

Advanced Digital Signal Processing -Introduction

Conjugate Gradient Method

AMS526: Numerical Analysis I (Numerical Linear Algebra)

CSC 576: Linear System

Review: From problem to parallel algorithm

Jae Heon Yun and Yu Du Han

Conjugate-Gradient. Learn about the Conjugate-Gradient Algorithm and its Uses. Descent Algorithms and the Conjugate-Gradient Method. Qx = b.

B553 Lecture 5: Matrix Algebra Review

CS 542G: Robustifying Newton, Constraints, Nonlinear Least Squares

Gershgorin s Circle Theorem for Estimating the Eigenvalues of a Matrix with Known Error Bounds

MATH 315 Linear Algebra Homework #1 Assigned: August 20, 2018

7.3 The Jacobi and Gauss-Siedel Iterative Techniques. Problem: To solve Ax = b for A R n n. Methodology: Iteratively approximate solution x. No GEPP.

Review of Basic Concepts in Linear Algebra

Classical iterative methods for linear systems

KRYLOV SUBSPACE ITERATION

Lagrange Multipliers

Transcription:

The Conjugate Gradient Method for Solving Linear Systems of Equations Mike Rambo Mentor: Hans de Moor May 2016 Department of Mathematics, Saint Mary s College of California

Contents 1 Introduction 2 2 Relevant Definitions and Notation 2 3 Linearization of Partial Differential Equations 4 4 The Mechanisms of the Conjugate Gradient Method 6 4.1 Steepest Descent......................................... 6 4.2 Conjugate Directions....................................... 12 4.3 Conjugate Gradient Method................................... 14 5 Preconditioning 18 6 Efficiency 19 7 Conclusion 20 8 References 21 1

Abstract The Conjugate Gradient Method is an iterative technique for solving large sparse systems of linear equations. As a linear algebra and matrix manipulation technique, it is a useful tool in approximating solutions to linearized partial differential equations. The fundamental concepts are introduced and utilized as the foundation for the derivation of the Conjugate Gradient Method. Alongside the fundamental concepts, an intuitive geometric understanding of the Conjugate Gradient Method s details are included to add clarity. A detailed and rigorous analysis of the theorems which prove the Conjugate Gradient algorithm are presented. Extensions of the Conjugate Gradient Method through preconditioning the system in order to improve the efficiency of the Conjugate Gradient Method are discussed. 1 Introduction The Method of Conjugate Gradients (cg-method) was initially introduced as a direct method for solving large systems of n simultaneous equations and n unknowns. Eduard Stiefel of the Institute of Applied Mathematics at Zürich and Magnus Hestenes of the Institute for Numerical Analysis, met at a symposium held at the Institute for Numerical Analysis in August 1951 where one of the topics discussed was solving systems of simultaneous linear equations. Hestenes and Stiefel collaborated to write the first papers on the method, published as early as December 1952. During the next two decades, the cgmethod was utilized heavily, but not accepted by the numerical analysis community due to a lack of understanding of the algorithms and their speed. Hestenes and Stiefel had suggested the use of the cg-method as an iterative technique for well-conditioned problems; however, it was not until the early 1970 s that researchers were drawn to the cg-method as an iterative method. In current research the cgmethod is understood as an iterative technique with a focus on improving and extending the cg-method to include different classes of problems such as unconstrained optimization or singular matrices. 2 Relevant Definitions and Notation Throughout this paper, the following definitions and terminology will be utilized for the cg-method. Defintion 2.1. Partial Differential Equations (PDEs): an equation in which the solution is a function which has two or more independent variables. Remark. The cg-method is utilized to estimate solutions to linear PDEs. Linear PDEs are PDEs in which the unknown function and its derivatives all have power 1. 2

A solution to a PDE can be found by linearizing into a system of linear equations: a 11 x 1 + a 12 x 2 + + a 1n x n = b 1 a 21 x 1 + a 22 x 2 + + a 2n x n = b 2...... =. a n1 x 1 + a n2 x 2 + + a nn x n = b n This system of equations will be written in matrix form Ax = b, where a 11 a 12 a 1n x 1 a 21 a 22 a 2n x 2 A =. x =...... a n1 a n2 a nn x n b 1 b 2. b = b n The matrix A is referred to as the Coefficient Matrix, and x the Solution Matrix. Defintion 2.2. A matrix is defined to be sparse if a large proportion of its entries are zero. Defintion 2.3. A n n matrix A is defined to be symmetric if A = A T. Defintion 2.4. A n n matrix A is Positive Definite if x T Ax > 0 for every n-dimensional column matrix x 0, where x T is the transpose of vector x. Remark. The notation x,ax is commonly used. This notation is called the inner product, and x, Ax = x T Ax. Typically systems of equations arising from linearizing PDEs yield coefficient matrices which are sparse. However, when discussing large sparse matrix solutions, it is not sufficient to know that the coefficient matrix is sparse. Systems arising from linear PDEs have a coefficient matrix which have non-zero diagonals and all other entries zero. When programming the cg-method, a programmer can utilize the sparse characteristic and only program the non-zero diagonals to reduce storage and improve efficiency. In order for the cg-method to yield a solution the coefficient matrix needs to be symmetric and positive definite. Because the inner product notation is utilized throughout the rest of this paper, it is useful to know some of the basic properties of the inner product. Theorem 2.1. [4] For any vectors x, y, and z and any real number α, the following are true: 1. x, y = y, x. 2. αx, y = x, αy = α x, y 3. x + z, y = x, y + z, y 4. x, x 0 5. x, x = 0 if and only if x = 0 3

Defintion 2.5. The Gradient is defined as F where is called the Del operator and is the sum of the partial derivatives with respect to each variable of F. Eg. For a function F (x, y, z), then is x ˆx + y ŷ + z ẑ, and F can be written as ( F = x ˆx + y ŷ + ) z ẑ F = F F ˆx + x y ŷ + F z ẑ. Remark. The gradient will be used to find the direction in which a scalar-valued function of many variables increases most rapidly. Theorem 2.2. [9] Let the scalar σ be defined by σ = b T x where b and x are n 1 matrices and b is independent of x, then σ x = b Theorem 2.3. [9] Let σ be defined by σ = x T Ax where A is a n n matrix, x is a n 1 matrix, and A is independent of x, then σ x = (AT + A)x 3 Linearization of Partial Differential Equations There are several established methods to linearize PDEs. For the following example for linearizing the one-dimensional heat equation, the Forward Difference Method is utilized. Note that this process will work for all linear PDEs. Consider the one-dimensional heat equation: φ t (x, t) = φ α 2 x2(x, t); 0 < x < l, t > 0 This boundary value problem has the properties that the endpoints remain constant throughout time at 0, so φ(0, t) = φ(l, t) = 0. Also at time = 0, φ(x, 0) = f(x), which describes the whole system from 0 x l. The forward difference method utilizes Taylor series expansion. A Taylor expansion yields infinitely many terms, so the utilization of Taylor s formula with remainder which allows the truncation of the Taylor series at n derivatives with an error R is also needed. 4

Theorem 3.1. [6] Taylor s formula with remainder If f and its first n derivatives are continuous in a closed interval I : {a x b}, and if f n+1 (x) exists at each point of the open interval J : {a < x < b}, then for each x in I there is a β in J for which R n+1 = f n+1 (β) (n + 1)! (x a)n+1. First, the x-axis is split into equal segments of length s, and a step size of x = l. For a time step s size t, note that (x i, t j ) = (i x, j t) for 0 i s and j 0. By expanding φ using a Taylor series expansion in t, Solving for φ t, φ(x i, t i + t) = φ(x i, t i ) + t φ + t2 2 φ tj t tj 2! t 2 + φ = φ(x i, t j + t) φ(x i, t j ) t ti t t 2 φ tj 2! t 2 By Taylor s formula with remainder, the higher order derivatives can be replaced with t2 for some τ j (t j 1, t t+1 ) so φ is reduced to t By a similar Taylor expansion, 2 φ φ = φ(x i, t j + t) φ(x i, t j ) t tj t x 2 = φ(x i + x, t j ) 2φ(x i, t j ) + φ(x i x, t j ) x 2 t2 2 φ τ 2 t 2 By substituting back into the heat equation and writing φ(x i, t j ) as Φ i,j, x2 4 φ 12 x 4(χ, t j), χ (x i 1, x x+1 ) 2 2 φ t 2 (x i, τ j ), with an error of Φ i,j+1 Φ i,j t = α Φ i+1,j 2Φ i,j + Φ i 1,j x 2 ξ = t 2 φ 2 t 2 (x i, τ j ) α 2 4 φ 12 x 4(χ i, t j ) Solving for Φ i,j+1 as a function of Φ i,j, which is found to be: Φ i,j+1 = (1 2α t x 2 )Φ i,j + α t x 2(Φ i+1,j + Φ i 1,j ) for each i = 0, 1,, s 1 and j = 0, 1, Now by choosing initial values i = 0 and j = 0, the first vector for the given system is: 5

Φ 0,0 = f(x 0 ), Φ 1,0 = f(x 1 ),... Φ s,0 = f(x s ) Building the next vectors, Φ 0,1 = φ(0, t 1 ) = 0 Φ 1,1 = (1 2α t x 2 )Φ 1,0 + α t x 2(Φ 2,0 + Φ 0,0 ). Φ s 1,1 = (1 2α t x 2 )Φ s 1,0 + α t x 2(Φ s,0 + Φ s 2,0 ) Φ s,1 = φ(s, t 1 ) = 0 By continuing to build these vectors in s, there is a pattern which can be written as the matrix equation θ (j) = Aθ (j 1), for each successive j > 0 and where A is the (s 1) x (s 1) matrix (1 2β) β 0 0. β (1 2β)....... 0........ 0.......... β 0 0 β (1 2β) where β = α t x 2. A acts on the vector θ(j) = (Φ 1,j, Φ 2,j,, Φ s 1,j ) T and produces θ (j+1), the next vector after a time step of j. A is a tri-diagonal matrix with an upper and lower triangular section of zeroes. For any linear PDE, the matrix equations derived using finite difference methods will have a coefficient matrix A which is symmetric, positive definite and sparse. Recall that because the non-zero terms of A are the three diagonals and the rest of the terms are zero, a programmer will be able to just program the diagonals as vectors which makes the space-complexity of this matrix for the cg-method small. 4 The Mechanisms of the Conjugate Gradient Method 4.1 Steepest Descent There are a few fundamental techniques utilized to find solutions to simultaneous systems of equations derived from linear PDEs. A first attempt may be to try direct methods, such as Gaussian elimination, which would yield exact solutions to the system. However, for large systems, Gaussian elimination on a sparse matrix system eliminates the sparse characteristic of the matrix, making this very computation and memory intensive. The next theorem illustrates a geometry of the method. A proof will be stated later. 6

Theorem 4.1. [4] The solution vector x to the system Ax = b where A is positive definite and symmetric, is the minimal value of the quadratic form f(x) = 1 x, Ax x, b. 2 As an illustration, consider a simple 2 2 system. The example provided by equation (1) is pictured in (figure 1). 2 1 x = 3 (1) 1 1 y 2 This system represents the lines 2x + y = 3 x + y = 2 For this example, the function f(x) from T heorem 4.1, will project a paraboloid into a three dimensional graph (figure 2). Note that this does not lose generality for higher dimensions. The cg-method applies in orders that cannot be represented geometrically. Figure 1: A system of two equations and two unknowns; the red equation is 2x + y = 3, the blue equation is x + y = 2 Note also that Theorem 4.1, leads to the fact that the minimization of f(x) is the solution to the system of interest. For a 2 2 system, the vertex is the minimum value of the paraboloid (figure 3). As noted earlier, direct methods are very time consuming, however, the paraboloid yields potential solutions through less direct or iterative solutions. Several iterative algorithms produce the minimal value. The method presented here utilizes the method of Steepest Decent. The concept of steepest decent is simple: start at an arbitrary point anywhere on the paraboloid and follow the steepest curve to the minimized value of the paraboloid. Start at an arbitrary point x (0) and then take a series of iterations, x (1), x (2),. Stop when x (i) is sufficiently close to the solution x. 7

Figure 2: The paraboloid formed from the quadratic form from Theorem 4.1 for example (1) For any estimate x (i), the solution x can be found by taking the direction that the quadratic forms decreases most rapidly, that is taking the negative gradient, f(x i ). By a direct computation, ( 1 ) f(x) = x, Ax b, x 2 ( 1 ) = 2 xt Ax b T x ( 1 = 2 AT x + 1 ) 2 Ax b (by Theorem 2.2 and Theorem 2.3) Since A is symmetric, it can be simplified further to be = (Ax b) f(x) = b Ax (2) So for each x i, f(x i ) = b Ax i. Note that this definition of the direction of steepest descent is exactly equal to the residual. A residual is the difference between the real value and the estimated Figure 3: Contour map of paraboloid with the linear system from example (1) with solutions at the vertex of the paraboloid 8

value. In this case the real value is b and the estimated value is Ax i, so the residual is r i = b Ax i. This residual indicates how far away from the value of b the approximate step is. For the best convergence to the solution it is ideal to travel in the direction of steepest descent. So, each subsequent step is some scalar multiple of the direction of steepest descent. Determining how far needs to be defined. The equation is then x 1 = x 0 + s 0 r 0 where s is the scalar for how far in the direction of the residual each iteration descends. For successive steps, this equation is x i+1 = x i + s i r i In each successive step the search direction d i+1 = r i is chosen. In order to solve for each s i, a procedure known as a line search evaluates s to minimize the value of f along the line in the direction of steepest descent. First, consider f(x i+1 ) and minimize s i, that is, take the derivative of f(x i+1 ) with respect to s i : d f(x i+1 ) = f (x i+1 ) d T x i+1 ds i ds i = f (x i+1 ) d T (x i + s i r i ) ds i (Chain Rule) = f (x i+1 ) T r i (3) To find the minimum of s i set equation (3) equal to zero f (x i+1 ) T r i = 0 Recognize that because f (x i+1 ) T and r i are vectors whose product is 0 then either one vector is zero or they are orthogonal. Since neither vector can be zero, they must be orthogonal. As indicated earlier, f (x i+1 ) = b Ax i+1, so 9

f (x i+1 ) T r i = 0 (b Ax i+1 ) T r i = 0 [b A(x i + s i r i )] T r i = 0 [b Ax i s i (Ar i )] T r i = 0 (b Ax i ) T r i s i (Ar i ) T r i = 0 (b Ax i ) T r i = s i (Ar i ) T r i (b Ax i ) T r i (Ar i ) T = s i r i ri T r i (Ar i ) T = s i r i Another way of writing s i is in inner product notation: s i = r i, r i Ar i, r i (4) First, r 0 is calculated, then repeated using r i = b Ax i in order to calculate x i+1 which can be computed by x i+1 = x i +s i r i where s i = r i, r i. A quick consideration of the computational algorithm Ar i, r i shows that the algorithm is dominated by two matrix products, first Ax i, then Ar i. Ax i can be eliminated by x i+1 = x i + s i r i A(x i+1 ) = A(x i + s i r i ) Ax i+1 = Ax i + s i ( Ar i ) Ax i+1 + b = Ax i + b s i Ar i r i+1 = r i s i Ar i Now it is only necessary to compute Ar i for both equations. What the algorithm gains in efficiency it loses in accuracy, because x i is no longer being computed, so the error may increase. This suggests that computing a new x i at regular intervals helps reduce the error. Before moving on to improvements, the proof of Theorem 4.1, follows. Theorem 4.1 [4] The solution vector x to the system Ax = b where A is positive definite and symmetric, is the minimal value of the quadratic form f(x) = 1 x, Ax x, b. 2 10

Proof : Let x and d be fixed vectors not equal to 0 and let m R. Then, f(x + md) = 1 x + md, A(x + md) x + md, b 2 = 1 2 x, Ax + m 2 d, Ax + m m2 x, Ad + d, Ad x, b m d, b 2 2 = 1 m2 x, Ax x, b + m d, Ax m d, b + d, Ad 2 2 Notice that 1 x, Ax x, b = f(x) and m d, Ax m d, b = m d, Ax b, so this can be rewritten as 2 f(x + md) = f(x) m d, b Ax + m2 d, Ad 2 Because x and d are fixed vectors, the quadratic function g(m) is defined by g(m) = f(x + md) The minimum value of g(m) is when g (m) = 0, because the m 2 coefficient is positive. Then g (m) = 0 = d, b Ax + m d, Ad solving for m, Substituting m into g(m), d, b Ax m = d, Ad g(m ) = f(x + m d) = f(x) m d, b Ax + (m ) 2 d, Ad 2 d, b Ax = f(x) d, b Ax + 1 ( ) 2 d, b Ax d, Ad d, Ad 2 d, Ad = f(x) 1 d, b Ax 2 2 d, Ad d, b Ax 2 Because is always positive or zero, for any vectors d 0, f(x + m d) < f(x), or when d, Ad d, b Ax = 0, f(x + m d) = f(x). Suppose that x satisfies, Ax = b. Then d, b Ax = 0, and f(x) cannot be made any smaller than g(x ). Thus, x minimizes f(x). Next, suppose that x minimizes f(x). Then for any vector d, f(x, t m d) g(x ). Thus, d, b Ax = 0. Since d is non-zero, this implies that b Ax = 0. Therefore Ax = b. 11

4.2 Conjugate Directions The algorithm just derived is the steepest descent algorithm. This algorithm is not sufficient for the cg-method because the convergence is slow. The convergence is slow because by following the negative gradient the search directions are often chosen in the same directions as previously searched directions. In order to improve the convergence, the condition that the search directions are never in the same direction as any of the previous search directions is imposed on the algorithm. This condition is to choose a set of nonzero vectors {d (1),, d (n) } such that d (i), Ad (j) = 0 if i j. This is known as the A-orthogonality condition. Simply choosing vectors to be orthogonal is not sufficient because in choosing a starting point and an initial search direction, there would only be a single vector orthogonal to the search direction which would result in the solution. Unfortunately, in order to choose the correct orthogonal vector and both scalars it would be necessary to know the solution. Clearly, this is not a viable solution. Imposing A-orthogonality on the steepest descent algorithm and utilizing Theorem 4.1, the new s i are given by s i = d(i), r (i) d (i), Ad (i) for r i = b Ax (i) The next step is still calculated by x (i+1) = x (i) + s i d (i) The next theorem shows the full power of this choice of search directions. Theorem 4.2. [4] Let {d (1),, d (n) } be an A-orthogonal set of nonzero vectors associated with the positive definite symmetric matrix A, and let x (0) be arbitrary. Define s k = d(k), b Ax (k 1) x (k) = x (k 1) + s k d (k) for k = 1, 2,, n. Then, assuming exact arithmetic, Ax (n) = b. Proof : Consider the A-orthogonal set associated with a positive definite symmetric matrix A, {d (1),, d (n) }. Let x (0) be arbitrary. So, for the n th vector, x (n) = x (n 1) + s n d (n) (5) The x (n 1) in equation (5) can be expanded to x (n 1) = x (n 2) +s n 1 d (n 1). By continuing this process, the x (k) terms can be continually replaced with the x (k 1) + s k d (k) to obtain x (n) = x (0) + s 1 d (1) + s 2 d (2) + + s n d (n) multiplying both sides by matrix A, and subtracting b from both sides, 12

Ax (n) b = Ax (0) b + s 1 Ad (1) + s 2 Ad (2) + + s n Ad (n) Now take the inner product of both sides with the vector d (k). The A-orthogonality property says that for any m k, such that 0 m n, the inner product is 0. So, Ax (n) b, d (k) = Ax (0) b, d (k) + s k Ad (k), d (k) By the fact that A is symmetric this can be rewritten as Ax (n) b, d (k) = Ax (0) b, d (k) + s k Since s k = d(k), b Ax (k 1), then s d (k), Ad (k) k = d (k), b Ax (k 1). By expanding the right hand side, d (k), b Ax (k 1) = d (k), b Ax (0) + Ax (0) Ax (1) + Ax (1) + Ax (k 2) + Ax (k 2) + Ax (k 1) For any i = d (k), b Ax (0) + d (k), Ax (0) Ax (1) + + d (k), Ax (k 2) Ax (k 1) (6) x (i) = x (i 1) + s i d (i) Ax (i) = Ax (i 1) + s i Ad (i) Ax (i 1) Ax (i) = s i Ad (i) (7) Substituting equation (7) into equation (6), d (k), b Ax (k 1) = d (k), b Ax (0) s 1 d (k), Ad (1) + s k 1 d (k), Ad (k 1) By A-orthogonality d (k), Ad (m) = 0 if k m, so s k = d (k), b Ax (k 1) = d (k), b Ax (0) Thus, Ax (n) b, d (k) = Ax (0) b, d (k) + s k Ad (k), d (k) = Ax (0) b, d (k) + d (k), b Ax (0) = Ax (0) b, d (k) d (k), Ax (0) b = Ax (0) b, d (k) Ax (0) b, d (k) = 0 Therefore Ax (n) b, d (k) = 0. Because d (k) 0, Ax (n) b = 0. Therefore Ax (n) = b and Ax (n) b is orthogonal to the A-orthogonal set of vectors. 13

4.3 Conjugate Gradient Method A method utilizing an A-orthogonal set of vectors is called a Conjugate Direction method. The cgmethod is a method of conjugate directions which chooses the residual vectors to be mutually orthogonal. Recall that the residual is defined by r (k) = b Ax (k). Hestenes and Stiefel chose their search directions, d (k+1), in the cg-method by choosing the residual vectors, r (k), in a way such that they are mutually orthogonal. Similar to steepest descent, the algorithm starts with an initial approximation x (0) and takes the first direction to be the residual from steepest descent d (1) = r (0) = b Ax (0). Each approximation is computed by x (k) = x (k 1) + s k d (k). Applying the A-orthogonality condition from conjugate directions in order to speed up convergence, d (i), Ad (j) = 0 and r (i), r (j) = 0 when i j. There are two stopping conditions. The first is calculating a residual to be zero, which means r (k) = b Ax (k) 0 = b Ax (k) Ax (k) = b This implies that the solution is x (k). The second stopping condition is if the residual is sufficiently close to 0, within some specified tolerance. The next search direction d (k+1), is computed using the residual from the previous iteration r (k), by d (k+1) = r (k) + c k d (k) In order for the A-orthogonal condition to hold, c k must be chosen in such a way that d (k+1), Ad (k) = 0. In order to figure out what the choice of c k should be, multiply by A and take the inner product with the previous search direction d (k), to the left side to obtain: d (k), Ad (k+1) = d (k), Ar (k) + c k By the A-orthogonality condition, d (k), Ad (k+1) = 0, so 0 = d (k), Ar (k) + c k Then solving for c k, c k = d(k), Ar (k) Next solving for the scalar s k, from conjugate directions, s k = d(k), r (k 1) 14

Applying the chosen definition of d (k+1), s k = d(k), r (k 1) = r(k 1) + c k 1 d (k 1), r (k 1) = r(k 1), r (k 1) d (k 1), r (k 1) + c d (k), Ad (k) k 1 Substituting d (k 1) using the definition d (k+1) = r (k) + c k d (k) to obtain: s k = r(k 1), r (k 1) r (k 2), r (k 1) c k 2 d (k 2), r (k 1) + c k 1 + c d (k), Ad (k) k 1 Because of the orthogonality condition of residuals, r (k 2), r (k 1) = 0. Clearly, by continuing to expand the d (i) terms none of the terms will contain r (k 1). So, every term except for the r (k 1), r (k 1) term is zero. So, s k = r(k 1), r (k 1) Lastly, calculating the residuals, starting with the definition of x (k), x (k) = x (k 1) + s (k) d (k) By multiplying by A, and adding b the equation becomes, b Ax (k) = b Ax (k 1) s k Ad (k) Now utilizing the definition of r (k), r (k) = r (k 1) s k Ad (k) These formulas complete the Conjugate Gradient method. The initial assumptions are therefore: r (0) = b Ax (0) d (1) = r (0) and for each successive step k = 1,, n, s k = r(k 1), r (k 1) c k = d(k), Ar (k) x (k) = x (k 1) + s k d (k) d (k+1) = r (k) + c k d (k) r (k) = r (k 1) s k Ad (k) When running the algorithm, it is clear that there are a few calculations that are done more than once, and are therefore repetitive. By eliminating our dependence on these repetitive calculations, the algorithm becomes more efficient. The matrix multiplications in the c k formula can both be removed by the following: 15

Starting with the r (k) formula and taking the inner product with itself on the right, r (k) = r (k 1) s k Ad (k) r (k), r (k) = r (k 1), r (k) s k Ad (k), r (k) r (k), r (k) = s k Ad (k), r (k) 1 r (k), r (k) = Ad (k), r (k) s k 1 r (k), r (k) = d (k), Ar (k) s k Next considering the s k formula, s k = r(k 1), r (k 1) s k = r (k 1), r (k 1) = 1 s k r (k 1), r (k 1) Substituting into the c k formula, c k = d(k), Ar (k) = 1 s k r (k), r (k) 1 s k r (k 1), r (k 1) = r(k), r (k) r (k 1), r (k 1) This eliminated the redundancy of the algorithm, which increases the efficiency substantially. following is the pseudo code for the cg-method. The r (0) = b Ax (0) d (1) = r (0) k = 1 16

while (k n) s k = r(k 1), r (k 1) x (k) = x (k 1) + s k d (k) r (k) = r (k 1) s k Ad (k) if r k is smaller than a tolerance, quit c k = r(k), r (k) r (k 1), r (k 1) d (k+1) = r (k) + c k d (k) k = k + 1 end For an example, consider the system 5 2 0 2 5 1 0 1 5 x 1 x 2 x 3 20 = 10 10 Where the matrix 5 2 0 A = 2 5 1 0 1 5 is positive definite and symmetric. For the cg-method, first set the starting point 0 x (0) = 0 0 and then calculate the initial assumptions: 20 r (0) = b Ax (0) = b = 10 10 Next, set d (1) = r (0), so that 20 d (1) = 10 10 17

Then running through the first iteration, k = 1, Next, for the second iteration k = 2, s 1 = r(0), r (0) d (1), Ad (1) = 3 10 6 x (1) = x (0) + s 1 d (1) = 3 3 4 r (1) = r (0) s 1 Ad (1) = 10 2 c 1 = r(1), r (1) r (0), r (0) = 1 5 0 d (2) = r (1) + c 1 d (1) = 12 0 s 2 = r(1), r (1) d (2), Ad (2) = 1 6 6 x (2) = x (1) + s 2 d (2) = 5 3 0 r (2) = r (1) s 2 Ad (2) = 0 0 Since the residual r (2) = [ 0 0 0] T, the solution is exactly x (2). Since this is a small system it is easy to find the exact solution. Unfortunately for larger systems, the cg-method suffers from a significant weakness: round-off error. The solution to the round-off error is Preconditioning. 5 Preconditioning Typically, mathematicians are used to round-off error when it comes to numerical solutions and usually it is not that problematic. However, round-off error from early steps could accumulate and 18

potentially force the cg-method to fail. So what can the mathematician do in order to create a more accurate set of formulas? The main cause for round-off error is in a poorly conditioned matrix A. A new n n matrix P which is non-singular is introduced to the system. Non-singular means that the determinant is nonzero. Since the cg-method erquires the matrix system to be positive definite, by multiplying P to the left and right of A, the new matrix P AP T is still positive definite. So define, A = P AP T In order for the new matrix equation to make sense set x = (P T ) 1 x and b = P b. The new matrix equation A x = b is now as follows: A x = b (8) By substituting, A x = b (P AP T )((P T ) 1 x) = P b P Ax = P b Clearly, the original system is left unchanged. Utilizing these preconditioned matrices the formulas for the cg-method are as follows: s k+1 = P 1 r (k), P 1 r (k) d (k+1), Ad (k+1) λ k+1 = P 1 r (k+1), P 1 r (k+1) P 1 r (k), P 1 r (k) x (k+1) = x (k) + s k+1 d(k+1) r (k+1) = r (k) s k+1 Ad(k+1) d (k+1) = P t P 1 r k + λ k d(k) 6 Efficiency Conjugate Gradient O(m K) Gaussian Elimination O(n 3 ) Table 1: Time complexity of the cg-method vs Gaussian elimination In table (1) is a comparison of the time complexity of the cg-method and Gaussian elimination. Where m is the number of non-zero terms in the coefficient matrix, and K is the condition number of the coefficient matrix A and n is the dimension of the coefficient matrix. Calculating the condition number requires knowledge of A 1 so it is necessary to estimate it through other means. However, by preconditioning a matrix, it has the effect of reducing the value of K. The goal is for K to be as close to 1 as possible so that it is not a factor in the time-complexity for the cg-method. Most numerical analysits agree that a preconditioner should always be used for the cg-method. 19

Clearly, by comparing the time complexity, the cg-method is more efficient because there are a small proportion of terms which are zero. To Gaussian elimination, since the system loses its sparse characteristic, no matrix is really sparse so its time complexity is worse for larger systems. 7 Conclusion The Conjugate Gradient algorithm is used in the fields of engineering optimization problems, neuralnet training, and in image restoration. The Conjugate Gradient alogirthm is now a grandfather algorithm for a whole class of methods for solving various matrix systems. However, there is still research into expanding the Conjugate Gradient method to more complex systems such as unconstrained optimization or singular matrices. 20

8 References [1] R. Chandra, S.C. Eisenstat, and M.H. Schultz, Conjugate Gradient Methods for Partial Differential Equations, June 1975. [2] Gerald W. Recktenwald, Finite-Difference Approximations to the Heat Equation, 6 March 2011. [3] Magnus R Hestenes and Eduard Stiefel, Methods of Conjugate Gradients for Solving Linear Systems, Jounral of Research of the National Bureau of Standards Vol. 49, No. 6, December 1952. [4] Richard L. Burden and J. Douglas Faires, Numerical Analysis, ninth edition 2011. [5] Jonathan Richard Stewchuk, An Introduction to the Conjugate Gradient Method Without the Agonizing Pain, 4 August 1994. [6] Watson Fulks, Advanced Caluclus: An Introduction To Analysis, John Wiley & Sons, Inc. Hoboken, NJ, 1961. [7] Mark S. Gockenbach Partial Differential Equations, Society for Industrial and Applied Mathematics. Philadelphia, PA, 2011. [8] Gene H. Golub and Dianne P. O Leary Some History of the Conjugate Gradient and Lanczos Algorithms: 1948-1976 Siam Review Vol. 31, No. 1, March 1989. [9] Randal J. Barnes, Matrix Differentiation, University of Minnesota. Spring 2006. 21