Chapter 13 Gaussian Elimination (III) Bunch-Parlett diagonal pivoting

Slides:



Advertisements
Similar presentations
Chapter 2 Solutions of Systems of Linear Equations / Matrix Inversion
Advertisements

Chapter 11 Gaussian Elimination (I)
Linear Algebra Applications in Matlab ME 303. Special Characters and Matlab Functions.
Algebraic, transcendental (i.e., involving trigonometric and exponential functions), ordinary differential equations, or partial differential equations...
Linear Systems LU Factorization CSE 541 Roger Crawfis.
MATH 685/ CSI 700/ OR 682 Lecture Notes
Scientific Computing Linear Systems – Gaussian Elimination.
LU Factorization LU-factorization Matrix factorization Forward substitution Back substitution.
Systems of Linear Equations
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.
Lecture 9: Introduction to Matrix Inversion Gaussian Elimination Sections 2.4, 2.5, 2.6 Sections 2.2.3, 2.3.
Numerical Algorithms Matrix multiplication
Speaker: Lung-Sheng Chien
Solution of linear system of equations
Chapter 9 Gauss Elimination The Islamic University of Gaza
Chapter 2, Linear Systems, Mainly LU Decomposition.
1cs542g-term Notes  Assignment 1 is out (due October 5)  Matrix storage: usually column-major.
Linear Algebraic Equations
Linear Systems of Equations Ax = b Marco Lattuada Swiss Federal Institute of Technology - ETH Institut für Chemie und Bioingenieurwissenschaften ETH Hönggerberg/
Chapter 15 C-implementation PA = LU Speaker: Lung-Sheng Chien.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 17 Solution of Systems of Equations.
The Terms that You Have to Know! Basis, Linear independent, Orthogonal Column space, Row space, Rank Linear combination Linear transformation Inner product.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 15 Solution of Systems of Equations.
ECIV 520 Structural Analysis II Review of Matrix Algebra.
Math for CSLecture 31 LU Decomposition Pivoting Diagonalization Gram-Shcmidt Orthogonalization Lecture 3.
Ordinary least squares regression (OLS)
Chapter 17 C-implementation PAP’ = LDL’ Speaker: Lung-Sheng Chien Reference: [1] H. M. Deitel, P. J. Deitel, C++ How to Program 5-th edition.
Mujahed AlDhaifallah (Term 342) Read Chapter 9 of the textbook
Math for CSLecture 31 LU Decomposition Pivoting Diagonalization Gram-Shcmidt Orthogonalization Lecture 3.
Systems of Linear Equations
1 Systems of Linear Equations Gauss-Jordan Elimination and LU Decomposition.
Chapter 12 Gaussian Elimination (II) Speaker: Lung-Sheng Chien Reference book: David Kincaid, Numerical Analysis Reference lecture note: Wen-wei Lin, chapter.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 1.1 © 2012 Pearson Education, Inc. Linear Equations in Linear Algebra SYSTEMS OF LINEAR EQUATIONS.
Computational Methods in Physics PHYS 3437 Dr Rob Thacker Dept of Astronomy & Physics (MM-301C)
Scientific Computing Linear Systems – LU Factorization.
Eigenvalue Problems Solving linear systems Ax = b is one part of numerical linear algebra, and involves manipulating the rows of a matrix. The second main.
Linear Algebra and Complexity Chris Dickson CAS Advanced Topics in Combinatorial Optimization McMaster University, January 23, 2006.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
MA2213 Lecture 5 Linear Equations (Direct Solvers)
ΑΡΙΘΜΗΤΙΚΕΣ ΜΕΘΟΔΟΙ ΜΟΝΤΕΛΟΠΟΙΗΣΗΣ 4. Αριθμητική Επίλυση Συστημάτων Γραμμικών Εξισώσεων Gaussian elimination Gauss - Jordan 1.
Chapter 3 Solution of Algebraic Equations 1 ChE 401: Computational Techniques for Chemical Engineers Fall 2009/2010 DRAFT SLIDES.
 6.2 Pivoting Strategies 1/17 Chapter 6 Direct Methods for Solving Linear Systems -- Pivoting Strategies Example: Solve the linear system using 4-digit.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 21.
