Solving Linear Systems: Iterative Methods and Sparse Systems COS 323.

Slides:



Advertisements
Similar presentations
Least Squares example There are 3 mountains u,y,z that from one site have been measured as 2474 ft., 3882 ft., and 4834 ft.. But from u, y looks 1422 ft.
Advertisements

MATH 685/ CSI 700/ OR 682 Lecture Notes
1 Parallel Algorithms II Topics: matrix and graph algorithms.
Solving Linear Systems (Numerical Recipes, Chap 2)
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
SOLVING SYSTEMS OF LINEAR EQUATIONS. Overview A matrix consists of a rectangular array of elements represented by a single symbol (example: [A]). An individual.
CISE301_Topic3KFUPM1 SE301: Numerical Methods Topic 3: Solution of Systems of Linear Equations Lectures 12-17: KFUPM Read Chapter 9 of the textbook.
Rayan Alsemmeri Amseena Mansoor. LINEAR SYSTEMS Jacobi method is used to solve linear systems of the form Ax=b, where A is the square and invertible.
Iterative methods TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAA A A A A A A A.
Modern iterative methods For basic iterative methods, converge linearly Modern iterative methods, converge faster –Krylov subspace method Steepest descent.
Solution of linear system of equations
1cs542g-term High Dimensional Data  So far we’ve considered scalar data values f i (or interpolated/approximated each component of vector values.
CSCI 317 Mike Heroux1 Sparse Matrix Computations CSCI 317 Mike Heroux.
Sparse Matrix Algorithms CS 524 – High-Performance Computing.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
Monica Garika Chandana Guduru. METHODS TO SOLVE LINEAR SYSTEMS Direct methods Gaussian elimination method LU method for factorization Simplex method of.
1 Systems of Linear Equations Error Analysis and System Condition.
Part 3 Chapter 8 Linear Algebraic Equations and Matrices PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The.
1cs542g-term Notes  Extra class next week (Oct 12, not this Friday)  To submit your assignment: me the URL of a page containing (links to)
Finding the Inverse of a Matrix
LIAL HORNSBY SCHNEIDER
Matrices Write and Augmented Matrix of a system of Linear Equations Write the system from the augmented matrix Solve Systems of Linear Equations using.

ECE 530 – Analysis Techniques for Large-Scale Electrical Systems Prof. Hao Zhu Dept. of Electrical and Computer Engineering University of Illinois at Urbana-Champaign.
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Matrix Solution of Linear Systems The Gauss-Jordan Method Special Systems.
Chapter 10 Review: Matrix Algebra
Scientific Computing Linear Systems – LU Factorization.
Systems and Matrices (Chapter5)
Solving Scalar Linear Systems Iterative approach Lecture 15 MA/CS 471 Fall 2003.
Iterative Methods for Solving Linear Systems Leo Magallon & Morgan Ulloa.
MATH 250 Linear Equations and Matrices
1 Iterative Solution Methods Starts with an initial approximation for the solution vector (x 0 ) At each iteration updates the x vector by using the sytem.
Qualifier Exam in HPC February 10 th, Quasi-Newton methods Alexandru Cioaca.
Matrix Entry or element Rows, columns Dimensions Matrix Addition/Subtraction Scalar Multiplication.
Copyright © 2013, 2009, 2005 Pearson Education, Inc. 1 5 Systems and Matrices Copyright © 2013, 2009, 2005 Pearson Education, Inc.
8.1 Matrices & Systems of Equations
Lecture 8 Matrix Inverse and LU Decomposition
1 Incorporating Iterative Refinement with Sparse Cholesky April 2007 Doron Pearl.
Lecture 7 - Systems of Equations CVEN 302 June 17, 2002.
Lesson 3 CSPP58001.
Linear Systems – Iterative methods
Case Study in Computational Science & Engineering - Lecture 5 1 Iterative Solution of Linear Systems Jacobi Method while not converged do { }
ES 240: Scientific and Engineering Computation. Chapter 8 Chapter 8: Linear Algebraic Equations and Matrices Uchechukwu Ofoegbu Temple University.
Direct Methods for Sparse Linear Systems Lecture 4 Alessandra Nardi Thanks to Prof. Jacob White, Suvranu De, Deepak Ramaswamy, Michal Rewienski, and Karen.
Chapter 10 Minimization or Maximization of Functions.
INTRO TO OPTIMIZATION MATH-415 Numerical Analysis 1.
Monte Carlo Linear Algebra Techniques and Their Parallelization Ashok Srinivasan Computer Science Florida State University
Programming Massively Parallel Graphics Multiprocessors using CUDA Final Project Amirhassan Asgari Kamiabad
9 Nov B - Introduction to Scientific Computing1 Sparse Systems and Iterative Methods Paul Heckbert Computer Science Department Carnegie Mellon.
2.5 – Determinants and Multiplicative Inverses of Matrices.
ECE 530 – Analysis Techniques for Large-Scale Electrical Systems
Unit #1 Linear Systems Fall Dr. Jehad Al Dallal.
1 SYSTEM OF LINEAR EQUATIONS BASE OF VECTOR SPACE.
A rectangular array of numeric or algebraic quantities subject to mathematical operations. The regular formation of elements into columns and rows.
1 Matrix Math ©Anthony Steed Overview n To revise Vectors Matrices.
Monte Carlo Linear Algebra Techniques and Their Parallelization Ashok Srinivasan Computer Science Florida State University
1 Numerical Methods Solution of Systems of Linear Equations.
Iterative Solution Methods
Finding the Inverse of a Matrix
Singular Value Decomposition
Lecture 11 Matrices and Linear Algebra with MATLAB
CS5321 Numerical Optimization
~ Least Squares example
Solving Linear Systems: Iterative Methods and Sparse Systems
~ Least Squares example
Linear Algebra Lecture 16.
Ax = b Methods for Solution of the System of Equations:
Pivoting, Perturbation Analysis, Scaling and Equilibration
Ax = b Methods for Solution of the System of Equations (ReCap):
Presentation transcript:

Solving Linear Systems: Iterative Methods and Sparse Systems COS 323

Direct vs. Iterative Methods So far, have looked at direct methods for solving linear systemsSo far, have looked at direct methods for solving linear systems – Predictable number of steps – No answer until the very end Alternative: iterative methodsAlternative: iterative methods – Start with approximate answer – Each iteration improves accuracy – Stop once estimated error below tolerance

Benefits of Iterative Algorithms Some iterative algorithms designed for accuracy:Some iterative algorithms designed for accuracy: – Direct methods subject to roundoff error – Iterate to reduce error to O(  ) Some algorithms produce answer fasterSome algorithms produce answer faster – Most important class: sparse matrix solvers – Speed depends on # of nonzero elements, not total # of elements Today: iterative improvement of accuracy, solving sparse systems (not necessarily iteratively)Today: iterative improvement of accuracy, solving sparse systems (not necessarily iteratively)

Iterative Improvement Suppose you’ve solved (or think you’ve solved) some system Ax=bSuppose you’ve solved (or think you’ve solved) some system Ax=b Can check answer by computing residual : r = b – Ax computedCan check answer by computing residual : r = b – Ax computed If r is small (compared to b), x is accurateIf r is small (compared to b), x is accurate What if it’s not?What if it’s not?

Iterative Improvement Large residual caused by error in x: e = x correct – x computedLarge residual caused by error in x: e = x correct – x computed If we knew the error, could try to improve x: x correct = x computed + eIf we knew the error, could try to improve x: x correct = x computed + e Solve for error: Ax computed = A(x correct – e) = b – r Ax correct – Ae = b – r Ae = rSolve for error: Ax computed = A(x correct – e) = b – r Ax correct – Ae = b – r Ae = r

Iterative Improvement So, compute residual, solve for e, and apply correction to estimate of xSo, compute residual, solve for e, and apply correction to estimate of x If original system solved using LU, this is relatively fast (relative to O(n 3 ), that is):If original system solved using LU, this is relatively fast (relative to O(n 3 ), that is): – O(n 2 ) matrix/vector multiplication + O(n) vector subtraction to solve for r – O(n 2 ) forward/backsubstitution to solve for e – O(n) vector addition to correct estimate of x

Sparse Systems Many applications require solution of large linear systems (n = thousands to millions)Many applications require solution of large linear systems (n = thousands to millions) – Local constraints or interactions: most entries are 0 – Wasteful to store all n 2 entries – Difficult or impossible to use O(n 3 ) algorithms Goal: solve system with:Goal: solve system with: – Storage proportional to # of nonzero elements – Running time << n 3

Special Case: Band Diagonal Last time: tridiagonal (or band diagonal) systemsLast time: tridiagonal (or band diagonal) systems – Storage O(n): only relevant diagonals – Time O(n): Gauss-Jordan with bookkeeping

Cyclic Tridiagonal Interesting extension: cyclic tridiagonalInteresting extension: cyclic tridiagonal Could derive yet another special case algorithm, but there’s a better wayCould derive yet another special case algorithm, but there’s a better way

Updating Inverse Suppose we have some fast way of finding A -1 for some matrix ASuppose we have some fast way of finding A -1 for some matrix A Now A changes in a special way: A* = A + uv T for some n  1 vectors u and vNow A changes in a special way: A* = A + uv T for some n  1 vectors u and v Goal: find a fast way of computing (A*) -1Goal: find a fast way of computing (A*) -1 – Eventually, a fast way of solving (A*) x = b

Sherman-Morrison Formula

Applying Sherman-Morrison Let’s consider cyclic tridiagonal again:Let’s consider cyclic tridiagonal again: TakeTake

Applying Sherman-Morrison Solve Ay=b, Az=u using special fast algorithmSolve Ay=b, Az=u using special fast algorithm Applying Sherman-Morrison takes a couple of dot productsApplying Sherman-Morrison takes a couple of dot products Total: O(n) timeTotal: O(n) time Generalization for several corrections: WoodburyGeneralization for several corrections: Woodbury

More General Sparse Matrices More generally, we can represent sparse matrices by noting which elements are nonzeroMore generally, we can represent sparse matrices by noting which elements are nonzero Critical for Ax and A T x to be efficient: proportional to # of nonzero elementsCritical for Ax and A T x to be efficient: proportional to # of nonzero elements – We’ll see an algorithm for solving Ax=b using only these two operations!

Compressed Sparse Row Format Three arraysThree arrays – Values: actual numbers in the matrix – Cols: column of corresponding entry in values – Rows: index of first entry in each row – Example: (zero-based) values cols rows

Compressed Sparse Row Format Multiplying Ax: for (i = 0; i < n; i++) { out[i] = 0; for (j = rows[i]; j < rows[i+1]; j++) out[i] += values[j] * x[ cols[j] ]; }Multiplying Ax: for (i = 0; i < n; i++) { out[i] = 0; for (j = rows[i]; j < rows[i+1]; j++) out[i] += values[j] * x[ cols[j] ]; } values cols rows

Solving Sparse Systems Transform problem to a function minimization! Solve Ax=b  Minimize f(x) = x T Ax – 2b T xTransform problem to a function minimization! Solve Ax=b  Minimize f(x) = x T Ax – 2b T x To motivate this, consider 1D: f(x) = ax 2 – 2bx df / dx = 2ax – 2b = 0 ax = bTo motivate this, consider 1D: f(x) = ax 2 – 2bx df / dx = 2ax – 2b = 0 ax = b

Solving Sparse Systems Preferred method: conjugate gradientsPreferred method: conjugate gradients Recall: plain gradient descent has a problem…Recall: plain gradient descent has a problem…

Solving Sparse Systems … that’s solved by conjugate gradients… that’s solved by conjugate gradients Walk along directionWalk along direction Polak and Ribiere formula:Polak and Ribiere formula:

Solving Sparse Systems Easiest to think about A = symmetricEasiest to think about A = symmetric First ingredient: need to evaluate gradientFirst ingredient: need to evaluate gradient As advertised, this only involves A multiplied by a vectorAs advertised, this only involves A multiplied by a vector

Solving Sparse Systems Second ingredient: given point x i, direction d i, minimize function in that directionSecond ingredient: given point x i, direction d i, minimize function in that direction

Solving Sparse Systems So, each iteration just requires a few sparse matrix – vector multiplies (plus some dot products, etc.)So, each iteration just requires a few sparse matrix – vector multiplies (plus some dot products, etc.) If matrix is n  n and has m nonzero entries, each iteration is O ( max(m,n) )If matrix is n  n and has m nonzero entries, each iteration is O ( max(m,n) ) Conjugate gradients may need n iterations for “perfect” convergence, but often get decent answer well before thenConjugate gradients may need n iterations for “perfect” convergence, but often get decent answer well before then