CE317 : Computer Methods in Civil Engineering

Total Page:16

File Type:pdf, Size:1020Kb

CE317 : Computer Methods in Civil Engineering

CE317 : Computer Methods in Civil Engineering Lecture 11 *: Linear Algebraic Equations-Iterative Methods-Cont.

1- Gauss-Seidel Method

Example1: Use the Gauss-Seidel method to obtain the solution of the following equations:

6x1 -2 x2 + x3 = 11 (1)

x1 +2 x2 -5x3 = -1 (2)

-2x1 +7 x2 +2x3 = 5 (3)

Solution

Step 1:

Re-write the equations such that each equation has the unknown with largest coefficient on the left hand side:

2x  x 11 x  2 3 from eq. (1) 1 6 2x  2x  5 x  1 3 from eq. (3) 2 7

x  2x 1 x  1 2 from eq. (2) 3 5

Step 2:

0 0 0 1 1 1 Assume the initial guesses (x1) = (x2) = (x3) = 0, then calculate (x1) , (x2) and (x3) :

2(x )0  (x )0 11 2(0)  (0) 11 (x )1  2 3  1.833 1 6 6 2(x )0  2(x )0  5 2(0)  2(0)  5 (x )1  1 3  0.714 2 7 7 (x )0  2(x )0 1 (0)  2(0) 1 (x )1  1 2  0.200 3 5 5

* Important: This handout is only a summery of the lecture. The student should take detailed notes during the class and refer to the textbook for more examples and discussion. Step 3:

Use the values obtained in the first iteration, to calculate the values for the 2nd iteration:

2(x )1  (x )1 11 2(0.714)  (0.200) 11 (x )2  2 3   2.038 1 6 6 2(x )1  2(x )1  5 2(1.833)  2(0.200)  5 (x )2  1 3  1.181 2 7 7 (x )1  2(x )1 1 (1.833)  2(0.714) 1 (x )2  1 2  0.852 3 5 5 and so on for the next iterations so that the next values are calculated using the current values:

2(x )i  (x )i 11 (x )i1  2 3 1 6 2(x )i  2(x )i  5 (x )i1  1 3 2 7 (x )i  2(x )i 1 (x )i1  1 2 3 5

i+1 I i+1 and continue the above iterative procedure until [(xk) - (xk) ]/ (xk) < Єs for k=1,2 and 3. The results for 9 iterations are:

Unknown Iteration x1 x2 x3

1 1.833 0.714 0.200 2 2.038 1.181 0.852 3 2.085 1.053 1.080 4 2.004 1.001 1.038 ...... 9 2.000 1.000 1.000 Conditions for the Convergence of Gauss-Seidel Method:

A sufficient condition for convergence is given by n a  a ii  ij j1 ii As an example: for two equations, n=3 and the following three conditions are sufficient to get convergence: a11  a12  a13 (1) a22  a21  a23 (2) a33  a31  a32 (3) and so on for n=2, 4,…

Example: Identify the systems of equations that cannot be solved using the Gauss-Seidel method: a) x1 -2 x2 + 4x3 = .. (1) 4x1 +2 x2 - x3 = .. (2) -5x1 +7 x2 + x3 = .. (3) b) x1 -2 x2 + 3x3 = .. (1) 3x1 +2 x2 = .. (2) -5x1 +7 x2 +2x3= .. (3) c) x1 -2 x2 = .. (1) 5x1 +3 x2 - x3 = .. (2) -x1 + x2 +3x3 = .. (3)

Solution: 2- Jacobi Iteration Method

Example: Use the Jacobi iteration method to obtain the solution of the following equations:

6x1 -2 x2 + x3 = 11 (1) x1 +2 x2 -5x3 = -1 (2) -2x1 +7 x2 +2x3 = 5 (3)

Solution

Step 1: Re-write the equations such that each equation has the unknown with largest coefficient on the left hand side:

2x  x 11 x  2 3 from eq. (1) 1 6 2x  2x  5 x  1 3 from eq. (3) 2 7

x  2x 1 x  1 2 from eq. (2) 3 5 Step 2:

0 0 1 Assume the initial guesses (x2) = (x3) = 0, then calculate (x1) :

2(x )0  (x )0 11 2(0)  (0) 11 (x )1  2 3  1.833 1 6 6

1 0 1 Use the updated value (x1) = 1.833 and (x3) = 0 to calculate (x2) 2(x )1  2(x )0  5 2(1.833)  2(0)  5 (x )1  1 3  1.238 2 7 7

1 1 1 Similarly, use (x1) = 1.833 and (x2) = 1.238 to calculate (x3)

(x )1  2(x )1 1 (1.833)  2(1.238) 1 (x )1  1 2  1.062 3 5 5 Step 3: Repeat the same procedure for the 2nd iteration

2(x )1  (x )1 11 2(1.238)  (1.062) 11 (x )2  2 3   2.069 1 6 6 2(x )2  2(x )1  5 2(2.069)  2(1.062)  5 (x )2  1 3  1.002 2 7 7 (x )2  2(x )2 1 (2.069)  2(1.002) 1 (x )2  1 2  1.015 3 5 5 and so on for the next iterations so that the next values are calculated using the current values: 2(x )i  (x )i 11 (x )i1  2 3 1 6 2(x )i1  2(x )i  5 (x )i1  1 3 2 7 (x )i1  2(x )i1 1 (x )i1  1 2 3 5

i+1 I i+1 and continue the above iterative procedure until [(xk) - (xk) ]/ (xk) < Єs for k=1,2 and 3. The procedure yields the exact solution after 5 iterations only:

Unknown Iteration x1 x2 x3

1 1.833 1.238 1.062

2 2.069 1.002 1.015

3 1.998 0.995 0.998

4 1.999 1.000 1.000

5 2.000 1.000 1.000

Recommended publications