Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

24
Iterative Methods Numerical Matrix Analysis Lecture Notes #25 — Iterative Methods Overview Peter Blomgren, [email protected]Department of Mathematics and Statistics Dynamical Systems Group Computational Sciences Research Center San Diego State University San Diego, CA 92182-7720 http://terminus.sdsu.edu/ Spring 2019 Peter Blomgren, [email protected]Iterative Methods — Overview — (1/24)

Transcript of Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Page 1: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods

Numerical Matrix Analysis

Lecture Notes #25 — Iterative MethodsOverview

Peter Blomgren,〈[email protected]

Department of Mathematics and StatisticsDynamical Systems Group

Computational Sciences Research Center

San Diego State UniversitySan Diego, CA 92182-7720

http://terminus.sdsu.edu/

Spring 2019

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (1/24)

Page 2: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods

Outline

1 Iterative MethodsOverview

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (2/24)

Page 3: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Iterative Methods: A Birds-eye View

The size and complexity of linear and non-linear systems that arisefrom modern applications (especially 3+1-Dimensional models)make direct (LU/QR/SVD) methods intractable in many settings.

Instead of using O(m3) operations to find a solution using directmethods, in many cases it is possible to find a goodapproximation (maybe even indistinguishable from the “correct”solution in a floating-point environment) a lot faster using iterativemethods.

Yousef Saad, “Iterative Methods for Sparse Linear Systems,” 2nd edition, Society forIndustrial and Applied Mathematics, 2003, ISBN: 0-89871-534-2, MSRP $89.00.

R. Barrett, M. Berry, T. F. Chan, J. Demmel, J. Donato, J. Dongarra, V. Eijkhout, R.Pozo, C. Romine and H. Van der Vorst, “Templates for the Solution of Linear Systems:

Building Blocks for Iterative Methods,” 2nd Edition, Society for Industrial and AppliedMathematics, 1994, URL http://www.netlib.org/linalg/html templates/Templates.html

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (3/24)

Page 4: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

The Boundary of “Tractable” Is Moving (Direct Methods)

What does it mean for m to be “very large?” — where m defines anm ×m dense matrix.

Year m Defining Force1950 20 Wilkinson1965 200 Forsythe and Moler [Book, 1967]1980 2,000 LINPACK1995 20,000 LAPACK2010 ???,000 ??? parallel computing, MPI/CUDA ???2016 ???,000 ??? parallel computing, MPI/CUDA/FPGA ???

Over this time-span m has increased by a factor of 103, If we look at thespeedup in processing speed (computer hardware) over the same period,we see a speedup ∼ 109.

If matrix problems scaled as O(m2), we would have m1995 ∼ 3, 000, 000.With iterative methods this is sometimes achievable.

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (4/24)

Page 5: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Iterative Methods: Stationary Methods 1 of 2

Jacobi Iteration, for Ax = bThe Jacobi method is based on solving for every variable locally withrespect to the other variables; one iteration of the method correspondsto solving for every variable once. The resulting method is easy tounderstand and implement, but convergence is slow

x(k)i =

1

aii

[bi −

j 6=i

aijx(k−1)j

], i = 1, . . . , n

Gauss-Seidel Iteration, for Ax = bThe Gauss-Seidel method is like the Jacobi method, except that it usesupdated values as soon as they are available. In general, if the Jacobimethod converges, the Gauss-Seidel method will converge faster thanthe Jacobi method, though still relatively slowly.

x(k)i =

1

aii

[bi −

j<i

aijx(k)j −

j>i

aijx(k−1)j

], i = 1, . . . , n

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (5/24)

Page 6: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Iterative Methods: Stationary Methods 2 of 2

SOR, for Ax = bSuccessive Over-relaxation (SOR) can be derived from the Gauss-Seidel method by introducing an extrapolation parameter. For theoptimal choice of ω, SOR may converge faster than Gauss-Seidelby an order of magnitude

