Вы находитесь на странице: 1из 8

Gauss-Seidel Iterative Method

Introduction

One of the methods that can be used to solve a system of linear equations is the
Iterative Method. The equations are written explicitly in terms of the other
unknowns in the Iterative Method. To use such method, it is important to satisfy the
condition for convergence which is the absolute value of the diagonal element is
greater than the sum of the absolute values of the off-diagonal elements. The two
types of Iterative Method are Jacobi Iterative Method and Gauss-Seidel Iterative
Method. The Gauss-Seidel Iterative Method was used to solve the given system of
linear equations in this experiment. The Gauss-Seidel Iterative Method starts by
assuming all the initial values to be zero, unless stated otherwise. The given initial
values or the assumed values are then to be substituted in an equation (see any of
the equations below) and the answers that were obtained will be the new values of
the unknown. The iteration will stop when the error is 0.001 (Gilat, Subramaniam,
2014).

Objectives

 To solve a system of linear equations using Gauss-Seidel Iteration Method.


 To write a user-defined MATLAB function that solves a system of linear
equations with Gauss-Seidel Iterations Method.
Sample Problem

1. Three masses, m1 = 2 kg, m2 = 3 kg, and m3 = 1.5 kg, are attached to


springs, k1 = 30 N/m, k2 = 25 N/m, k3 = 20 N/m, and k4 = 15 N/m, as shown.
Initially the masses are positioned such that the springs are in their natural
length (not stretched or compressed); then the masses are slowly released
and move downward to an equilibrium position as shown. The equilibrium
equations of the three masses are:

( k 1+ k 2 +k 3 ) u1−k 3 u 2=m1 g
−k 3 u1 + ( k 3+ k 4 ) u 2−k 4 u3 =m2 g
−k 4 u2+ k 4 u3 =m 3 g

where u1, u2, and u3 are the relative displacement of each mass as shown.
Determine the displacement of the three masses. (g = 9.81 m/s2)

Answer:

Given:

m1 = 2 kg k1 = 30 N/m
( k 1+ k 2 +k 3 ) u1−k 3 u 2=m1 g
m2 = 3 kg k2 = 25 N/m

m3 = 1.5 kg k3 = 20 N/m −k 3 u1 + ( k 3+ k 4 ) u 2−k 4 u3 =m2 g


k4 = 15 N/m
−k 4 u2+ k 4 u3 =m3 g
g = 9.81 m/s2

Required: u1, u2, u3 (displacement of the three masses)

Solution:

The system of linear equations was solved using the Gauss-Seidel Iteration
Method. Only the first 7 iterations were shown in this solution but iterations
were actually done until the error is equal to 0.001.
( 30+25+20 ) u1 −20u 2=( 2 ) ( 9.81 ) 75 u1−20 u2=19.62
−20 u1 + ( 20+15 ) u2−15 u3 =( 3 )( 9.81 ) −20 u1 +35 u2−15 u3=29.43
−15 u2 +15 u3=( 1.5 ) ( 9.81 ) −15 u2 +15 u3=14.715

Initial values assumption: u1(1) = 0 ; u2(1) = 0 ; u3(1) = 0

19.62−( −20u 2 ) 29.43−(−20 u1−15 u3 ) 14.715−(−15 u2 )


u1 = u2 = u3 =
75 35 15

19.62−[−20 ( 0 ) ]
u(2)
1 = =0.2616
75

29.43−[−20 ( 0.2616 )−15 ( 0 ) ]


u(2)
2 = =0.9903
35

14.715−[ −15 ( 0.9903 ) ]


u(2)
3 = =1.9713
15

19.62−[−20 ( 0.9903 ) ]
u(3)
1 = =0.5257
75

29.43−[−20 ( 0.5257 )−15 ( 1.9713 ) ]


u(3)
2 = =1.9861
35

14.715−[ −15 ( 1.9861 ) ]


u(3)
3 = =2.9671
15

19.62− [− 20 ( 1.9861 ) ]
u(4)
1 = =0.7912
75

29.43−[−20 ( 0.7912 )−15 ( 2.9671 ) ]


u(4)
2 = =2.5646
35

14.715−[−15 ( 2.5646 ) ]
u(4)
3 = =3.5456
15
19.62−[−20 ( 2.5646 ) ]
u(5)
1 = =0.9455
75

29.43−[−20 ( 0.9455 ) −15 (3.5456 ) ]


u(5)
2 = =2.9007
35

14.715−[ −15 ( 2.9007 ) ]


u(5)
3 = =3.8817
15

19.62−[−20 ( 2.9007 ) ]
u(6)
1 = =1.0351
75

29.43− [−20 ( 1.0351 )−15 ( 3.8817 ) ]


u(6)
2 = =3.0959
35

14.715−[ −15 ( 3.0959 ) ]


u(6)
3 = =4.0769
15

19.62−[−20 ( 3.0959 ) ]
u(7)
1 = =1.0872
75

29.43−[ −20 ( 1.0872 )−15 ( 4.0769 ) ]


u(7)
2 = =3.2094
35

14.715−[−15 ( 3.2094 ) ]
u(7)
3 = =4.1904
15

i u1 u2 u3

1 0 0 0

2 0.2616 0.9903 1.9713

3 0.5257 1.9861 2.9671


4 0.7912 2.5646 3.5456

5 0.9455 2.9007 3.8817

6 1.0351 3.0959 4.0769

7 1.0872 3.2094 4.1904

u1 = 1.1588 m

u2 = 3.3654 m

u3 = 4.3464 m

Matlab Code

The codes used for solving the given system of linear equations are given below.
The codes that were used in this experiment were patterned from the codes found
from the internet (see the link in the references). Iteration was performed until the
error is found to be 0.001.
Results and Discussion

When the codes were run in Matlab, the command window displayed this:
Based on the values obtained, it can be observed that the answers become more
accurate as the number of iteration increases. It took 15 iterations to obtain the
values which have the error equal to 0.001.

Conclusion
The values obtained converge to the actual answer when iteration was done
numerous times. The Gauss-Seidel Iterative Method can only be used when the
condition for convergence was satisfied, otherwise erroneous values could be
obtained when the condition was not satisfied.

References

1. Gilat, A., Subramanian, V. 2014. Numerical methods for engineers and


scientists: an introduction applications using matlab.
2. Matlab code guide to create a user-defined function to solve the problem via
Gauss-Seidel Iterative Method:
https://ch.mathworks.com/matlabcentral/fileexchange/32051-gauss-seidel-
method?focused=5193371&tab=function

Вам также может понравиться