seidal

35
7/23/2011 http://numericalmethods.eng.usf.edu 1 Gauss-Siedel Method Major: All Engineering Majors  Authors: Autar Kaw http://numericalmethods.eng.usf.edu Transforming Numerical Methods Education for STEM Undergraduates

Upload: dinuniroxx

Post on 07-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 1/35

7/23/2011 http://numericalmethods.eng.usf.edu 1

Gauss-Siedel Method

Major: All Engineering Majors

 Authors: Autar Kaw

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

Undergraduates

Page 2: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 2/35

Gauss-Seidel Method

http://numericalmethods.eng.usf.edu

Page 3: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 3/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method An iterative method.

Basic Pr ocedur e:

- Algebr aically solve each linear equation f or xi 

- Assume an initial guess solution arr ay

-Solve f or each xi and r epeat

-Use absolute r elative appr oximate err or af ter each iter ationto check if err or is within a pr e-specif ied toler ance.

Page 4: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 4/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodWhy?

The Gauss-Seidel Method allows the user to contr ol r ound-off err or .

Elimination methods such as Gaussian Elimination and LU 

Decomposition ar e pr one to pr one to r ound-off err or .

 Also: If the physics of the pr oblem ar e under stood, a close initialguess can be made, decr easing the number of iter ations needed. 

Page 5: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 5/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method Algor ithm

 A set of n equations and n unknowns:

11313212111 ... b xa xa xa xa nn !

2323222121 ... b xa xa xa xa n2n !

nnnnnnn b xa xa xa xa ! ...332211

. .

. .

. .

If : the diagonal elements ar e 

non-zer o

Rewr ite each equation solving

f or the corr esponding unknown

ex:

Fir st equation, solve f or x1

Second equation, solve f or x2

Page 6: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 6/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method Algor ithm

Rewr iting each equation

11

13132121

1

a

 xa xa xac x nn

!

--

nn

nnnnnn

n

nn

nnnnnnnnnn

nn

a

 xa xa xac x

a xa xa xa xac x

a

 xa xa xac x

11,2211

1,1

,122,122,111,111

22

232312122

!

!

!

--

--

///

--

Fr om Equation 1

Fr om equation 2

Fr om equation n-1

Fr om equation n

Page 7: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 7/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method Algor ithm

Gener al For m of each equation

11

11

11

1a

 xac

 x

n

 j j

 j j