Lecture 8 Matrix Inverse and LU Decomposition
Chapter 5 MATRIX ALGEBRA: DETEMINANT, REVERSE, EIGENVALUES.
Chapter 3 Determinants Linear Algebra. Ch03_2 3.1 Introduction to Determinants Definition The determinant of a 2  2 matrix A is denoted |A| and is given.
Lesson 3 CSPP58001.
Direct Methods for Sparse Linear Systems Lecture 4 Alessandra Nardi Thanks to Prof. Jacob White, Suvranu De, Deepak Ramaswamy, Michal Rewienski, and Karen.
Direct Methods for Linear Systems Lecture 3 Alessandra Nardi Thanks to Prof. Jacob White, Suvranu De, Deepak Ramaswamy, Michal Rewienski, and Karen Veroy.
Chapter 9 Gauss Elimination The Islamic University of Gaza
ECE 530 – Analysis Techniques for Large-Scale Electrical Systems Prof. Hao Zhu Dept. of Electrical and Computer Engineering University of Illinois at Urbana-Champaign.
1 Chapter 7 Numerical Methods for the Solution of Systems of Equations.
Linear Systems Dinesh A.
Gaoal of Chapter 2 To develop direct or iterative methods to solve linear systems Useful Words upper/lower triangular; back/forward substitution; coefficient;
Unit #1 Linear Systems Fall Dr. Jehad Al Dallal.
2 - 1 Chapter 2A Matrices 2A.1 Definition, and Operations of Matrices: 1 Sums and Scalar Products; 2 Matrix Multiplication 2A.2 Properties of Matrix Operations;
Lecture 9 Numerical Analysis. Solution of Linear System of Equations Chapter 3.
Numerical Computation Lecture 6: Linear Systems – part II United International College.
1 Numerical Methods Solution of Systems of Linear Equations.
MAT 322: LINEAR ALGEBRA.
Spring Dr. Jehad Al Dallal
Linear Equations.
Linear Algebra Lecture 15.
Chapter 10: Solving Linear Systems of Equations
Numerical Analysis Lecture14.
Numerical Analysis Lecture10.
Ax = b Methods for Solution of the System of Equations (ReCap):
Presentation transcript:

Chapter 13 Gaussian Elimination (III) Bunch-Parlett diagonal pivoting Speaker: Lung-Sheng Chien Reference: James R. Bunch and Linda Kaufman, Some Stable Methods for Calculating Inertia and Solving Symmetric Linear Systems, Mathematics of Computation, volume 31, number 137, January 1977, page 163-179

OutLine Preliminary - 1x1, 2x2 pivoting in Gaussian Elimination - real symmetric indefinite matrix Symmetric permutation LDL’ decomposition (diagonal pivoting) Example of complete diagonal pivoting Algorithm of complete diagonal pivoting

Pivoting in Traditional Gaussian Elimination consider then one step LU-factorization leads to where and It is easy to show from Gaussian Elimination We use principal submatrix as pivoting, called pivoting since Question: can we use or higher pivoting, i.e.

2x2 pivoting in block Gaussian Elimination If principal sub-matrix is non-singular, then one-step GE leads to Example 1: pivoting where and

3x3 pivoting in block Gaussian Elimination Example 2: pivoting where and Question: what is criterion to choose 1x1, 2x2 or 3x3 pivoting? stability performance Question: what is the cost to estimate the criterion ?

Real symmetry indefinite matrix A is symmetric implies and From linear algebra, if A is real symmetric, then A has real spectrum decomposition (譜分解) and or write in matrix form and without loss of generality, we can rearrange eigen-values to be increasing Definition: suppose matrix A is real symmetric, then we say “A is indefinite” if there exists an eigen-value of A less than zero. If A is nonsingular, then Thereafter we focus on LU-decomposition of symmetry indefinite matrix A

