35
06/11/22 http:// numericalmethods.eng.usf.edu 1 Gauss-Siedel Method Chemical Engineering Majors Authors: Autar Kaw http://numericalmethods.eng.u sf.edu Transforming Numerical Methods Education for STEM Undergraduates

Gauss-Siedel Method

  • Upload
    kasia

  • View
    83

  • Download
    3

Embed Size (px)

DESCRIPTION

Gauss-Siedel Method. Chemical Engineering Majors Authors: Autar Kaw http://numericalmethods.eng.usf.edu Transforming Numerical Methods Education for STEM Undergraduates. Gauss-Seidel Method http://numericalmethods.eng.usf.edu. Gauss-Seidel Method. An iterative method. Basic Procedure : - PowerPoint PPT Presentation

Citation preview

Page 1: Gauss-Siedel Method

04/22/23http://

numericalmethods.eng.usf.edu 1

Gauss-Siedel Method

Chemical Engineering Majors

Authors: Autar Kaw

http://numericalmethods.eng.usf.eduTransforming Numerical Methods Education for STEM

Undergraduates

Page 2: Gauss-Siedel Method

Gauss-Seidel Method

http://numericalmethods.eng.usf.edu

Page 3: Gauss-Siedel Method

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodAn iterative method.

Basic Procedure:

-Algebraically solve each linear equation for xi

-Assume an initial guess solution array

-Solve for each xi and repeat

-Use absolute relative approximate error after each iteration to check if error is within a pre-specified tolerance.

Page 4: Gauss-Siedel Method

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodWhy?

The Gauss-Seidel Method allows the user to control round-off error.

Elimination methods such as Gaussian Elimination and LU Decomposition are prone to prone to round-off error.

Also: If the physics of the problem are understood, a close initial guess can be made, decreasing the number of iterations needed.

Page 5: Gauss-Siedel Method

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodAlgorithm

A set of n equations and n unknowns:

11313212111 ... bxaxaxaxa nn

2323222121 ... bxaxaxaxa n2n

nnnnnnn bxaxaxaxa ...332211

. . . . . .

If: the diagonal elements are non-zero

Rewrite each equation solving for the corresponding unknown

ex:

First equation, solve for x1

Second equation, solve for x2

Page 6: Gauss-Siedel Method

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodAlgorithm

Rewriting each equation

11

131321211 a

xaxaxacx nn

nn

nnnnnnn

nn

nnnnnnnnnn

nn

axaxaxac

x

axaxaxaxac

x

axaxaxacx

11,2211

1,1

,122,122,111,111

22

232312122

From Equation 1

From equation 2

From equation n-1

From equation n

Page 7: Gauss-Siedel Method

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodAlgorithm

General Form of each equation

11

11

11

1 a

xac

x

n

jj

jj

22

21

22

2 a

xac

x

j

n

jj

j

1,1

11

,11

1

nn

n

njj

jjnn

n a

xac

x

nn

n

njj

jnjn

n a

xac

x

1

Page 8: Gauss-Siedel Method

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodAlgorithm

General Form for any row ‘i’

.,,2,1,1

nia

xac

xii

n

ijj

jiji

i

How or where can this equation be used?

Page 9: Gauss-Siedel Method

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodSolve for the unknowns

Assume an initial guess for [X]

n

-n

2

xx

xx

1

1

Use rewritten equations to solve for each value of xi.

Important: Remember to use the most recent value of xi. Which means to apply values calculated to the calculations remaining in the current iteration.

Page 10: Gauss-Siedel Method

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodCalculate the Absolute Relative Approximate Error

100

newi

oldi

newi

ia xxx

So when has the answer been found?

The iterations are stopped when the absolute relative approximate error is less than a prespecified tolerance for all unknowns.

Page 11: Gauss-Siedel Method

Example: Liquid-Liquid Extraction

A liquid-liquid extraction process conducted in the Electrochemical Materials Laboratory involved the extraction of nickel from the aqueous phase into an organic phase. A typical experimental data from the laboratory is given below:

Ni aqueous phase, a (g/l) 2 2.5 3

Ni organic phase, g (g/l) 8.57 10 12

Assuming g is the amount of Ni in organic phase and a is the amount of Ni in the aqueous phase, the quadratic interpolant that estimates g is given by

5.32,322

1 axaxaxg

Page 12: Gauss-Siedel Method

Example: Liquid-Liquid Extraction

The solution for the unknowns x1, x2, and x3 is given by

121057.8

13915.225.6124

3

2

1

xxx