x(k)i = ωx

(k)i + (1− ω)x

(k−1)i , where x

(k)i = the GS iterate

SSOR, for Ax = bSymmetric Successive Over-relaxation (SSOR) has no advantageover SOR as a stand-alone iterative method; however, it is usefulas a preconditioner for nonstationary methods. — SSOR is a for-ward SOR sweep followed by a backward SOR sweep in which theunknowns are updated in the reverse order.

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (6/24)

Page 7: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Krylov Subspaces, Arnoldi and Lanczos

Given a vector x and a matrix A, the associated Krylov vectorsequence is {x, Ax, . . . , Ak−1x, . . . }, and the correspondingKrylov subspaces K (A, b; k) = span{x, Ax, . . . , Ak−1x}.

Most of the iterative algorithms described in the following slides forsolution of the linear system Ax = b are derived from analysis(minimization of residuals) over Krylov subspaces, specifically

Symmetry Linear System Eigenvalue ProblemAx = b Ax = λx

A = A∗ CG Lanczos

GMRES

A 6= A∗ CGNE / CGNR Arnoldi

BiCG, etc...

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (7/24)

Page 8: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

The Arnoldi Iteration

Arnoldi is to Householder-based Hessenberg transformations, asGram-Schmidt is to Householder-based QR-factorization:

Problem A = QR A = QHQ∗

Orthogonal Transformation Householder Householder Structure Q∗A = R Q∗AQ = H

“Structure” Transformation Gram-Schmidt Arnoldi Orthogonalization AR−1 = Q AQn = Qn+1Hn

By “enforcing” the desired structure on Hn, the “by-product” isthe orthogonal matrix Q.

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (8/24)

Page 9: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Lanczos vs. Arnoldi

When A = A∗, we can find an orthonormal similarity transform sothat A = QTQ∗, where T is tri-diagonal. This special case makesthe Lanczos iteration much faster (3-term recurrence) than theArnoldi iteration (“infinite” n-recurrence):

b = b0, q1 = b/‖b‖for n = 1,...

xxv = Aqnxxfor j = 1,. . . ,nxxxxhjn = qj

∗vxxxxv = v − hjnqjxxendfor(j)

xxhn+1,n = ‖v‖xxqn+1 = v/hn+1,n

endfor(n)

b = b0, q1 = b/‖b‖,β0 = 0, q0 = 0for n = 1,...

xxv = Aqnxxαn = q∗n vxxv = v − βn−1qn−1 − αnqnxxβn = ‖v‖xxqn+1 = v/βn

endfor(n)

T = diag(α) + diag(β,±1)

Arnoldi iteration Lanczos iteration

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (9/24)

Page 10: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Iterative Methods: Non-Stationary Methods 1 of 6

Conjugate Gradient, “CG”The conjugate gradient method derives its name from the factthat it generates a sequence of conjugate (or orthogonal) vectors.These vectors are the residuals of the iterates. They are also thegradients of a quadratic functional, the minimization of which isequivalent to solving the linear system. CG is an extremely effec-tive method when the coefficient matrix is symmetric positivedefinite, since storage for only a limited number of vectors isrequired. (See slide 22 for implementation details.)

Minimum Residual, “MINRES”A computational alternative for CG for coefficient matrices thatare symmetric but possibly indefinite.

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (10/24)

Page 11: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Iterative Methods: Non-Stationary Methods 2 of 6

Conjugate Gradient on the Normal Equations, “CGNE” / “CGNR”These methods are based on the application of the CG method to one oftwo forms of the normal equations for Ax = b. CGNE solves the systemfor (AA∗)y = b, and then computes the solution x = A∗y. CGNR solves(A∗A)x = A∗b for the solution vector x. When the coefficient matrix A

is non-symmetric and nonsingular, the normal equations matrices AA∗

