You are on page 1of 7

Numerical Analysis Ch IV: Linear Systems of Equations

CHAPTER IV
NUMERICAL SOLUTION OF
LINEAR SIMULTANEOUS EQUATIONS

4.1 Introduction

In almost every scientific discipline there are problems that give rise to a system of linear
algebraic equations. An n×n linear system is a system of n simultaneous linear equations
in n unknowns. The notation for such a system will be: -

This system of equations is commonly written in the following matrix form

or A×X=B

where Xi’s are the unknowns, aij’s are the coefficients and bi’s are constants.

In this chapter we will discuss and develop numerical methods for solving such system of
equations. A solution of this system of equations is a set of values (X 1, X2, …,Xn) which
simultaneously satisfies each equation of the system.

There are a number of numerical methods for solving the system of linear algebraic
equations. The following will be covered in this course:
1- Gauss elimination method.
2- Gauss-Jordan method.

4.2 Gauss Elimination Method


This method is a direct method, which based on row-by-row elimination of terms. The
method will be explained by the following example: -
Example 4.1

Using Gauss elimination method, solve the following system of equations:

35
Numerical Analysis Ch IV: Linear Systems of Equations
2 X1 – 3 X 2 + X 3 = 7 (1)
X1 – X2 – 2 X3 = –2 (2)
3 X1 + X 2 – X 3 = 0 (3)

Solution:
- We eliminate X1 from equation (2) by multiplying equation (1) by T21 and add it to
equation (2) where:
T21 = - a21/a11 ( a11 ≠ 0 )
T21 = -(1/2)

Equation (2) become