Find the values of x1, x2,and x3 using the Gauss Seidel method. Estimate the amount of nickel in organic phase

when 2.3 g/l is in the aqueous phase using quadratic interpolation.

Initial Guess: Conduct two iterations.

111

3

2

1

xxx

Page 13: Gauss-Siedel Method

Example: Liquid-Liquid Extraction

Rewriting each equation 4

257.8 321

xxx

5.225.610 31

2xxx

13912 21

3xxx

121057.8

13915.225.6124

3

2

1

xxx

Page 14: Gauss-Siedel Method

Example: Liquid-Liquid Extraction

Iteration 1Applying the initial guess and solving for each xi

Initial Guess

When solving for x2, how many of the initial guess values were used?

3925.14

11257.81

x

11875.05.2

13925.125.6102

x

88875.01

11875.033925.19123

x

111

3

2

1

xxx

Page 15: Gauss-Siedel Method

Example: Liquid-Liquid Extraction

Finding the absolute relative approximate error for Iteration 1.

100

newi

oldi

newi

ia xxx At the end of the Iteration

1

The maximum absolute relative approximate error

is 742.11%.

%..

.a 18728100

39251139251

1

%..

.a 11742100

1187501118750

2

%..

.a 52212100

8887501888750

3

88875.011875.03925.1

3

2

1

xxx

Page 16: Gauss-Siedel Method

Example: Liquid-Liquid Extraction

Iteration 2

Using from Iteration 1

the values of xi are found.

88875.011875.03925.1

3

2

1

xxx

