Solution of linear equations using Gaussian elimination Home

  • Slides: 17
Download presentation
Solution of linear equations using Gaussian elimination

Solution of linear equations using Gaussian elimination

Home Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Resources Gaussian

Home Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Resources Gaussian Elimination Method Gaussian Elimination HOME Procedure Programming Exercise Resources Info FAQ References Summary

Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Resources Learning objectives

Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Resources Learning objectives in this module 1. Develop problem solution skills using computers and numerical methods 2. Review the Gaussian elimination method for solving simultaneous linear equations 3. Develop programming skills using FORTRAN New FORTRAN elements in this module -use of NAG-library Info FAQ References Summary

Introduction Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Resources Solution

Introduction Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Resources Solution of sets of linear equations is required in many petroleum applications. Many methods exist for this purpose, direct methods as well as iterative methods. The reference mentioned in the end may be consulted for a review of such methods. A direct method frequently used in petroleum applications is the Gaussian elimination method, and the simplest form of this method will be discussed below. First, let’s review the concept of simultaneous linear equations. A set of linear simultaneous equations may be written as: . . . . Info FAQ References Summary

Introduction Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure . . . .

Introduction Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure . . . . Programming exercise Resources Ø Here we have a total of N unknowns (xj, j=1, 2… N), related through M equations. The coefficients in the left sides of the equations (aij, i=1, 2… N ; j=1, 2… M ) are known parameters, and so are also the coefficients on the right side (bi, i=1, 2… M). Info FAQ References Summary

Introduction Learning Objectives The equations may alternatively be written in a compact form: Introduction

Introduction Learning Objectives The equations may alternatively be written in a compact form: Introduction Gaussian elimination method Gaussian elimination procedure where A is the coefficient matrix, and b is the right hand side vector: Programming exercise Resources If the number of unknowns is equal to the number of equations, N=M, we may be able to solve the set of equations, provided that the equations are unique. Gaussian Elimination Method Info FAQ References Summary

Gaussian elimination method Learning Objectives Introduction Gaussian elimination method For simplicity, let’s use the

Gaussian elimination method Learning Objectives Introduction Gaussian elimination method For simplicity, let’s use the following set of 3 equations and 3 unknowns, ie. N=3 and M=3, in order to illustrate the Gaussian elimination method: Gaussian elimination procedure (4) Programming exercise (5) Resources (6) The method starts by multiplying Eq. (4) by –a 21/a 11 and then add it to Eq. (5). The resulting equation becomes: We then multiply Eq. (4) by and add it to Eq. (6), resulting in: Info FAQ References Summary

Gaussian elimination method Learning Objectives Introduction The set of equation has now become Gaussian

Gaussian elimination method Learning Objectives Introduction The set of equation has now become Gaussian elimination method (7) Gaussian elimination procedure (8) Programming exercise Resources (9) Next, we multiply Eq. (8) by –a’ 32/a’ 22 and add it to Eq. (9), so that the set of equations become: (10) (11) (12) This completes the first part of the Gaussian elimination method, called the forward elimination process. Continue to the Second Part Info FAQ References Summary

Gaussian elimination method Learning Objectives Introduction Eq. (12) may now be used to solve

Gaussian elimination method Learning Objectives Introduction Eq. (12) may now be used to solve directly for x 3: Gaussian elimination method Gaussian elimination procedure Programming exercise Resources (13) After completion of the forward elimination process, determined the last unknown of the vector (x 3) by Eq. (13), we will perform a back substitution process. This simply means that as the unknowns are calculated, in our simple example from x 3 and downwards, they are substituted into the equations above, and the next unknown may be computed. For Eqs. (12) and (11) this process is carried out as follows: (14) (15) Based on the example above, we may formulate a general procedure for the forward elimination, solution for the last unknown, and back substitution to get the rest of the unknowns Gaussian Elimination Procedure Info FAQ References Summary

Gaussian elimination procedure Learning Objectives 1) Forward elimination: Introduction Gaussian elimination method Gaussian elimination

