ΑΡΙΘΜΗΤΙΚΕΣ ΜΕΘΟΔΟΙ ΜΟΝΤΕΛΟΠΟΙΗΣΗΣ 4. Αριθμητική Επίλυση Συστημάτων Γραμμικών Εξισώσεων Gaussian elimination Gauss - Jordan 1.

Slides:



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

Algebraic, transcendental (i.e., involving trigonometric and exponential functions), ordinary differential equations, or partial differential equations...
MATH 685/ CSI 700/ OR 682 Lecture Notes
1 Parallel Algorithms II Topics: matrix and graph algorithms.
Simultaneous Linear Equations
Simultaneous Linear Equations
Lecture 7 Intersection of Hyperplanes and Matrix Inverse Shang-Hua Teng.
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.
Part 3 Chapter 9 Gauss Elimination
Solution of linear system of equations
Chapter 9 Gauss Elimination The Islamic University of Gaza
Major: All Engineering Majors Author(s): Autar Kaw
Ecuaciones Algebraicas lineales. An equation of the form ax+by+c=0 or equivalently ax+by=- c is called a linear equation in x and y variables. ax+by+cz=d.
Linear Algebraic Equations
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 14 Elimination Methods.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 15 Solution of Systems of Equations.
Algorithm for Gauss elimination 1) first eliminate for each eq. j, j=1 to n-1 for all eq.s k greater than j a) multiply eq. j by a kj /a jj b) subtract.
ECIV 301 Programming & Graphics Numerical Methods for Engineers REVIEW II.
MOHAMMAD IMRAN DEPARTMENT OF APPLIED SCIENCES JAHANGIRABAD EDUCATIONAL GROUP OF INSTITUTES.
Mujahed AlDhaifallah (Term 342) Read Chapter 9 of the textbook
Systems of Linear Equations
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Part 31 Chapter.
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
Solving System of Linear Equations. 1. Diagonal Form of a System of Equations 2. Elementary Row Operations 3. Elementary Row Operation 1 4. Elementary.
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 ~ Linear Algebraic Equations ~ Gauss Elimination Chapter.
Major: All Engineering Majors Author(s): Autar Kaw
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. by Lale Yurttas, Texas A&M University Part 31 Linear.
Linear Systems Gaussian Elimination CSE 541 Roger Crawfis.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Chemical Engineering Majors Author(s): Autar Kaw
Lecture 8 Matrix Inverse and LU Decomposition
Lecture 7 - Systems of Equations CVEN 302 June 17, 2002.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 3 - Chapter 9 Linear Systems of Equations: Gauss Elimination.
Gaussian Elimination Electrical Engineering Majors Author(s): Autar Kaw Transforming Numerical Methods Education for.
Chapter 9 Gauss Elimination The Islamic University of Gaza
Simultaneous Linear Equations
Gaussian Elimination Industrial Engineering Majors Author(s): Autar Kaw Transforming Numerical Methods Education for.
Gaussian Elimination Mechanical Engineering Majors Author(s): Autar Kaw Transforming Numerical Methods Education for.
Part 3 Chapter 9 Gauss Elimination PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The McGraw-Hill Companies,
Gaussian Elimination Civil Engineering Majors Author(s): Autar Kaw Transforming Numerical Methods Education for STEM.
Unit #1 Linear Systems Fall Dr. Jehad Al Dallal.
Linear Algebra Review Tuesday, September 7, 2010.
Autar Kaw Benjamin Rigsby Transforming Numerical Methods Education for STEM Undergraduates.
1 SYSTEM OF LINEAR EQUATIONS BASE OF VECTOR SPACE.
Lecture 9 Numerical Analysis. Solution of Linear System of Equations Chapter 3.
Numerical Methods. Introduction Prof. S. M. Lutful Kabir, BRAC University2  One of the most popular techniques for solving simultaneous linear equations.
1 Numerical Methods Solution of Systems of Linear Equations.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 3 - Chapter 9.
Numerical Methods. Prof. S. M. Lutful Kabir, BRAC University2  One of the most popular techniques for solving simultaneous linear equations is the Gaussian.
Pitfalls of Gauss Elimination ● Division by zero (avoid by pivoting) ● Round-off errors – Important with >100 eqns – Substitute answer into original eqn.
Part 3 Chapter 9 Gauss Elimination
Simultaneous Linear Equations
Spring Dr. Jehad Al Dallal
Gaussian Elimination.
Choi, Jong-In Lee, Ho-Keun Shim, Yoon-Sik
Gauss-Siedel Method.
Chapter 10: Solving Linear Systems of Equations
Naïve Gauss Elimination Pitfalls
Autar Kaw Benjamin Rigsby
Part 3 - Chapter 9.
Simultaneous Linear Equations
Major: All Engineering Majors Author(s): Autar Kaw
Numerical Analysis Lecture14.
Numerical Analysis Lecture10.
Simultaneous Linear Equations
Lecture 13 Simultaneous Linear Equations – Gaussian Elimination (2) Partial Pivoting Dr .Qi Ying.
Simultaneous Linear Equations Gaussian Elimination with Partial Pivoting
Naïve Gauss Elimination Pitfalls
Presentation transcript:

