1 / 40

Chapter 3

Chapter 3. SOLVING SYSTEMS OF LINEAR EQUATIONS. Choi, Jong-In Lee, Ho-Keun Shim, Yoon-Sik. Chapter 3.1. GAUSSIAN ELIMINATION. EX 3.1 Three-by-Three System. Solving three equations in three unknowns. 3.1.1 Using Matrix Notation. I. Write in matrix-vector form : Ax = b.

Mia_John
Download Presentation

Chapter 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 3 SOLVING SYSTEMS OF LINEAR EQUATIONS Choi, Jong-In Lee, Ho-Keun Shim, Yoon-Sik

  2. Chapter 3.1 GAUSSIAN ELIMINATION

  3. EX 3.1 Three-by-Three System • Solving three equations in three unknowns

  4. 3.1.1 Using Matrix Notation I • Write in matrix-vector form : Ax = b combine in the augmented matrix • Basic Gaussian elimination procedure

  5. 3.1.1 Using Matrix Notation II • Pivot • At the kth stage of Gaussian elimination procedure, the appropriate multiple of the kth row is used to reduce each of the entries in the kth column below the kth row to zero • kth row : pivot row • kth column : pivot column • element akk : pivot element • ex : If at 3rd elimination procedure,

  6. Ex 3.2 Circuit Analysis I • The sum of the voltage drops around a closed loop is zero • V=IR

  7. Ex 3.2 Circuit Analysis II • Step 1 • The pivot is a11 = 30 • Multiply the first row by 20/30 and add it to the second row • Multiply the first row by 10/30 and add it to the third row

  8. Ex 3.2 Circuit Analysis III • Step 2 • The pivot is a22 = 125/3 • Multiply the second row by 2/5 and add it to the third row to get • By back substitution,

  9. G.E. in MATLAB Function % Gaussian Elimination function which can solve k systems of the form Ax=b1,....,Ax=bk at the same time function x = Gauss( A , b ) [n,k1] = size(A); [n1,k] = size(b); x = zeros(n,k); for i=1 : n-1 m = -A(i+1:n , i) / A(i,i); A(i+1:n , : ) = A(i+1:n , : ) + m*A(i,:); b(i+1:n , : ) = b(i+1:n , : ) + m*b(i,:); end x(n,:) = b(n,:) ./ A(n,n); for i=n-1 : -1 : 1 x(i,:) = ( b(i,:) - A(i , i+1:n) * x(i+1:n , : ) ) ./ A(i,i); end

  10. Using the MATLAB Function • Solving circuit analysis example % Actually using function : G.E. A = [ 30 -20 -10 -20 55 -10 -10 -10 50 ]; b = [ 0 0 200 ]; x = Gauss(A,b); display(x); x = 3.0000 2.0000 5.0000 >> RUN

  11. Ex 3.3 Forces on a Truss I node 3 node 1 • # Assuming the forces in each truss are pulling together • # Define forces to be positive if they • - act to the right • - act in an upward direction node 2

  12. Ex 3.3 Forces on a Truss II • Write in Ax=b form • if :

  13. Ex 3.3 Forces on a Truss III • Let’s use MATLAB function that we made for two different W3

  14. Ex 3.3 Forces on a Truss IV • Let’s use MATLAB function that we made for two different W3 % Using G.E. function to Truss sa = sin(pi/6); ca = cos(pi/6); sb = sin(pi/3); cb = cos(pi/3); A = [ 1 0 0 0 sa 0 0 1 0 1 ca 0 0 0 1 0 0 sb 0 0 0 -1 0 -cb 0 0 0 0 -sa -sb 0 0 0 0 -ca cb ]; b = [ 0 0 0 0 0 0 0 0 100 75 0 0 ]; x = Gauss(A,b); display(x); x = 25.0000 18.7500 0 0 75.0000 56.2500 43.3013 32.4760 -50.0000 -37.5000 -86.6025 -64.9519 >> RUN

  15. Discussion I • Measuring computational effort • Measure the number of multiplication and divisions

  16. Discussion II • Measuring computational effort • Measure the number of multiplication and divisions • The total number of multiplication and divisions

  17. Discussion III • An Ill-Conditioned matrix

  18. Chapter 3.2 GAUSSIAN ELIMINATION WITH ROW PIVOTING

  19. Introduction • WHY • Reducing the inaccuracies • More accurate than Gaussian Elimination • Avoiding (if possible) the failure • Divide by zero • HOW • Pivoting!!

  20. EX 3.4 Difficult System • Rounding to two significant digits Pivot Result

  21. 3.2.1 MATLAB Function for Gaussian Elimination with Row Pivoting I

  22. 3.2.1 MATLAB Function for Gaussian Elimination with Row Pivoting II function x = Gauss_pivot(A, b) [n, n1] = size(A); for i = 1 : (n - 1) [pivot, k] = max(abs(A(i : n, i))); if k > 1 temp1 = A(i, :); temp2 = b(i, :); A(i, :) = A(i + k - 1, :); b(i, :) = b(i + k - 1, :); A(i + k - 1, :) = temp1; b(i + k - 1, :) = temp2; end;

  23. 3.2.1 MATLAB Function for Gaussian Elimination with Row Pivoting III • Cont’ for h = (i + 1) : n m = A(h, i) / A(i, i); A(h, :) = A(h, :) - m * A(i, :); b(h, :) = b(h, :) - m * b(i, :); end; end; x(n, :) = b(n, :) ./ A(n, n); for i = (n - 1) : -1 : 1 x(i, :) = (b(i, :) - A(i, (i + 1) : n) * x((i + 1) : n, :)) ./ A(i, i); end;

  24. 100kg EX 3.6 Forces in a Simple Truss I • Triangular Truss

  25. EX 3.6 Forces in a Simple Truss II • Cont.

  26. Discussion • Big coefficients Scaling Result

  27. Chapter 3.3 GAUSSIAN ELIMINATION FOR TRIDIAGONAL SYSTEM

  28. Tridiagonal Systems I * 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 , 28

  29. Tridiagonal Systems II 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 29

  30. Tridiagonal Systems III * Example of Tridiagonal Matrix… 2x1 –x2 = 1, -x1 +2x2 –x3 = 0, -x2 +2x3 –x4 = 0, -x3 +2x4 = 1. 30

  31. Gaussian Eliminationfor Tridiagonal Systems * Example 3.7

  32. Solving a Tridiagonal Systems Using the Thomas Method I • B1 and An are zero. • This algorithm takes advantage of the zero elements that are • alreadypresent in the coefficient matrix and avoids unnecessary arithmetic • operations. • Thus, we need to store only the new vectors a and r. 32

  33. 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

  34. Solving a Tridiagonal Systems Using the Thomas Method III * Example 3.8.q

  35. Solving a Tridiagonal Systems Using the Thomas Method IV * Example 3.8.s

  36. MATLAB Functionfor Solving a Tridiagonal Systems Function x=Thomas(a,d,b,r) N=length(d) A(1)=a(1)/d(1) R(1)=r(1)/d(1) For i=2 : n-1 Denom=d(i)-b(i)*a(i-1); If(denom==0), error(‘zero in denominator’), end A(i)=a(i)/denom; R(i)=(r(i)-b(i)*r(n-1))/denom; End R(n)=(r(n)-b(n)*r(n-1))/(d(n)-b(n)*a(n-1)); X(n)=r(n); For i=n-1 : -1 :1 X(i)=r(i)-a(i)*x(i+1); end

  37. Discussion of Thomas method * 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.

  38. Using the Thomas Method for a System that Would Require Pivoting for Gaussian Elimination I * Example 3.9

  39. Using the Thomas Method for a System that Would Require Pivoting for Gaussian Elimination II • Example 3.9

  40. Using the Thomas Method for a System that Would Require Pivoting for Gaussian Elimination III * Example 3.9.s-3

More Related