5245.41

)4078.1(33053.2912x

4078.15.2

)88875.0(3053.225.610x

3053.24

)88875.0(11875.0257.8x

3

2

1

Page 17: Gauss-Siedel Method

Example: Liquid-Liquid Extraction

Finding the absolute relative approximate error for Iteration 2.

At the end of the Iteration 1

The maximum absolute relative approximate error

is 108.44%

%357.80

1005245.4

)88875.0(5245.4%44.108

1004078.1

11875.040778.1%596.39

1003053.2

3925.13053.2

3

2

1

a

a

a

5245.44078.13053.2

xxx

3

2

1

Page 18: Gauss-Siedel Method

Iteration x1 x2 x3

123456

1.39252.30533.97757.058412.75223.291

28.186739.596042.04143.64944.64945.249

0.11875−1.4078−4.1340−9.0877−18.175−34.930

742.1053108.435365.94654.51049.99947.967

−0.88875−4.5245−11.396−24.262−48.243−92.827

212.5280.35760.29653.03249.70848.030

Example: Liquid-Liquid Extraction

Repeating more iterations, the following values are obtained%1a %

2a %3a

Notice – The relative errors are not decreasing at any significant rate

Also, the solution is not converging to the true solution of

55.827.214.1

xxx

3

2

1

Page 19: Gauss-Siedel Method

Gauss-Seidel Method: Pitfall

What went wrong?Even though done correctly, the answer is not converging to

the correct answerThis example illustrates a pitfall of the Gauss-Seidel method:

not all systems of equations will converge.

Is there a fix?One class of system of equations always converges: One with a

diagonally dominant coefficient matrix.

Diagonally dominant: [A] in [A] [X] = [C] is diagonally dominant if:

n

jj

ijaai1

ii

n

ijj

ijii aa1

for all ‘i’ and for at least one ‘i’

Page 20: Gauss-Siedel Method

Gauss-Siedel Method: Pitfall

Diagonally dominant: The coefficient on the diagonal must be at least equal to the sum of the other coefficients in that row and at least one row with a diagonal coefficient greater than the sum of the other coefficients in that row.

Original (Non-Diagonally dominant) Rewritten (Diagonally dominant)

57.81012

12415.225.6139

3

2

1

xxx

121057.8

13915.225.6124

3

2

1

xxx

Page 21: Gauss-Siedel Method

Example: Liquid-Liquid Extraction

Rewriting each equation

Iteration 1With an initial guess of

111

3

2

1

xxx

2589.21

3778.1288889.0457.8x

3778.15.2

188889.025.610x

88889.09

11312x

3

2

1

Page 22: Gauss-Siedel Method

Example: Liquid-Liquid Extraction

The absolute relative approximate error for Iteration 1 is

The maximum absolute relative error after the first iteration is 55.730%

%730.551002589.2

12589.2

%419.271003778.1

13778.1

%5.1210088889.0

188889.0

3

2

1

a

a

a At the end of Iteration 1

2589.23778.18889.0

3

2

1

xxx

Page 23: Gauss-Siedel Method

Example: Liquid-Liquid Extraction

Iteration 2

Using from Iteration 1

the values for xi are found

2589.23778.18889.0

3

2

1

xxx

0002.31

5387.1262309.0457.8x

5387.15.2

2589.2162309.025.610x

62309.09

2589.213778.1312x

3

2

1

Page 24: Gauss-Siedel Method

Example: Liquid-Liquid Extraction

The absolute relative approximate error for Iteration 2

The maximum absolute relative error after the first iteration is 42.659%

%709.241000002.3

2589.20002.3

%460.101005387.1

3778.15387.1

%659.4210062309.0

88889.062309.0

3

2

1

a

a

a At the end of Iteration 2

0002.35387.162309.0

xxx

3

2

1

Page 25: Gauss-Siedel Method

Iteration x1 x2 x3123456

0.888890.623090.487070.421780.394940.38890

12.542.65927.92615.4796.79601.5521

1.37781.53871.58221.56271.50961.4393

27.41910.4562.75061.25373.51314.8828

2.25893.00023.45723.75763.97104.1357

55.73024.70913.2207.99285.37473.9826

Example: Liquid-Liquid Extraction

Repeating more iterations, the following values are obtained%1a %

2a %3a

After six iterations, the absolute relative approximate error seems to be decreasing.

Conducting more iterations allows the absolute relative approximate error to decrease to an

acceptable level.

Page 26: Gauss-Siedel Method

Iteration x1 x2 x3199200

1.13351.1337

0.0144120.014056

−2.2389−2.2397

0.0348710.034005

8.51398.5148

0.0106660.010403

Example: Liquid-Liquid Extraction

Repeating more iterations, the following values are obtained%1a %

2a %3a

55.827.214.1

xxx

3

2

1

5148.82397.21337.1

3

2

1

xxx

The value of closely approaches the true value of

Page 27: Gauss-Siedel Method

Example: Liquid-Liquid Extraction

514882397213371 2

322

1

.a.a.

xaxaxag

g/l36089

514883223972321337132 2

.......g

Where g is grams of nickel in the organic phase and a is the grams/liter in the aqueous phase.

The polynomial that passes through the three data points is then

When 2.3g/l is in the aqueous phase, using quadratic interpolation, the estimated the amount of nickel in the organic

phase

Page 28: Gauss-Siedel Method

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 3

Given the system of equations

761373 321 xxx

2835 321 xxx

15312 321 xxx

With an initial guess of

101

3

2

1

xxx

Rewriting the equations

313776 32

1xxx

5328 31

2xxx

53121 21

3

xxx

Page 29: Gauss-Siedel Method

Iteration a1 A2 a3

123456

21.000−196.15−1995.0−201492.0364×105−2.0579×105

95.238110.71109.83109.90109.89109.89

0.8000014.421−116.021204.6−121401.2272×105

100.0094.453112.43109.63109.92109.89

50.680−462.304718.1−476364.8144×105−4.8653×106

98.027110.96109.80109.90109.89109.89

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 3

Conducting six iterations, the following values are obtained

%1a %

2a %3a

The values are not converging.

Does this mean that the Gauss-Seidel method cannot be used?

Page 30: Gauss-Siedel Method

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodThe Gauss-Seidel Method can still be used

The coefficient matrix is not diagonally dominant

53123511373

A

But this same set of equations will converge.

13733515312

A

If a system of linear equations is not diagonally dominant, check to see if rearranging the equations can form a diagonally dominant matrix.

Page 31: Gauss-Siedel Method

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodNot every system of equations can be rearranged to have a diagonally dominant coefficient matrix.

Observe the set of equations

3321 xxx

9432 321 xxx

97 321 xxx

Which equation(s) prevents this set of equation from having a diagonally dominant coefficient matrix?

Page 32: Gauss-Siedel Method

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodSummary

-Advantages of the Gauss-Seidel Method

-Algorithm for the Gauss-Seidel Method

-Pitfalls of the Gauss-Seidel Method

Page 33: Gauss-Siedel Method

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method

Questions?

Page 34: Gauss-Siedel Method

Additional ResourcesFor all resources on this topic such as digital audiovisual lectures, primers, textbook chapters, multiple-choice tests, worksheets in MATLAB, MATHEMATICA, MathCad and MAPLE, blogs, related physical problems, please visit

http://numericalmethods.eng.usf.edu/topics/gauss_seidel.html

Page 35: Gauss-Siedel Method

THE END

http://numericalmethods.eng.usf.edu