ΑΡΙΘΜΗΤΙΚΕΣ ΜΕΘΟΔΟΙ ΜΟΝΤΕΛΟΠΟΙΗΣΗΣ 4. Αριθμητική Επίλυση Συστημάτων Γραμμικών Εξισώσεων Gaussian elimination Gauss - Jordan 1

Direct solution Methods Gaussian Elimination –Matrix A is transformed into an upper triangular matrix (all elements below diagonal 0) –Back substitution is used to solve the upper-triangular system  Back substitution 2

Gauss Elimination (μέθοδος απαλοιφής Gauss) 1. Gauss Elimination 2. Gauss Elimination Pitfalls 3. Gauss Elimination with Partial Pivoting 4. Determinant of a Square Matrix Using Gauss Elimination 3

1. Gaussian Elimination A method to solve simultaneous linear equations of the form [A][X]=[C] Two steps 1. Forward Elimination 2. Back Substitution 4

Forward Elimination The goal of forward elimination is to transform the coefficient matrix into an upper triangular matrix 5

Forward Elimination A set of n equations and n unknowns.. (n-1) steps of forward elimination 6

Forward Elimination Step 1 For Equation 2, divide Equation 1 by and multiply by. 7

Forward Elimination Subtract the result from Equation 2. − _________________________________________________ or 8

Forward Elimination Repeat this procedure for the remaining equations to reduce the set of equations as... End of Step 1 9

Step 2 Repeat the same procedure for the 3 rd term of Equation 3. Forward Elimination.. End of Step 2 10

Forward Elimination At the end of (n-1) Forward Elimination steps, the system of equations will look like.. End of Step (n-1) 11

Matrix Form at End of Forward Elimination 12

Back Substitution Solve each equation starting from the last equation Example of a system of 3 equations 13

Back Substitution Starting Eqns.. 14

Back Substitution Start with the last equation because it has only one unknown 15

Back Substitution 16

