gauss-siedel method - math for college

Post on 03-Jun-2022

5 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1/9/2010 http://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

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

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

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.

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.

Example: Liquid-Liquid ExtractionA liquid-liquid extraction process conducted in the ElectrochemicalMaterials Laboratory involved the extraction of nickel from the aqueousphase into an organic phase. A typical experimental data from thelaboratory 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 ExtractionThe 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

Example: Liquid-Liquid Extraction

Rewriting each equation4257.8 32

1xxx −−

=

5.225.610 31

2xxx −−

=

13912 21

3xxx −−

=

=

121057.8

13915.225.6124

3

2

1

xxx

Example: Liquid-Liquid ExtractionIteration 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

Example: Liquid-Liquid ExtractionFinding 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

Example: Liquid-Liquid ExtractionIteration 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

−=−×−×−

=

−=−−×−

=

=−−×−

=

Example: Liquid-Liquid ExtractionFinding 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.1

3053.2

xxx

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

14.1

xxx

3

2

1

Gauss-Seidel Method: PitfallWhat 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

ijaai1

ii ∑≠=

⟩n

ijj

ijii aa1

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

Gauss-Siedel Method: PitfallDiagonally 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

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

=×−×−

=

=−×−

=

=−×−

=

Example: Liquid-Liquid ExtractionThe 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

Example: Liquid-Liquid ExtractionIteration 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

=×−×−

=

=×−×−

=

=×−×−

=

Example: Liquid-Liquid ExtractionThe 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

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 ExtractionRepeating 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 ExtractionRepeating more iterations, the following values are obtained

%1a∈ %

2a∈ %3a∈

−=

55.827.2

14.1

xxx

3

2

1

−=

5148.82397.2

1337.1

3

2

1

xxx

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 3Given the system of equations

761373 321 =++ xxx

2835 321 =++ xxx15312 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

Iteration a1 A2 a3

123456

21.000−196.15−1995.0−20149

2.0364 105

−2.0579 105

95.238110.71109.83109.90109.89109.89

0.8000014.421−116.021204.6−12140

1.2272 105

100.0094.453112.43109.63109.92109.89

50.680−462.304718.1−47636

4.8144 105

−4.8653 106

98.027110.96109.80109.90109.89109.89

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 3Conducting 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 [ ]

−=

5312351

1373A

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.

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