9/7/2015 1 gauss-siedel method chemical engineering majors authors: autar kaw transforming

Post on 26-Dec-2015

234 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

04/19/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

Gauss-Seidel Method

http://numericalmethods.eng.usf.edu

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.

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.

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

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodAlgorithm

Rewriting each equation

11

131321211 a

xaxaxacx nn

nn

nnnnnnn

nn

nnnnnnnnnn

nn

a

xaxaxacx

a

xaxaxaxacx

a

xaxaxacx

11,2211

1,1

,122,122,111,111

22

232312122

From Equation 1

From equation 2

From equation n-1

From equation n

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

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?

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodSolve for the unknowns

Assume an initial guess for [X]

n

-n

2

x

x

x

x

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.

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodCalculate the Absolute Relative Approximate Error

100

newi

oldi

newi

ia x

xx

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.

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

Example: Liquid-Liquid Extraction

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

12

10

57.8

139

15.225.6

124

3

2

1

x

x

x

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.

1

1

1

3

2

1

x

x

x

Example: Liquid-Liquid Extraction

Rewriting each equation 4

257.8 321

xxx

5.2

25.610 312

xxx

1

3912 213

xxx

12

10

57.8

139

15.225.6

124

3

2

1

x

x

x

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

1

1

1

3

2

1

x

x

x

Example: Liquid-Liquid Extraction

Finding the absolute relative approximate error for Iteration 1.

100

newi

oldi

newi

ia x

xx At the end of the Iteration 1

The maximum absolute relative approximate error

is 742.11%.

%..

.a 18728100

39251

1392511

%..

.a 11742100

118750

11187502

%..

.a 52212100

888750

18887503

88875.0

11875.0

3925.1

3

2

1

x

x

x

Example: Liquid-Liquid Extraction

Iteration 2

Using from Iteration 1

the values of xi are found.

88875.0

11875.0

3925.1

3

2

1

x

x

x

5245.41

)4078.1(33053.2912x

4078.15.2

)88875.0(3053.225.610x

3053.24

)88875.0(11875.0257.8x

3

2

1

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

4078.1

3053.2

x

x

x

3

2

1

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

27.2

14.1

x

x

x

3

2

1

Gauss-Seidel Method: Pitfall

What went wrong?

Even though done correctly, the answer is not converging to the correct answer

This 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

ijaa

i1

ii

n

ijj

ijii aa1

for all ‘i’ and

for at least one ‘i’

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

10

12

124

15.225.6

139

3

2

1

x

x

x

12

10

57.8

139

15.225.6

124

3

2

1

x

x

x

Example: Liquid-Liquid Extraction

Rewriting each equation

Iteration 1With an initial guess of

1

1

1

3

2

1

x

x

x

2589.21

3778.1288889.0457.8x

3778.15.2

188889.025.610x

88889.09

11312x

3

2

1

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

3778.1

8889.0

3

2

1

x

x

x

Example: Liquid-Liquid Extraction

Iteration 2

Using from Iteration 1

the values for xi are found

2589.2

3778.1

8889.0

3

2

1

x

x

x

0002.31

5387.1262309.0457.8x

5387.15.2

2589.2162309.025.610x

62309.09

2589.213778.1312x

3

2

1

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

5387.1

62309.0

x

x

x

3

2

1

Iteration x1 x2 x3

123456

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.

Iteration x1 x2 x3

199200

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

27.2

14.1

x

x

x

3

2

1

5148.8

2397.2

1337.1

3

2

1

x

x

x

The value of closely approaches the true value of

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

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

1

0

1

3

2

1

x

x

x

Rewriting the equations

3

13776 321

xxx

5

328 312

xxx

5

3121 213

xxx

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?

http://numericalmethods.eng.usf.edu

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

The coefficient matrix is not diagonally dominant

5312

351

1373

A

But this same set of equations will converge.

1373

351

5312

A

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

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?

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

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method

Questions?

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

THE END

http://numericalmethods.eng.usf.edu

top related