Forward Elimination For i = 1 to n-1 { // for each equation For j = i+1 to n { // for each target equation below the current For k = i+1 to n { // for each element beyond pivot column } Computational Complexity divisions multiply-add’s O(n 3 ) 17

Computational Complexity Backward Substitution For i = n-1 to 1 { // for each equation For j = n to i+1 { // for each known variable sum = sum – A ij * x j } multiply-add’s O(n 2 ) 18

Example 1 The upward velocity of a rocket is given at three different times Time, Velocity, The velocity data is approximated by a polynomial as: Find the velocity at t=6 seconds. Table 1 Velocity vs. time data.

Example 1 Cont. Assume Results in a matrix template of the form: Using data from Table 1, the matrix becomes: 20

Example 1 Cont. 1.Forward Elimination 2.Back Substitution 21

Forward Elimination 22

Number of Steps of Forward Elimination Number of steps of forward elimination is ( n  1)  (3  1)  2 23

Divide Equation 1 by 25 and multiply it by 64,. Forward Elimination: Step 1. Subtract the result from Equation 2 Substitute new equation for Equation 2 24

Forward Elimination: Step 1 (cont.). Divide Equation 1 by 25 and multiply it by 144,. Subtract the result from Equation 3 Substitute new equation for Equation 3 25

Forward Elimination: Step 2 Divide Equation 2 by −4.8 and multiply it by −16.8,. Subtract the result from Equation 3 Substitute new equation for Equation 3 26

Back Substitution 27

Back Substitution Solving for a 3 28

Back Substitution (cont.) Solving for a 2 29

Back Substitution (cont.) Solving for a 1 30

Gaussian Elimination Solution 31

Example 1 Cont. Solution The solution vector is The polynomial that passes through the three data points is then: 32

2. Gauss Elimination Pitfalls 33

Pitfall#1. Division by zero 34

Is division by zero an issue here? 35

Is division by zero an issue here? YES Division by zero is a possibility at any step of forward elimination 36

Pitfall#2. Large Round-off Errors Exact Solution 37

Pitfall#2. Large Round-off Errors Solve it on a computer using 6 significant digits with chopping 38

Pitfall#2. Large Round-off Errors Solve it on a computer using 5 significant digits with chopping Is there a way to reduce the round off error? 39

Avoiding Pitfalls Increase the number of significant digits Decreases round-off error Does not avoid division by zero 40

Avoiding Pitfalls Gaussian Elimination with Partial Pivoting Avoids division by zero Reduces round off error 41

3. Gauss Elimination with Partial Pivoting 42

Avoiding Pitfalls Gaussian Elimination with Partial Pivoting Avoids division by zero Reduces round off error 43

What is Different About Partial Pivoting? At the beginning of the k th step of forward elimination, find the maximum of If the maximum of the values is in the p th row,then switch rows p and k. 44

Matrix Form at Beginning of 2 nd Step of Forward Elimination 45

Example (2 nd step of FE) Which two rows would you switch? 46

Example (2 nd step of FE) Switched Rows 47

Gaussian Elimination with Partial Pivoting A method to solve simultaneous linear equations of the form [A][X]=[C] Two steps 1. Forward Elimination 2. Back Substitution 48

Forward Elimination Same as Gauss elimination method except that we switch rows before each of the (n-1) steps of forward elimination. 49

Example: Matrix Form at Beginning of 2 nd Step of Forward Elimination 50

Matrix Form at End of Forward Elimination 51

Back Substitution Starting Eqns.. 52

Back Substitution 53

Example 2 Solve the following set of equations by Gaussian elimination with partial pivoting 54

Example 2 Cont. 1.Forward Elimination 2.Back Substitution 55

Forward Elimination 56

Number of Steps of Forward Elimination Number of steps of forward elimination is ( n  1 )=(3  1)=2 57

Forward Elimination: Step 1 Examine absolute values of first column, first row and below. Largest absolute value is 144 and exists in row 3. Switch row 1 and row 3. 58

Forward Elimination: Step 1 (cont.). Divide Equation 1 by 144 and multiply it by 64,. Subtract the result from Equation 2 Substitute new equation for Equation 2 59

Forward Elimination: Step 1 (cont.). Divide Equation 1 by 144 and multiply it by 25,. Subtract the result from Equation 3 Substitute new equation for Equation 3 60

Forward Elimination: Step 2 Examine absolute values of second column, second row and below. Largest absolute value is and exists in row 3. Switch row 2 and row 3. 61

Forward Elimination: Step 2 (cont.). Divide Equation 2 by and multiply it by 2.667, Subtract the result from Equation 3 Substitute new equation for Equation 3 62

Back Substitution 63

Back Substitution Solving for a 3 64

Back Substitution (cont.) Solving for a 2 65

Back Substitution (cont.) Solving for a 1 66

Gaussian Elimination with Partial Pivoting Solution 67

Partial Pivoting: Example Consider the system of equations In matrix form = Solve using Gaussian Elimination with Partial Pivoting using five significant digits with chopping 68

Partial Pivoting: Example Forward Elimination: Step 1 Examining the values of the first column |10|, |-3|, and |5| or 10, 3, and 5 The largest absolute value is 10, which means, to follow the rules of Partial Pivoting, we switch row1 with row1. Performing Forward Elimination 69

Partial Pivoting: Example Forward Elimination: Step 2 Examining the values of the first column |-0.001| and |2.5| or and 2.5 The largest absolute value is 2.5, so row 2 is switched with row 3 Performing the row swap 70

Partial Pivoting: Example Forward Elimination: Step 2 Performing the Forward Elimination results in: 71

Partial Pivoting: Example Back Substitution Solving the equations through back substitution 72

Partial Pivoting: Example Compare the calculated and exact solution The fact that they are equal is coincidence, but it does illustrate the advantage of Partial Pivoting 73

4. Determinant of a Square Matrix Using Gauss Elimination Example 74

Theorem of Determinants If a multiple of one row of [A] n x n is added or subtracted to another row of [A] n x n to result in [B] n x n then det(A)=det(B) 75

Theorem of Determinants The determinant of an upper triangular matrix [A] n x n is given by 76

Forward Elimination of a Square Matrix Using forward elimination to transform [A] n x n to an upper triangular matrix, [U] n x n. 77

Example Using Gaussian elimination find the determinant of the following square matrix. 78

Forward Elimination 79

Forward Elimination: Step 1. Divide Equation 1 by 25 and multiply it by 64,. Subtract the result from Equation 2 Substitute new equation for Equation 2 80

Forward Elimination: Step 1 (cont.). Divide Equation 1 by 25 and multiply it by 144,. Subtract the result from Equation 3 Substitute new equation for Equation 3 81

Forward Elimination: Step 2. Divide Equation 2 by −4.8 and multiply it by −16.8,. Subtract the result from Equation 3 Substitute new equation for Equation 3 82

Finding the Determinant. After forward elimination 83

5. Gaussian Elimination For Tridiagonial System 84

* Introduction of Tridiagonal System?  Special Linear System Arising in Application  A general tridiagonal matrix is a matrix whose nonzero elements are found only on the diagonal, subdiagonal, and superdiagonal of the matrix.  if |i – j | > 1, Tridiagonal Systems I 85

 In Storage  Only the diagonal, subdiagonal, and superdiagonal elements of the general tridiagonal matrix are stored. This is called tridiagonal storage mode.  The elements of a general tridiagonal matrix, A, of order n are stored in three one-dimensional arrays, C, D, and E, each of length n.  array C contains the subdiagonal elements, stored as follows: C = (*, a21, a32, a43,..., an,n-1)  array D contains the main diagonal elements, stored as follows: D = (a11, a22, a33,..., ann)  array E contains the superdiagonal elements, stored as follows: E = (a12, a23, a34,..., an-1,n, *)  where "*" means you do not store an element in that position in the array Tridiagonal Systems II 86

* Example of Tridiagonal Matrix… 2x 1 –x 2 = 1, -x 1 +2x 2 –x 3 = 0, -x 2 +2x 3 –x 4 = 0, -x 3 +2x 4 = 1. Tridiagonal Systems III 87

Gaussian Elimination for Tridiagonal Systems 88

1.B 1 and A n are zero. 2.This algorithm takes advantage of the zero elements that are already present in the coefficient matrix and avoids unnecessary arithmetic operations. Thus, we need to store only the new vectors a and r. Solving a Tridiagonal Systems Using the Thomas Method I 89

Solving a Tridiagonal Systems Using the Thomas Method II  Step 1 : For the first equation  Step 2 : For each of the equation  Step 3 : For the last equation  Step 4 : by back substitution 90

Solving a Tridiagonal Systems Using the Thomas Method III 91

Solving a Tridiagonal Systems Using the Thomas Method IV 92

* The required multiplications and divisions for Thomas method. For the first equation, 2divisions are needed. For each of the next n-2 equations, 2multiplications and 2 divisions are needed. For the last equation, 2 multiplications and 1 division are required. The total for elimination is 5+4(n-2). For the back substitution, n-1 multiplications are needed. Discussion of Thomas method 93

Using the Thomas Method for a System that Would Require Pivoting for Gaussian Elimination I 94

Using the Thomas Method for a System that Would Require Pivoting for Gaussian Elimination II 95

Using the Thomas Method for a System that Would Require Pivoting for Gaussian Elimination III 96

6. Gauss – Jordan Elimination 97

Gauss-Jordan Variation of Gauss elimination Primary motive for introducing this method is that it provides a simple and convenient method for computing the matrix inverse. When an unknown is eliminated, it is eliminated from all other equations, rather than just the subsequent one. All rows are normalized by dividing them by their pivot elements Elimination step results in an identity matrix

Introduction For inverting a matrix, Gauss-Jordan elimination is about as efficient as any other method. For solving sets of linear equations, Gauss-Jordan elimination produces both the solution of the equations for one or more right-hand side vectors b, and also the matrix inverse A −1. However, its principal weaknesses are –(i) that it requires all the right-hand sides to be stored and manipulated at the same time, and –(ii) that when the inverse matrix is not desired, Gauss-Jordan is three times slower than the best alternative technique for solving a single linear set The method’s principal strength is that it is as stable as any other direct method, perhaps even a bit more stable when full pivoting is used 99

Graphical depiction of Gauss-Jordan

102 Gauss-Jordan Elimination Let us consider the set of linearly independent equations. Augmented matrix for the set is:

103 Gauss-Jordan Elimination Step 1: Eliminate x from the 2nd and 3rd equation.

104 Gauss-Jordan Elimination Step 2: Eliminate y from the 3rd equation. 13R’ 2 +R’ 3 R’’ 3 Step 3: 0.5R’ 1 R’ 1 -R’ 2 R’’ 2 (1/168)R’’ 3 R’’’ 3

105 Gauss-Jordan Elimination Step 4: Eliminate z from the 2 nd equation

106 Gauss-Jordan Elimination Step 5-1: Eliminate y from the 1st equation

107 Gauss-Jordan Elimination Step 5-2: Eliminate z from the 1st equation

Example Given the following, determine {x} for the two different loads {c} 108

Solution {c} T = {1 2 3} x 1 = (2)(1) + (-1)(2) + (1)(3) = 3 x 2 = (-2)(1) + (6)(2) + (3)(3) = 19 x 3 = (-3)(1) + (1)(2) + (-4)(3) = -13 {c} T = {4 -7 1) x 1 = (2)(4) + (-1)(-7) + (1)(1)=16 x 2 = (-2)(4) + (6)(-7) + (3)(1) = -47 x 3 = (-3)(4) + (1)(-7) + (-4)(1) =