LU-factorization for real symmetry indefinite matrix A where and Question: why not LU-decomposition? A is real symmetric, we only store lower triangle part of A, say

Pointer array to store lower triangular part of A row-major based col-major based Question: what is the cost to fetch one element of A ? That is, operation count for Question: can you find another representation for lower part of matrix A ? Question: if one uses row-major to store lower part of matrix A, then how to fetch a column of A efficiently?

OutLine Preliminary Symmetric permutation - change diagonal element to (1,1) position - change off-diagonal element to (2,1) position - implementation of symmetric permutation LDL’ decomposition (diagonal pivoting) Example of complete diagonal pivoting Algorithm of complete diagonal pivoting

How to do permutation on real symmetry indefinite matrix A Let Define permutation matrix interchange row 2, 3 interchange column 2, 3 Symmetric permutation: 1 2 3 1 2 3 1 3 2 interchange row 2, 3 interchange column 2, 3 2 4 5 3 5 6 3 6 5 3 5 6 2 4 5 2 5 4

Change diagonal element to (1,1) position [1] suppose we want to change to position (1,1) , then consider permutation and do symmetric permutation on A, say 8 6 3 9 1 2 3 4 3 2 1 4 6 5 2 7 2 5 6 7 interchange col 1, 3 6 5 2 7 interchange row 1, 3 3 2 1 4 3 6 8 9 8 6 3 9 9 7 4 10 4 7 9 10 9 7 4 10 Question: we only store lower triangle part of matrix A, above permutation does not work, how to modify it? Observation 1: 1 2 3 4 8 2 3 4 2 5 6 7 2 5 6 7 3 6 8 9 3 6 1 9 4 7 9 10 4 7 9 10

Change diagonal element to (1,1) position [2] Observation 2: we only need to update lower triangle part of A (diagonal term is excluded ). 8 2 3 4 2 5 6 7 2 3 6 1 9 6 4 7 9 10 4 7 9 diagonal term does not changed we have changed does not changed

Change diagonal element to (1,1) position [3] 6 2 2 6 2 2 6 interchange col 1, 3 6 2 interchange row 1, 3 2 6 6 9 7 4 4 7 9 9 7 4 Keep lower triangle part 8 8 6 5 Fill-in A(3,1) 6 5 Fill-in diagonal term 6 3 2 1 2 1 2 9 7 4 10 9 7 4 10 9 7 4 Question: any compact form to represent above interchange?

Change diagonal element to (1,1) position [4] 2 6 2 6 6 2 4 7 9 9 7 4 4 7 9 case 1: 4 7 9 case 2: 2 6

Change diagonal element to (1,1) position [5] For general real symmetric matrix A with dimension n, suppose we want to change interchanges rows or columns Step 1: interchange position (1,1) and (k,k), i.e. keep position (k,1) and (1,k), i.e. does not changed

Change diagonal element to (1,1) position [6] Step 2: interchange column 1 and k below row k+1, i.e Therefore

Change diagonal element to (1,1) position [7] Step 3: interchange column 1 (from row-2 to row-(k-1)) and row k (from col-2 to col-(k-1)) Therefore

Implementation of symmetric permutation: swapping overhead [1] Suppose we use col-major based pointer array to store real symmetric matrix A Step 2: interchanging column 1 and k is O.K since memory block is contiguous. Contiguous memory block

Implementation of symmetric permutation: swapping overhead [2] Step 3: interchanging column 1 and row k, i.e. is NOT efficient since is NOT contiguous. NOT contiguous, swapping is very slow. Observation: the situation is the same even we choose row-major based pointer array as storage strategy. Solution: in order to avoid high swapping overhead, we should avoid permutation.

Change off-diagonal element to (2,1) position [1] suppose we want to change to position (2,1), then consider first permutation which change first index from 4 to 2 1 4 3 2 1 2 3 4 1 4 3 2 4 10 9 7 2 5 6 7 interchange col 2, 4 2 7 6 5 interchange row 2, 4 3 9 8 6 3 6 8 9 3 9 8 6 2 7 6 5 4 7 9 10 4 10 9 7 and second permutation which change second index from 3 to 1 1 4 3 2 3 4 1 2 8 9 3 6 4 10 9 7 interchange col 1, 3 9 10 4 7 interchange row 1, 3 9 10 4 7 3 9 8 6 8 9 3 6 3 4 1 2 2 7 6 5 6 7 2 5 6 7 2 5