and A∗A will be symmetric and positive definite, and hence CG can beapplied. The convergence may be slow, since the spectrum of the normalequations matrices will be less favorable than the spectrum of A.

Chebyshev IterationThe Chebyshev Iteration recursively determines polynomials with coeffi-cients chosen to minimize the norm of the residual in a min-max sense.The coefficient matrix must be positive definite and knowledge of theextremal eigenvalues is required. This method has the advantage ofrequiring no inner products.

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (11/24)

Page 12: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Iterative Methods: Non-Stationary Methods 3 of 6

Generalized Minimal Residual, “GMRES”The Generalized Minimal Residual method computes a sequenceof orthogonal vectors (like MINRES), and combines these througha least-squares solve and update. However, unlike MINRES (andCG) it requires storing the whole sequence, so that a large amountof storage is needed. For this reason, restarted versions of thismethod are used. In restarted versions, computation and storagecosts are limited by specifying a fixed number of vectors to begenerated. This method is useful for general non-symmetricmatrices. (See slide 21 for implementation details.)

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (12/24)

Page 13: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Iterative Methods: Non-Stationary Methods 4 of 6

BiConjugate Gradient, “BiCG”The Biconjugate Gradient method generates two CG-like se-quences of vectors, one based on a system with the original coef-ficient matrix A, and one on A∗. Instead of orthogonalizing eachsequence, they are made mutually orthogonal, or “bi-orthogonal”.This method, like CG, uses limited storage. It is useful whenthe matrix is non-symmetric and nonsingular; however, conver-gence may be irregular, and there is a possibility that the methodwill break down. BiCG requires a multiplication with the coeffi-cient matrix and with its transpose at each iteration. (See slide 23 for

implementation details.)

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (13/24)

Page 14: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Iterative Methods: Non-Stationary Methods 5 of 6

Conjugate Gradient Squared, “CGS”The Conjugate Gradient Squared method is a variant of BiCG thatapplies the updating operations for the A-sequence and the A∗-sequences both to the same vectors. Ideally, this would double theconvergence rate, but in practice convergence may be much moreirregular than for BiCG, which may sometimes lead to unreliableresults. A practical advantage is that the method does not needthe multiplications with the transpose of the coefficient matrix.

Biconjugate Gradient Stabilized, “BiCGSTAB”The Biconjugate Gradient Stabilized method is a variant of BiCG,like CGS, but using different updates for the A∗-sequence in orderto obtain smoother convergence than CGS.

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (14/24)

Page 15: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Iterative Methods: Non-Stationary Methods 6 of 6

Quasi-Minimal Residual , “QMR”The Quasi-Minimal Residual method applies a least-squares solveand update to the BiCG residuals, thereby smoothing out the ir-regular convergence behavior of BiCG, which may lead to morereliable approximations. In full glory, it has a look-ahead strat-egy built in that avoids the BiCG breakdown. Even without lookahead, QMR largely avoids the breakdown that can occur in BiCG.On the other hand, it does not effect a true minimization of eitherthe error or the residual, and while it converges smoothly, it oftendoes not improve on the BiCG in terms of the number of iterationsteps.

Transpose-Free Quasi-Minimal Residual, “TFQMR”A variant of the QMR algorithm which avoids multiplication by A∗.

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (15/24)

Page 16: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Other Approaches 1 of 4

PreconditioningA preconditioner is any form of explicit or implicit modificationof an original linear system that makes it easier to solve by agiven iterative method. Finding a good preconditioner for agiven linear system is a combination of art, science, and whitemagic . One step of the Jacobi, Gauss-Seidel, SOR, and SSORiterations can be viewed as the application of a (rudimentary)preconditioner. Successful preconditioning techniques are oftenbased on incomplete factorizations.

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (16/24)

Page 17: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Other Approaches 2 of 4

