Sie sind auf Seite 1von 17

Numerical Methods Application

Engg Software Lab


2016

Simple Gaussian Elimination


A method to solve simultaneous linear equations
of the form [A][X]=[C]

Two steps
1. Forward Elimination

2. Back Substitution

Forward Elimination
The goal of forward elimination is to transform the coefficient matrix into
an upper triangular matrix

25 5 1 x1 106.8
64 8 1 x = 177.2

144 12 1 x3 279.2
5
1 x1 106.8
25
0 4.8 1.56 x = 96.21

0
0.7 x3 0.735
0

Forward Elimination
A set of n equations and n unknowns

a11 x1 + a12 x2 + a13 x3 + ... + a1n xn = b1

a21 x1 + a22 x2 + a23 x3 + ... + a2 n xn = b2


.
.
.

.
.
.

an1 x1 + an 2 x2 + an 3 x3 + ... + ann xn = bn


(n-1) steps of forward elimination

Forward Elimination
Step 1

For Equation 2, divide Equation 1 by a11and multiply by a21


.

a21
a ( a11 x1 + a12 x2 + a13 x3 + ... + a1n xn = b1 )
11

a21
a21
a21
a21 x1 +
a12 x2 + ... +
a1n xn =
b1
a11
a11
a11

Forward Elimination
Subtract the result from Equation 2.
a21 x1 + a22 x2 + a23 x3 + ... + a2 n xn = b2
a21
a21
a21
a21 x1 +
a12 x2 + ... +
a1n xn =
b1

a11
a11
a11
_________________________________________________

a21
a21
a21
a22
b1
a1n xn = b2
a12 x2 + ... + a2 n
a11
a11
a11

or

a x + ... + a x = b
'
22 2

'
2n n

'
2

Forward Elimination
Repeat this procedure for the remaining
equations to reduce the set of equations as
a11 x1 + a12 x2 + a13 x3 + ... + a1n xn = b1
'
'
a22
x2 + a23
x3 + ... + a2' n xn = b2'

'
'
a32
x2 + a33
x3 + ... + a3' n xn = b3'
.
.
.

.
.
.

.
.
.

'
an' 2 x2 + an' 3 x3 + ... + ann
xn = bn'

End of Step 1

Forward Elimination
Step 2
Repeat the same procedure for the 3rd term of
Equation 3.
a11 x1 + a12 x2 + a13 x3 + ... + a1n xn = b1
'
'
a22
x2 + a23
x3 + ... + a2' n xn = b2'

"
x3 + ... + a3" n xn = b3"
a33
.
.
.

.
.
.

"
an" 3 x3 + ... + ann
xn = bn"

End of Step 2

Forward Elimination
At the end of (n-1) Forward Elimination steps, the system of equations will look like

a11 x1 + a12 x 2 + a13 x3 + ... + a1n x n = b1


'
'
a22
x2 + a23
x3 + ... + a2' n xn = b2'

a x + ... + a x = b
"
33 3

"
3n n

.
.
.

( n 1)

"
3

.
.
.

(n 1 )

ann xn = bn
End of Step (n-1)

Matrix Form at End of Forward Elimination


a11
0

a12
'
a22
0

a13 a1n x1 b1
'
'
'

a23 a2 n x2
b2


"
"
"
a33 a3n x3 = b3




(n-1 )
(n 1 )

0 0 ann xn bn

Back Substitution
Solve each equation starting from the last equation

5
1 x1 106.8
25
0 4.8 1.56 x = 96.21

0
0.7 x3 0.735
0
Example of a system of 3 equations

Back Substitution Starting Eqns


a11 x1 + a12 x 2 + a13 x3 + ... + a1n x n = b1
'
'
a22
x2 + a23
x3 + ... + a2' n xn = b2'

"
a33
x3 + ... + an" xn = b3"
.
.
.

( n 1)

.
.
.

(n 1 )

ann xn = bn

Back Substitution
Start with the last equation because it has only one unknown

( n 1)
n
( n 1)
nn

b
xn =
a

Back Substitution
( n 1)
n
( n 1)
nn

b
xn =
a
xi =

bi(i 1) ai(,ii+11) xi +1 ai(,ii+12) xi + 2 ... ai(,in1) xn


(i 1)

aii
(i 1)

xi =

bi

aij(i 1) x j
n

j =i +1
(i 1)
ii

for i = n 1,...,1

for i = n 1,...,1

Assignment
1) Write a program to take in values of A Matrix
and B Matrix for the system [A]{X}=[B]. These
can be taken from a file.
2) Convert the A Matrix in the [A,B] pair to a
Lower Diagonal Form
3) Eliminate and substitute for each element on
X[i] in the {X}.
4) Print X and verify if 1) is true.

References
Transforming Numerical Methods Education
for the STEM Undergraduate
http://numericalmethods.eng.usf.edu
Numerical Recipes in C: The art of scientific
computation
http://www.nr.com

End of session.

Das könnte Ihnen auch gefallen