Change off-diagonal element to (2,1) position [2] 3 4 1 4 3 2 8 9 3 6 2 5 6 7 interchange row and col 2, 4 4 10 9 7 interchange row and col 1, 3 9 10 4 7 3 6 8 9 3 9 8 6 3 4 1 2 4 7 9 10 2 7 6 5 6 7 2 5 Observation: two permutation matrices can be computed easily since 2  4 and 1  3 are independent.

Change off-diagonal element to (2,1) position [3] HOW to transform to position (2,1), under only lower triangle part of A is stored? Observation 1: and does not changed 1 2 3 4 1 4 3 2 2 5 6 7 interchange row/col 2, 4 4 10 9 7 3 6 8 9 3 9 8 6 4 7 9 10 2 7 6 5 Step 1: interchange position (4,4) and (2,2), 1 2 3 4 1 2 3 4 2 5 6 7 2 10 6 7 3 6 8 9 3 6 8 9 4 7 9 10 4 7 9 5

Change off-diagonal element to (2,1) position [4] Observation 2: we only need to update lower triangle part of A (diagonal term is excluded ). 1 2 3 4 2 10 6 7 2 3 6 8 9 3 6 4 7 9 5 4 9 Step 2: interchange row 2 and 4 below col 2, i.e 2 interchange row 2, 4 4 9 interchange col 2, 4 4 9 3 6 3 6 3 9 6 4 9 2 6 2 6 NOTE: Interchanging column 2, 4 does not change position (2,1) and (4,1), it suffices to interchange position (2,1) and (4,1) first.

Change off-diagonal element to (2,1) position [5] 4 3 6 3 6 4 9 2 9 Step 3: interchange column 2 (from row-3 to row-3) and row 4 (from col-3 to col-3) 4 4 3 6 3 9 2 9 2 6

Change off-diagonal element to (2,1) position [6] For general real symmetric matrix A with dimension n, suppose we want to change interchanges rows or columns Step 1: interchange position (2,2) and (k,k), i.e. keep position (k,2) and (2,k), i.e. does not changed

Change off-diagonal element to (2,1) position [7] Step 2: interchange column 2 and k below row k+1, i.e Therefore

Change off-diagonal element to (2,1) position [8] Step 3: interchange row 2 (column 1) and row k (column1), i.e Therefore

Change off-diagonal element to (2,1) position [9] Step 4: interchange column 2 (from row-3 to row-(k-1)) and row k (from col-3 to col-(k-1)) Therefore

OutLine Preliminary Symmetric permutation LDL’ decomposition (diagonal pivoting) - growth rate of 1x1, 2x2 pivoting - criterion for pivot strategy - comparison to complete pivoting in GE Example of complete diagonal pivoting Algorithm of complete diagonal pivoting

LDL’ decomposition: 1x1, 2x2 pivoting diagonal pivoting method with complete pivoting: Bunch-Parlett, “Direct methods fro solving symmetric indefinite systems of linear equations,” SIAM J. Numer. Anal., v. 8, 1971, pp. 639-655 diagonal pivoting method with partial pivoting: Bunch-Kaufman, “Some Stable Methods for Calculating Inertia and Solving Symmetric Linear Systems,” Mathematics of Computation, volume 31, number 137, January 1977, page 163-179

Growth rate in LDL’ decomposition [1] is of order maximal element of matrix A Define and constant maximal diagonal element of matrix A Case 1: s = 1 where with with and with

Growth rate in LDL’ decomposition [2] Therefore Observation: in PA=LU, we choose such that implies Therefore Observation: large element growth will not occur for a pivot if is large relative to

Growth rate in LDL’ decomposition [3] Case 2: s = 2 where and with and with and with implies