0.5 X2 – 2.5 X3 = – 5.5 (2')

- We eliminate X1 from equation (3) by multiplying equation (1) by T31 and add it to
equation (3) where:
T31 = - a31/a11 ( a11 ≠ 0 )
T31 = -(3/2)

Equation (3) become


5.5 X2 – 2.5 X3 = – 10.5 (3')

The equations now become:


2 X1 – 3 X 2 + X3 = 7 (1)
0.5 X2 – 2.5 X3 = – 5.5 (2')
5.5X2 – 2.5 X3 = – 10.5 (3')

- We eliminate X2 from equation (3') by multiplying equation (2’) by T32 and add it to
equation (3') where:
T32 = - a32/a22 ( a22 ≠ 0 )
T32 = - (5.5/0.5)
Equation (3') become
25 X3 = 50 (3'')
- The system of equations becomes:
2 X 1 – 3 X2 + X 3 = 7 (1)
0.5 X2 – 2.5 X3 = – 5.5 (2')
25 X3 = 50 (3'')
- Starting from the bottom to find the values of X1, X2, and X3 ; this process is known as
back substitution.
X3 = 2
X2 = ( -5.5 + 2.5(2))/0.5 = -1

36
Numerical Analysis Ch IV: Linear Systems of Equations
X1 = ( 7 – 2 + 3(-1))/2 = 1
The solution is [ 2 , -1 , 1 ]

Problem: 4.1

Using Gauss elimination method, solve the following system of equations:

2 X1 + X 2 + X 3 = 7 (1)
4 X1 + 4 X2 + 3 X3 = 21 (2)
6 X1 + 7 X2 + 4 X3 = 32 (3)

4.3 Gauss-Jordon Method


In this method we eliminate Xi from all equations, except the equation (i ). This method
saves the back substituting process, which we explained in Gauss elimination method
above. The following example will explain Gauss-Jordon method in details.

Example 4.2

Using Gauss-Jordon elimination method, solve the following system of equations:

2 X1 + X 2 – X 3 = 5 (1)
X1 + 2 X2 + 4 X3 = 10 (2)
5 X1 + 4 X2 – X3 = 14 (3)

Solution:
1. Using equation (1) to eliminate X1 from equation (2) & (3)
- multiply equation (1) by T21 and add it to equation (2) where:
T21 = - a21/a11 ( a11 ≠ 0 )
T21 = -(1/2) = -0.5

Equation (2) become


1.5 X2 + 4.5 X3 = 7.5 (2’)

- multiply equation (1) by T31 and add it to equation (3) where:


T31 = - a31/a11 ( a11 ≠ 0 )
T31 = -(5/2) = -2.5

37
Numerical Analysis Ch IV: Linear Systems of Equations
Equation (3) become
1.5 X2 + 1.5 X3 = 1.5 (3’)

- The new system of equations becomes:


2 X1 + X 2 – X3 = 5 (1)
1.5 X2 + 4.5 X3 = 7.5 (2’)
1.5 X2 + 1.5 X3 = 1.5 (3’)

2. Using equation (2’) to eliminate X2 from equation (1) & (3’)

- multiply equation (2’) by T12 and add it to equation (1) where:


T12 = - a12/a22 ( a22 ≠ 0 )
T12 = -(1/1.5)

Equation (1) become


2 X1 - 4 X 3 = 0 (1’)

- multiply equation (2’) by T32 and add it to equation (3’) where:


T32 = - a32/a22 ( a22 ≠ 0 )
T32 = -(1.5/1.5) = -1

Equation (3’) become


-3 X3 = -6 (3’’)

- The new system of equations becomes:


2 X1 - 4 X3 = 0 (1”)
1.5 X2 + 4.5 X3 = 7.5 (2’)
-3 X3 = -6 (3’’)
3. Using equation (3’’) to eliminate X3 from equation (1’’) & (2’’)

- multiply equation (3’’) by T13 and add it to equation (1’’) where:


T13 = - a13/a33 ( a33 ≠ 0 )
T13 = -(-4/-3) = -(4/3)

Equation (1’’) become


2 X1 = 8 (1’’’)

- multiply equation (2’’) by T23 and add it to equation (1’) where:


T23 = - a23/a33 ( a33 ≠ 0 )
T23 = -(4.5/-3) = 1.5

38
Numerical Analysis Ch IV: Linear Systems of Equations

Equation (2’’) become


1.5 X2 = - 1.5 (2’’)

- The system of equations becomes:


2 X1 =8 (1”’)
1.5 X2 = -1.5 (2’’’)
-3 X3 = -6 (3’’’)

From these equations we can find the solution direct.

From equation (1’’’) X1 = 8/2 =4


From equation (2’’’) X1 = 1.5/-1.5 = -1
From equation (3’’’) X1 = -6/-3 =2

The solution is [ 4 , -1 , 2 ]

Problem: 4.2

Using Gauss – Jordon elimination method, solve the following system of equations:

X1 + 2 X2 - 2X3 + X4 = 4 (1)
2X1 + 5 X2 - 2X3 +3X4 = 7 (2)
- 2X1 - 2 X2 + 5X3 +3X4 = -1 (3)
X1 + 3 X2 + 3X3 +2X4 = 0 (4)

4.4 Pivoting

In the solution of system of equations using conventional Gauss elimination or Gauss-


Jordon elimination methods, we sidestepped the problem of what to do if the diagonal
component of the coefficient matrix were started with zero or become zero during the solution
process. In this case we should search for the largest (absolute) coefficient in the rows not
processed, and interchange it with the zero row. This interchange technique is called “Pivoting”.
4.5 Gauss - Jordon Elimination Algorithm

1- Define the matrices required for the calculations as


Dimension a(10,10),x(10),T(10,10)
2- Read N, the number of unknowns as

39
Numerical Analysis Ch IV: Linear Systems of Equations
Read*,n
3- read the coefficients aij and constants a i,n+1 as
read*,((a(i,j),j=1,n+1),i=1,n)
4- Calculate the multiplication terms and do the elimination as
Do 20 k =1,n
Do 20 i =1, n
If(i.EQ.k) goto 20
T(i,k)= -(a(i,k) / a(k,k))

Do 25 j=1,n+1
a(i,j) = a(i,j) + T(i,k)* a(k,j)
25 Continue
20 Continue
5- Calculate and print the unknowns as
Do 30 i=1, n
x(i) = a(i,n+1) / a(i,i)
print*,x(i)
30 continue
6- Stop
End

Programming Assignment (4.1)

Using Gauss-Jordon Elimination method, Write a FORTRAN program to


solve the following system of equations:

4X1 + X2 + 3 X3 = 16 (1)
X1 + 3X2 + 2 X3 = 10 (2)
X1 + 2X2 + 5 X3 = 12 (3)
4.6 Other topics related to the subject:

1- Gauss-Seidel iterative method.


2- Jacobi Method

4.7 Real life exercise:


In the electric circuit shown in the figure, find the value of all the currents passing in the
circuit.

Hint:

40
Numerical Analysis Ch IV: Linear Systems of Equations
 Use Kirchhoff’s Law to write the 6 equation into 6 unknowns that are the currents
passing in the circuit.
 If the sign of the calculated current is –ve, it means that the direction of the current
is opposite to what was proposes.

3 R = 10 ohms 2 R = 5 ohms 1

I32 I12

R = 5 ohms I43 R=10 ohms I52 V = 200 V

I54 I65

4 5 6
R = 15 ohms R = 20 ohms

Solution:

I12 = + 6.1538
I52 = - 4.6154
I32 = - 1.5385
I65 = - 6.1538
I54 = - 1.5385
I43 = - 1.5385

41

You might also like