Gaussian elimination procedure Learning Objectives 1) Forward elimination: Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Resources 2) Solving for x. N: 3) Back substitution: Info FAQ References Summary

Programming Exercise Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Make

Programming Exercise Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Make a FORTRAN program consisting of a main program, that reads the coefficients of the system of equations (n, a 1, 1…an, n , d 1…dn) from an input file (IN. DAT) and writes the results (x 1…xn) to an out-file (OUT. DAT), and a subroutine, SUBROUTINE GAUSS(X, A, D, N), that uses the Gaussian elimination method in order to solve the set of equations and returns n values of x to the main program Resources Test the program on the following set of equations: Push 2 x +3 y +4 z -5 s +7 t = -35 8 x -2 y -3 z +9 s +3 t = +53 4 y +6 z -3 s -2 t = -33 5 x -7 y +8 z +3 s -9 t = -19 3 x +5 y -2 z +4 s +6 t = +27 Continue Info FAQ References Summary

Programming Exercise Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Resources

Programming Exercise Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Resources The Petra-server includes a NAG-library of scientific subroutines. Find a subroutine in this library (use naghelp) that may be used for solution of simultaneous equations (Gaussian elimination method or some other method). Modify the program above so that is asks you on the screen if you want to use the programmed Gaussian-routine or the NAG-routine for the solution. Check that the solutions from the two methods are identical. (Note that all real variables should be declared as REAL*8 (double precision) since the NAG-routines require this) The NAG-routine may be linked in by the command xlf –o prog fil. f –L/localiptibm 3/lib –l nag Resources Info FAQ References Summary

Resources Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Resources Introduction

Resources Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Resources Introduction to Fortran Template here The whole exercise in a printable format here Web sites Ø Numerical Recipes In Fortran Ø Fortran Tutorial Ø Professional Programmer's Guide to Fortran 77 Ø Programming in Fortran 77 Info FAQ References Summary

General information Learning Objectives Title: Solution of linear equations using Gaussian elimination Teacher(s): Professor

General information Learning Objectives Title: Solution of linear equations using Gaussian elimination Teacher(s): Professor Jon Kleppe Assistant(s): Per Jørgen Dahl Svendsen Gaussian elimination procedure Abstract: Provide a good background for solving problems within petroleum related topics using numerical methods Programming exercise 4 keywords: Linear equations, Gaussian elimination, matrices, subroutines Introduction Gaussian elimination method Resources Topic discipline: Level: 2 Prerequisites: None Learning goals: Develop problem solution skills using computers and numerical methods Size in megabytes: 0. 6 MB Software requirements: MS Power Point 2002 or later, Flash Player 6. 0 Estimated time to complete: Copyright information: The author has copyright to the module and use of the content must be in agreement with the responsible author or in agreement with http: //www. learningjournals. net. About the author Info FAQ References Summary

FAQ Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Resources No

FAQ Learning Objectives Introduction Gaussian elimination method Gaussian elimination procedure Programming exercise Resources No questions have been posted yet. However, when questions are asked they will be posted here. Remember, if something is unclear to you, it is a good chance that there are more people that have the same question For more general questions and definitions try these Dataleksikon Webopedia Schlumberger Oilfield Glossary Info FAQ References Summary

References Learning Objectives Introduction Gaussian elimination method W. H. Preuss, et al. , “Numerical

References Learning Objectives Introduction Gaussian elimination method W. H. Preuss, et al. , “Numerical Recipes in Fortran”, 2 nd edition Cambridge University Press, 1992 Gaussian elimination procedure Programming exercise Resources References to the textbook : Ø Gauss Jordan elimination: Ø Gaussian Elimination with backsubstitution: Info FAQ page 27 page 33 References Summary

Summary Learning Objectives Introduction Subsequent to this module you should. . . Gaussian elimination

Summary Learning Objectives Introduction Subsequent to this module you should. . . Gaussian elimination method Gaussian elimination procedure Programming exercise Resources Ø Ø be familiar with the Gaussian Elimination Method have a good feel for how Nag routines are used know how to efficiently use subroutines have obtained a better understanding on solving problems in Fortran Info FAQ References Summary