Growth rate in LDL’ decomposition [4] for Therefore

Growth rate in LDL’ decomposition [5] Therefore

Criterion for pivot strategy [1] Fix a number ( later on, we will determine optimal value of ) maximal element of matrix A maximal diagonal element of matrix A Case 1: suppose we interchange 1st and k-th rows and columns by introducing permutation matrix and do symmetric permutation Then do on with pivot, written as

Criterion for pivot strategy [2] Recall for pivot, , we have growth rate and Now for and Case 2: suppose , we interchange q-th and 1st rows and columns, and then r-th and 2nd rows and columns by introducing permutation matrix and do symmetric permutation Question: we must change q1 first, then change r 2, why?

Criterion for pivot strategy [3] transforms 1 2 3 (boundary case) but

Criterion for pivot strategy [4] Then do on with pivot, written as Recall for pivot, , we have growth rate and

Criterion for pivot strategy [5] Now for To sum up Case 1: and Case 2: and Question: How to choose value of

Criterion for pivot strategy [6] worst case analysis : choose such that growth rate of pivot + pivot growth rate of pivot or equivalently growth rate of pivot growth rate of pivot Define where satisfies Exercise: verify and

Diagonal pivoting versus complete pivoting of Gaussian Elimination [1] We must search for the largest element in each reduced matrix, this is a complete pivoting strategy analogous to Gaussian Elimination with complete pivoting 1 maximal element of matrix A maximal diagonal element of matrix A complete pivoting of GE (Gaussian Elimination) (1) find a such that (2) swap row and row (2) swap column and column then with

Diagonal pivoting versus complete pivoting of Gaussian Elimination [2] growth rate 2 diagonal pivoting complete pivoting in GE Remark: Bunch [1] proves that the element growth in the diagonal pivoting method with complete pivoting is bounded by in comparison with for Gaussian Elimination with complete pivoting, where [1] J.R. Bunch, “Analysis of the diagonal pivoting method”, SIAM J. Numer. Anal., v. 8, 1971, pp. 656-680

OutLine Preliminary Symmetric permutation LDL’ decomposition (diagonal pivoting) Example of complete diagonal pivoting Algorithm of complete diagonal pivoting

Example (complete pivoting) [1] 6 12 3 -6 12 -8 -13 4 we choose pivot 3 -13 -7 1 swap row/column and by permutation matrix -6 4 1 6 6 -8 -8 -13 12 4 12 -8 12 6 -13 -7 3 1 3 -13 -7 -13 3 -7 12 3 6 -6 -6 4 1 6 4 -6 1 6 4 1 -6 6

Example (complete pivoting) [2] -8 -13 12 4 1 -8 -13 -13 -7 3 1 1 -13 -7 12 3 6 -6 0.3982 -1.1681 1 4.7257 -6.4248 4 1 -6 6 0.1327 -0.3894 1 -6.4248 5.8584 Recursively do the same procedure for we choose pivot swap row/column by permutation matrix such that

Example (complete pivoting) [3] Do symmetry permutation for and -8 -13 -8 -13 -13 -7 -13 -7 4.7257 -6.4248 5.8584 -6.4248 -6.4248 5.8584 -6.4248 4.7257 1 1 1 1 0.3982 -1.1681 1 0.1327 -0.3894 1 0.1327 -0.3894 1 0.3982 -1.1681 1 5.8584 -6.4248 we do pivot on -6.4248 4.7257

Example (complete pivoting) [4] 5.8584 -6.4248 1 5.8584 1 -1.0967 -6.4248 4.7257 -1.0967 1 -2.3202 1 Or write in original matrix form -8 -13 1 -8 -13 -13 -7 1 -13 -7 5.8584 -6.4248 1 5.8584 -6.4248 4.7257 -1.0967 1 -2.3202

Example (complete pivoting) [5] 1 -8 -13 1 -13 -7 0.1327 -0.3984 1 5.8584 0.3982 -1.1681 -1.0967 1 -2.3202 In practice, we have two key issues col-major based 1 we only store lower part of matrix 6 6 -8 -7 6 12 -8 12 -13 1 3 -13 -7 3 4 -6 4 1 6 -6