§{!

!

22

21

22

2a

 xac

 x

 j

n

 j j

 j

§{!

!

1,1

11

,11

1

{!

§

!

nn

n

n j j

 j jnn

na

 xac

 x

nn

n

n j j  jnjn

na

 xac

 x§{!

!

1

Page 8: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 8/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method Algor ithm

Gener al For m f or any r ow µi¶

.,,2,1,

1

nia

 xac

 xii

n

i j j

 jiji

i -!

!

§{!

How or wher e can this equation be used?

Page 9: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 9/35

Page 10: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 10/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodCalculate the Absolute Relative Appr oximate Err or 

100v

!� new

i

old 

i

new

i

ia

 x

 x x

So when has the answer been f ound?

The iter ations ar e stopped when the absolute r elative 

appr oximate err or is less than a pr especif ied toler ance f or all

unknowns.

Page 11: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 11/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 1The upwar d velocity of a r ocket 

is given at thr ee diff er ent times

Time, Velocity

5 106.8

8 177.2

12 279.2

The velocity data is appr oximated by a polynomial as:

12.t5,32

2

1 ee! at at at v

s t  m/s v

Table 1 Velocity vs. Time data.

Page 12: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 12/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 1

¼

¼¼

½

»

¬

¬¬«

!

¼

¼¼

½

»

¬

¬¬«

¼

¼¼

½

»

¬

¬¬«

3

2

1

323

2

2

2

1

2

1

1

1

1

v

v

v

a

a

a

 

t t 

t t 

t t 

3

2

1Using a Matr ix template of the f or m

The system of equations becomes

¼¼¼

½

»

¬¬¬«

!

¼¼¼

½

»

¬¬¬«

¼¼¼

½

»

¬¬¬«

2.279

2.177

8.106

112144

1864

1525

3

2

1

a

a

a

 

Initial Guess: Assume an initial guess of 

¼¼¼

½

»

¬¬¬«

!

¼¼¼

½

»

¬¬¬«

5

2

1

3

2

1

a

a

a

Page 13: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 13/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 1

Rewr iting each equation

¼¼¼

½

»

¬¬¬«

!

¼¼¼

½

»

¬¬¬«

¼¼¼

½

»

¬¬¬«

2.279

2.177

8.106

112144

1864

1525

3

2

1

a

a

a

 

25

58.106 32

1

aaa

!

8

642.177 31

2

aaa

!

1

121442.279 21

3

aaa

!

Page 14: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 14/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 1 Applying the initial guess and solving f or ai

¼¼

¼

½

»

¬¬

¬«

!

¼¼

¼

½

»

¬¬

¬«

52

1

3

2

1

aa

a 6720.325

)5()2(58.106a1 !

!

8510.7

8

56720.3642.177a 2 !

!

36.155

1

8510.7126720.31442.279a

3!

!

Initial Guess

When solving f or a2, how many of the initial guess values wer e used?

Page 15: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 15/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 1

%76.721006720.3

0000.16720.31a !

!� x

%47.1251008510.7

0000.28510.72a !

!� x

%22.10310036.155

0000.536.1553a !

!� x

Finding the absolute r elative appr oximate err or 

100v

!�new

i

old 

i

new

i

ia

 x

 x x  At the end of the f ir st iter ation

The maximum absolute 

r elative appr oximate err or is 125.47%

¼¼¼

½

»

¬¬¬«

!

¼¼¼

½

»

¬¬¬«

36.155

8510.7

6720.3

3

2

1

a

a

a

Page 16: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 16/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 1Iter ation #2

Using

¼¼

¼

½

»

¬¬

¬«

!

¼¼

¼

½

»

¬¬

¬«

36.1558510.7

6720.3

3

2

1

aa

a

056.1225

36.1558510.758.1061 !

!a

882.54

8

36.155056.12642.1772 !

!a

34.798

1

882.5412056.121442.2793 !

!a

fr om iter ation #1

the values of ai ar e f ound:

Page 17: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 17/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 1Finding the absolute r elative appr oximate err or 

%543.69100056.12

6720.3056.121a !

!� x

%695.85100x

882.54

8510.7882.542

!

!�a

%540.8010034.798

36.15534.7983a !

!� x

 At the end of the second iter ation

¼¼¼

½

»

¬¬¬«

!

¼¼¼

½

»

¬¬¬«

54.798

882.54

056.12

3

2

1

a

a

a

The maximum absolute 

r elative appr oximate err or is 

85.695%

Page 18: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 18/35

Iteration a 1 a 2 a 3

12

3

4

5

6

3.672012.056

47.182

193.33

800.53

3322.6

72.76769.543

74.447

75.595

75.850

75.906

í7.8510í54.882

í255.51

í1093.4

í4577.2

í19049

125.4785.695

78.521

76.632

76.112

75.972

í155.36í798.34

í3448.9

í14440

í60072

í249580

103.2280.540

76.852

76.116

75.963

75.931

http://numerica lmethods.eng.usf.edu

Ga uss-Seidel Method: Exa mple 1

¼¼¼

½

»

¬¬¬«

!

¼¼¼

½

»

¬¬¬«

0857.1

690.19

29048.0

a

a

a

3

2

1

Repeating mor e iter ations, the f ollowing values ar e obtained

%1a

� %2a

� %3a�

Notice ± The r elative err or s ar e not decr easing at any signif icant r ate

 Also, the solution is not converging to the tr ue solution of 

Page 19: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 19/35

Page 20: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 20/35

Page 21: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 21/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 2Given the system of equations

15312 321   x-  x x !

2835 321 

 x x x  !

761373 321 !   x x x

¼¼¼

½

»

¬¬¬«

!

¼¼¼

½

»

¬¬¬«

1

01

3

2

1

 x

 x x

With an initial guess of 

The coeff icient matr ix is:

? A

¼¼

¼

½

»

¬¬

¬«

!

1373

351

5312

 A

Will the solution converge using the 

Gauss-Siedel method?

Page 22: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 22/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 2

? A

¼¼¼

½

»

¬¬¬

«

!

1373

351

5312

 A

Checking if the coeff icient matr ix is diagonally dominant

43155 232122 !!u!! aaa

10731313 323133 !!u!! aaa

8531212 131211 !!u!! aaa

The inequalities ar e all tr ue and at least one r ow is strictly gr eater than:

Ther ef or e: The solution should converge using the Gauss-Siedel Method

Page 23: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 23/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 2

¼¼¼

½

»

¬¬¬«

!

¼¼¼

½

»

¬¬¬«

¼¼¼

½

»

¬¬¬«

76

28

1

1373

351

5312

3

2

1

a

a

a

 

Rewr iting each equation

12

531 32

1

 x x x

!

5328 31

2 x x x

!

13

7376 21

3

 x x x

!

With an initial guess of 

¼¼¼

½

»

¬¬¬«

!

¼¼¼

½

»

¬¬¬«

1

0

1

3

2

1

 x

 x

 x

50000.0

12

150311 !

! x

9000.45

135.0282 !! x

0923.3

13

9000.4750000.03763 !

! x

Page 24: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 24/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 2The absolute r elative appr oximate err or 

%00.10010050000.0

0000.150000.01

!v

!�a

%00.1001009000.4

09000.42a !v

!�

%662.671000923.3

0000.10923.33a !v

!�

The maximum absolute r elative err or af ter the f ir st iter ation is 100%

Page 25: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 25/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 2

¼

¼¼

½

»

¬

¬¬«

!

¼

¼¼

½

»

¬

¬¬«

8118.3

7153.3

14679.0

3

2

1

 x

 x

 x

 Af ter Iter ation #1

14679.0

12

0923.359000.4311

!

! x

7153.3

5

0923.3314679.0282 !

! x

8118.3

13

900.4714679.03763

!

! x

Substituting the x values into the 

equations Af ter Iter ation #2

¼

¼¼

½

»

¬

¬¬«

!

¼

¼¼

½

»

¬

¬¬«

0923.3

9000.4

5000.0

3

2

1

 x

 x

 x

Page 26: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 26/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 2Iter ation #2 absolute r elative appr oximate err or 

%61.24010014679.0

50000.014679.01a !v

!�

%889.311007153.3

9000.47153.32a !v

!�

%874.18100

8118.3

0923.38118.33a !v

!�

The maximum absolute r elative err or af ter the f ir st iter ation is 240.61%

This is much larger than the maximum absolute r elative err or obtained in

iter ation #1. Is this a pr oblem?

Page 27: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 27/35

Iteration a1 a2 a3

1

2

3

4

5

6

0.50000

0.14679

0.74275

0.94675

0.99177

0.99919

100.00

240.61

80.236

21.546

4.5391

0.74307

4.9000

3.7153

3.1644

3.0281

3.0034

3.0001

100.00

31.889

17.408

4.4996

0.82499

0.10856

3.0923

3.8118

3.9708

3.9971

4.0001

4.0001

67.662

18.876

4.0042

0.65772

0.074383

0.00101

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 2Repeating mor e iter ations, the f ollowing values ar e obtained

%1a�

%2a� %

3a�

¼¼¼

½

»

¬¬¬«

!

¼¼¼

½

»

¬¬¬«

4

3

1

3

2

1

 x

 x

 x

¼¼¼

½

»

¬¬¬«

!

¼¼¼

½

»

¬¬¬«

0001.4

0001.3

99919.0

3

2

1

 x

 x

 x

The solution obtained  is close to the exact solution of  .

Page 28: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 28/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 3Given the system of equations

761373 321 ! x x x

2835 321 ! x x x

15312 321 ! x x x 

With an initial guess of 

¼¼¼

½

»

¬¬¬«

!

¼¼¼

½

»

¬¬¬«

1

0

1

3

2

1

 x

 x

 x

Rewr iting the equations

3

13776 321

 x x x

!

5

328 312

 x x x

!

5

3121 21

3

!

 x x x

Page 29: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 29/35

Iteration a1  A2 a3

1

2

3

4

5

6

21.000

í196.15

í1995.0

í20149

2.0364×105

í2.0579×105

95.238

110.71

109.83

109.90

109.89

109.89

0.80000

14.421

í116.02

1204.6

í12140

1.2272×105

100.00

94.453

112.43

109.63

109.92

109.89

50.680

í462.30

4718.1

í47636

4.8144×105

í4.8653×106

98.027

110.96

109.80

109.90

109.89

109.89

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method: Example 3Conducting six iter ations, the f ollowing values ar e obtained

%1a

� %2a

� %3a

The values ar e not converging.

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

Page 30: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 30/35

http://numericalmethods.eng.usf.edu

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

The coeff icient matr ix is not 

diagonally dominant? A

¼¼

¼

½

»

¬¬

¬«

!

5312351

1373

 A

But this is the same set of 

equations used in example #2, 

which did converge.? A

¼¼¼

½

»

¬¬¬«

!

1373

351

5312

 A

If a system of linear equations is not diagonally dominant, check to see if 

r earr anging the equations can f or m a diagonally dominant matr ix.

Page 31: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 31/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodNot every system of equations can be r earr anged to have a 

diagonally dominant coeff icient matr ix.

Observe the set of equations

3321 ! x x x

9432 321 ! x x x

97321

! x x x

Which equation(s) pr events this set of equation fr om having a 

diagonally dominant coeff icient matr ix?

Page 32: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 32/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel MethodSummary

- Advantages of the Gauss-Seidel Method- Algor ithm f or the Gauss-Seidel Method

-Pitf alls of the Gauss-Seidel Method

Page 33: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 33/35

http://numericalmethods.eng.usf.edu

Gauss-Seidel Method

Questions?

Page 34: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 34/35

 Additional ResourcesFor all resources on this topic such as digital audiovisuallectures, primers, textbook chapters, multiple-choicetests, worksheets in MATLAB, MATHEMATICA, MathCadand MAPLE, blogs, related physical problems, pleasevisit 

http://numericalmethods.eng.usf.edu/topics/gauss_seid

el.html

Page 35: seidal

8/6/2019 seidal

http://slidepdf.com/reader/full/seidal 35/35

THE END

http://numericalmethods.eng.usf.edu