Multigrid methodsMultigrid (MG) methods apply to linear systems arising fromdiscretizations of Partial Differential Equations (PDEs). MGtechniques use discretizations with different mesh sizes, toachieve fast convergence. Roughly, a solution is computed on acoarse mesh, that solution (interpolated to a finer mesh) is usedas an initial guess for the fine-mesh solution, etc... Warning:There are some serious dragons hiding in the details!

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

−1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

Figure: A successive refinement of the grid.

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (17/24)

Page 18: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Other Approaches 3 of 4

Domain Decomposition methods

−1 −0.5 0 0.5 1

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

−1 −0.5 0 0.5 1

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

−1 −0.5 0 0.5 1

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

−1 −0.5 0 0.5 1

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

−1 −0.5 0 0.5 1

−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

Domain decomposition methods revolvearound the divide-and-conquer principle.The (discretized) PDE is solved over sub-domains, and then the global solution ispatched together — very special attentionmust be paid at the numerical boundariesbetween the sub-domains.

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (18/24)

Page 19: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Other Approaches 4 of 4

Fast Multipole Method, FMM

• Introduced by Rokhlin & Greengard in 1987. “One of the 10

most significant advances in computing in the 20th century.”

• An algorithm for achieving fast matrix-vector products forparticular dense matrices.

• Developed based on ideas similar to the Fast Fourier Trans-form (FFT), and in some sense multi-grid methods...

• FFT — matrix entries are uniformly sampled complexexponentials.

• FMM — matrix entries are derived from particular functions,satisfying known translation theorems.

• Standard matrix-vector multiply ∼ O(m2).

• FMM matrix-vector multiply ∼ O(m log(m)).

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (19/24)

Page 20: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Algorithm Reference: Arnoldi Iteration

Algorithm (Arnoldi Iteration)

b = b0 = arbitrary, q1 = b/‖b‖for n = 1,...

v = Aqnfor j = 1,. . . ,n

hjn = qj∗v

v = v − hjnqjendfor(j)

hn+1,n = ‖v‖qn+1 = v/hn+1,n

endfor(n)

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (20/24)

Page 21: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Algorithm Reference: GMRES

Algorithm (GMRES)

q1 = b/‖b‖for n = 1:...

→ Step n of Arnoldi Iteration ←

yn = argminy

∥∥∥∥Hny − ‖b‖e1

∥∥∥∥xn = Qnyn

endfor

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (21/24)

Page 22: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Algorithm Reference: CG

Algorithm (Conjugate Gradient CG Iteration)

x0 = 0, p0 = r0 = bfor n = 1:...

αn = ‖rn−1‖2

p∗n−1Apn−1Step length

xn = xn−1 + αnpn−1 Approximate solution

rn = rn−1 − αnApn−1 Updated residual

βn = ‖rn‖2

‖rn−1‖2 Improvement this step

pn = rn + βnpn−1 New search directionendfor

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (22/24)

Page 23: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Algorithm Reference: BiCG

Algorithm (Bi-Conjugate Gradient BiCG Iteration)

x0 = 0, p0 = r0 = b, q0 = s0 = arbitrary

for n = 1:...

αn =s∗n−1 rn−1

q∗n−1Apn−1Step length

xn = xn−1 + αnpn−1 Approximate solution

rn = rn−1 − αnApn−1 Updated residual, rsn = sn−1 − αnA

∗qn−1 Updated residual, s

βn =s∗n rn

s∗n−1 rn−1Improvement this step

pn = rn + βnpn−1 New search direction, p

qn = sn + βnqn−1 New search direction, qendfor

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (23/24)

Page 24: Numerical Matrix Analysis - Peter Blomgren, blomgren AT mail DOT

Iterative Methods Overview

Acknowledgment

Slides 5–6, and 10–15 are blatantly “borrowed” from thehtml-version of “Templates for the Solution of Linear Systems:

Building Blocks for Iterative Methods.”

Peter Blomgren, 〈[email protected]〉 Iterative Methods — Overview — (24/24)