Presentation on theme: "Chem 302 - Math 252 Chapter 2 Solutions of Systems of Linear Equations / Matrix Inversion."— Presentation transcript:
Chem Math 252 Chapter 2 Solutions of Systems of Linear Equations / Matrix Inversion
Solutions of Systems of Linear Equations n linear equations, n unknowns Three possibilities –Unique solution –No solution –Infinite solutions Numerically systems that are almost singular cause problems –Range of solutions –Ill-conditioned problem Singular Systems
Solutions of Systems of Linear Equations Direct Methods –Determine solution in finite number of steps –Usually preferred –Round-off error can cause problems Indirect Methods –Use iteration scheme –Require infinite operations to determine exact solution –Useful when Direct Methods fail
Cramer’s Rule 1.Write coefficient matrix (A) 2.Evaluate |A| –If |A|=0 then singular 3.Form A 1 –Replace column 1 of A with answer column 4.Compute x 1 = |A 1 |/|A| 5.Repeat 3 and 4 for other variables
Cramer’s Rule Not singular: System has unique solution
Good for small systems Good if only one or two variables are needed Very slow and inefficient for large systems –n order system requires (n+1)! × & (n+1)! Additions 2 nd order 6 ×, th order ×, th order 1.27× ×, 1.27×
Gaussian Elimination 1.Form augmented matrix 2.Use elementary row operations to transform the augmented matrix so that the A portion is in upper triangular form Switch rows Multiply row by constant Linear combination of rows 3.Use back substitution to find solutions Requires n 3 +n 2 - n ×, n 3 +½n 2 - n +
Gauss-Jordan Elimination 1.Form augmented matrix 2.Normalize 1 st row 3.Use elementary row operations to transform the augmented matrix so that the A portion is the identity matrix Switch rows Multiply row by constant Linear combination of rows Requires ½n 3 +n 2 - 2½n+2 ×, ½n 3 -1½n+1 + Can also be used to find matrix inverse
Maximum Pivot Strategy Elimination methods can run into difficulties if one or more of diagonal elements is close to (or exactly) zero Normalize row with largest (magnitude) element.
Comparison of Direct Methods Small systems (n<10) not a big deal Large systems critical Number of floating point operations nCramer’sGaussian EliminationGauss-Jordan Elimination × × × × ×10 9
Comparison of Direct Methods Time required on a 300 MFLOP computer (500 TFLOP) nCramer’sGaussian EliminationGauss-Jordan Elimination 2 2.4×10 -8 s1.8×10 -8 s1.4×10 -8 s 3 9.6×10 -8 s5.6×10 -8 s5.4×10 -8 s 4 4.8×10 -7 s1.2×10 -7 s1.3×10 -7 s 5 2.9×10 -6 s2.3×10 -7 s2.7×10 -7 s s1.6×10 -6 s2.1×10 -6 s years (2.4 days)1.2×10 -5 s1.7×10 -5 s 100 1× (1× ) years1.4×10 -3 s2.0×10 -3 s ( ) years1.32
Indirect Methods Jacobi Method Gauss-Seidel Method Use iterations –Guess solution –Iterate to self consistent Can be combined with Direct Methods
Jacobi Method Rearrange system of equations to isolate the diagonal elements Guess solution Iterate until self-consistent
Jacobi Method iterationx1x2x
Gauss-Seidel Method Same as Jacobi method, but use updated values as soon as they are calculated.