Example (complete pivoting) [6] 2 we store decomposition and into original 1 -8 1 -13 -7 0.1327 -0.3984 1 5.8584 0.3982 -1.1681 -1.0967 1 -2.3202 -8 -13 -7 0.1327 -0.3984 5.8584 0.3982 -1.1681 -1.0967 -2.3202 Question: How can you judge correct decomposition from

Example (complete pivoting) [7] Case 1: four 1x1 pivot 1 -8 13 1 -7 0.1327 -0.3984 1 5.8584 0.3982 -1.1681 -1.0967 1 -2.3202 Case 2: two 2x2 pivot 1 -8 1 -13 -7 0.1327 -0.3984 1 5.8584 0.3982 -1.1681 1 -1.0967 -2.3202

Example (complete pivoting) [8] Case 3: 1x1 pivot + 2x2 pivot + 1x1 pivot -8 1 -7 -13 1 -0.3984 5.8584 0.1327 1 -2.3202 0.3982 -1.1681 -1.0967 1 Case 4: 2x2 pivot + 1x1 pivot + 1x1 pivot 1 -8 1 -13 -7 0.1327 -0.3984 1 5.8584 0.3982 -1.1681 -1.0967 1 -2.3202 Solution: we need an array to record pivot sequence 1x1 pivot pivot 2 1 1 2x2 pivot

OutLine Preliminary Symmetric permutation LDL’ decomposition (diagonal pivoting) Example of complete diagonal pivoting Algorithm of complete diagonal pivoting

Algorithm ( PAP’ = LDL’ ) [1] Given symmetric indefinite matrix , construct initial lower triangle matrix use permutation vector to record permutation matrix let , and while we have compute update original matrix , where combines all lower triangle matrix and store in

Algorithm ( PAP’ = LDL’ ) [2] 1 compute and Case 1: define permutation to do symmetric permutation 2 To compute , we only update lower triangle of 1 1 3 2 3 3 then 2

Algorithm ( PAP’ = LDL’ ) [3] To compute 4 We only update lower triangle matrix then 5 do 1x1 pivot : then 6 and

Algorithm ( PAP’ = LDL’ ) [4] Case 2: define permutation to interchange q-th and k-th rows and columns, and then r-th and (k+1)-th rows and columns 7 and then To compute , we only update lower triangle of (1) do interchange row/col 1 1 8 2 3 3 then 2

Algorithm ( PAP’ = LDL’ ) [5] 9 (2) do interchange row/col 1 2 3 4 1 3 4 then where 2

Algorithm ( PAP’ = LDL’ ) [6] To compute 10 (1) do interchange row 11 (2) do interchange row then

Algorithm ( PAP’ = LDL’ ) [7] 12 do 2x2 pivot : then 13 and means is 2x2 pivot endwhile

Question: recursion implementation Initialization - check algorithm holds for k=1 Recursion formula - check algorithm holds for k or k+1, if k-1 is true Termination condition - check algorithm holds for k=n-1 Breakdown of algorithm - check which condition PAP’=LDL’ fails No extension: algorithm works only for square, symmetric indefinite matrix. normal abnormal Extension of algorithm

MATLAB implementation [1] Given a (full) symmetric indefinite matrix , compute factorization return four quantities Remark: try to neglect upper triangle part of in MATLAB implementation Example : 6 12 3 -6 12 -8 -13 4 2 3 4 1 return : 3 -13 -7 1 2 1 1 -6 4 1 6 1 -8 1 -13 -7 0.1327 -0.3984 1 5.8584 0.3982 -1.1681 -1.0967 1 -2.3202

MATLAB implementation [2] When factorization is complete, , you need to provide linear solver 1 define , then by forward substitution 2 define , then by diagonal block inversion Example: , then 3 define , then by backward substitution However you cannot transpose explicitly in MATLAB 4 , you must scan once to determine