You are on page 1of 10

Numerical Analysis –MTH603 VU

Solution of Linear System of Equations and Matrix Inversion

Gauss–Jordon Elimination Method


This method is a variation of Gaussian elimination method. In this method, the elements above and below
the diagonal are simultaneously made zero. That is a given system is reduced to an equivalent diagonal
form using elementary transformations. Then the solution of the resulting diagonal system is obtained.
Sometimes, we normalize the pivot row with respect to the pivot element, before elimination. Partial
pivoting is also used whenever the pivot element becomes zero.

Example

Solve the system of equations using Gauss-Jordan elimination method:

x + 2y + z = 8 

2 x + 3 y + 4 z = 20 
4 x + 3 y + 2 z = 16 
Solution
In matrix notation, the given system can be written as
1 2 1   x   8 
 2 3 4   y  =  20 
    
 4 3 2   z   16 
1 2 1   x   8 
 0 −1 2   y  =  4  (-2) R1 +R2 and (-4) R1+R3
    
  
 0 −5 −2   z   −16  
Now, we eliminate y from the first and third rows using the second row. Thus, we get
1 0 5   x   16 
 0 −1 2   y  =  4 
    
 0 0 −12   z   −36 
Before, eliminating z from the first and second row, normalize the third row with respect to the pivot
element, we get
1 0 5   x   16 
 0 −1 2   y  =  4 
    
 0 0 1   z   3 
Using the third row of above Equation, and eliminating z from the first and second rows, we obtain
1 0 0   x   1 
 0 −1 0   y  =  −2 
    
 0 0 1   z   3 
The solution is
x =1, y =2, z =3.

Example

Solve the system of equation by using the Gauss Jordan elimination method
10 x + y + z = 12
2 x + 10 y + z = 13
x + y + 5z = 7
Solution

© Copyright Virtual University of Pakistan 1


Numerical Analysis –MTH603 VU

10 x + y + z = 12
2 x + 10 y + z = 13
x + y + 5z = 7
the given system
10 1 1   x  12 
 2 10 1   y  = 13
     
 1 1 5  z   7 
the arg umented matrix may be written as
10 1 1 12 
[ A / B ] =  2 10 1 | 13
 1 1 5 7 
 1 −8 −44 −51
∼  2 10 1 | 13  R1 − 9 R3
 1 1 5 7 
1 −8 −44 −51
∼  0 26 89 | 115  R2 − 2 R1 , R3 − R1
 0 9 49 58 
1 −8 −44 −51
∼  0 1 89 | 59  R2 − 3R3
 0 9 49 58 
1 0 420 421 
∼  0 1 58 | 59  R1 + 8R2 , R3 − 9 R2

 0 0 −473 −473
1 0 0 1
1
∼  0 1 0 | 1 R3 , R1 − 420 R3 , R2 − 58 R2
473
 0 0 1 1
thus the system reduces to reduced echlon form
so x = y = z = 1

Example
Solve the system of equations by Gauss Jordan method
10 x1 + x2 + x3 = 12
x1 + 10 x2 − x3 = 10
x1 − 2 x2 + 10 x3 = 9

Solution

© Copyright Virtual University of Pakistan 2


Numerical Analysis –MTH603 VU

10 x1 + x2 + x3 = 12
x1 + 10 x2 − x3 = 10
x1 − 2 x2 + 10 x3 = 9
the matrix form of the given system may be written as
10 1 1   x1  12 
 1 10 −1  x  = 10 
   2  
 1 −2 10   x3   9 
the arg umented mairix may be written as
10 1 1 12 
[ A / B ] =  1 10 −1 | 10
 1 −2 10 9 
1 −89 10 −78
~ 1 10 −1 | 88  R1 − 9 R2
1 −2 10 87 
1 −89 10 −78
~  0 9 −1 | 8  R2 − R1 , R3 − R1
 0 1 0 1 
1 −89 10 −78
R R
~  0 9 −1 | 8  2 , 3
99 87
 0 1 0 1 
1 −89 10 −78
~  0 1 −1 | 0  R2 − 8R3
 0 1 0 1 
1 0 −79 −78
~  0 1 −1 | 0  R1 − 89 R2 , R3 − R1
 0 0 1 1 
1 0 0 1
~  0 1 1 | 1 R1 + 79 R3 , R2 + R3
 0 0 0 1
so the system gives the values of all the three var iables
x1 = x2 = x3 = 1
Example
Solve the system of equations by using Gauss Jordan method.
x + 2 y + z − w = −2
2 x + 3 y − z + 2w = 7
x + y + 3 z − 2 w = −6
x+ y+z+w= 2
Solution

x + 2 y + z − w = −2
2 x + 3 y − z + 2w = 7
x + y + 3 z − 2 w = −6
x+ y+z+w= 2

© Copyright Virtual University of Pakistan 3


Numerical Analysis –MTH603 VU

the system may be written as


1 2 1 −1  x   −2 
2 3 −1 2   y   7 
 =
1 1 3 −2   z   −6 
     
1 1 1 1   w  2 

the arg umented matrix may be written as


1 2 1 −1 −2 
2 3 −1 2 7
[ A / B ] =  | 
1 1 3 −2 −6 
 
1 1 1 1 2
1 2 1 −1 −2 
0 1 3 −4 11 
∼ | R2 − 2 R1 , R3 − R1 , R4 − R1
 0 −1 2 −1 −4 
 
 0 −1 0 2 4
1 0 −5 7 20 
0 1 3 −4 −11 1
∼ | R1 − 2 R2 , ( R3 + R2 ), R4 + R2
0 0 1 −1 −3  5
 
0 0 3 −2 −7 
1 0 0 2 5
0 1 0 −1 −2 
∼ | R1 + 5 R3 , R2 − 3R3 , R4 − 3R3
0 0 1 −1 −3
 
0 0 0 1 2
1 0 0 0 1
0 1 0 0 0 
∼ | R1 − 2 R4 , R2 + R4 , R3 + R4
0 0 1 0 −1
 
0 0 0 1 2
the system maybe written as
1 0 0  x   1 
0
0 1 0   y   0 
0
 =
0 0 0   z   −1
1
     
0 0 1   w  2 
0
the values of all the ariables are
x = 1, y = 0, z = −1, w = 2

Crout’s ReductionMethod

Here the coefficient matrix [A] of the system of equations is decomposed into the product of two matrices
[L] and [U], where [L] is a lower-triangular matrix and [U] is an upper-triangular matrix with 1’s on its
main diagonal.

For the purpose of illustration, consider a general matrix in the form


[ L ][U ] = [ A]
© Copyright Virtual University of Pakistan 4
Numerical Analysis –MTH603 VU

 l11 0 0  1 u12 u13   a11 a12 a13 


l l22 0   0 1 u23  =  a21 a22 a23 
 21
l31 l32 l33   0 0 1   a31 a32 a33 

The sequence of steps for getting [L] and [U] are given below:
Step I: Multiplying all the rows of [L] by the first column of [U], we get

l11 = a11 , l21 = a21 , l31 = a31


Thus, we observe that the first column of [L] is same as the first column of [A].

Step II: Multiplying the first row of [L] by the second and third columns of [U], we obtain

l11u12 = a12 , l11u13 = a13


Or
a a
u12 = 12 , u13 = 13
l11 l11
Thus, the first row of [U] is obtained. We continue this process, getting alternately the column of [L] and a
row of [U].
Step III: Multiply the second and third rows of [L] by the second column of [U] to get
l21u12 + l22 = a22 , l31u12 + l32 = a32
This gives
l22 = a22 − l21u12 , l32 = a32 − l31u12
Step IV: Now, multiply the second row of [L] by the third column of [U] which yields
l21u13 + l22 u23 = a23
a23 − l21u13
u23 =
l22
Step V: Lastly, we multiply the third row of [L] by the third column of [U] and get
l31u13 + l32 u23 + l33 = a33
This gives
l33 = a33 − l33 u13 − l32 u23
Thus, the above five steps determine [L] and [U].
This algorithm can be generalized to any linear system of order n.
Consider a system of equations
a11 x1 + a12 x2 + a13 x3 = b1 

a21 x1 + a22 x2 + a23 x3 = b2 
a31 x1 + a32 x2 + a33 x3 = b3 
In matrix notation as [A](X) = (B). Let [A] = [L] [U], then we get,
[ L][U ]( X ) = ( B )
Substituting [U] (X) = (Z) in Eq. we obtain [L] (Z) = (B)
l11 z1 = b1 

l21 z1 + l22 z2 = b2 
l31 z1 + l32 z2 + l33 z3 = b3 
Having computed z1, z2 and z3, we can compute x1, x2, and x3 from equation [U] (X) = (Z) or from
1 u12 u13   x1   z1 
0 1 u   x  =  z 
 23   2   2
 0 0 1   x3   z3 
This method is also known as Cholesky reduction method. This technique is widely used in the numerical
solutions of partial differential equations.

© Copyright Virtual University of Pakistan 5


Numerical Analysis –MTH603 VU

This method is very popular from computer programming point of view, since the storages space reserved
for matrix [A] can be used to store the elements of [L] and [U] at the end of computation.
This method fails if any
aii = 0
Example
Solve the following system of equations by Crout’s reduction method
5 x1 − 2 x2 + x3 = 4
7 x1 + x2 − 5 x3 = 8
3x1 + 7 x2 + 4 x3 = 10

Solution
Let the coefficient matrix [A] be written as [L] [U]. Thus,
 l11 0 0  1 u12 u13   5 −2 1 
l    
 21 l22 0   0 1 u23  =  7 1 −5
l31 l32 l33   0 0 1   3 7 4 

Step I: Multiply all the rows of [L] by the first column of [U], we get

l11 = 5, l21 = 7, l31 = 3


Step II: Multiply the first row of [L] by the second and third columns of [U], we have
l11 u12 = −2, l11u13 = 1
2 1
u12 = − , u13 =
5 5

STEP III: Multiply the 2nd and 3rd rows of [L] by the 2nd column of [U], we get
14 19 
l21u12 + l22 = 1 or l22 = 1 + = 
5 5

6 41 
l31u12 + l32 = 7 or l32 = 7 + =
5 5 
STEP IV: Multiply the 2nd row of [L] by the 3rd column of [U]
l21u13 + l22 u23 = −5
19 7
u23 = −5 −
5 5
32
u23 = −
19
STEP V:Finally, multiply the 3rd row of [L] with the 3rd column of [U], we obtain

l31u13 + l32 u23 + l33 = 4


327
l33 =
19
Thus, the given system of equations takes the form [L][U][X] = (B).
  1 − 2 1  x   4 
0  5    
1
5 0 5
     
 7 19 32
0   0 1 −   x2  =  8 
 5  19     
  
1    
 3 41 327   0 0  x  10 
 5 19     3   
That is,

© Copyright Virtual University of Pakistan 6


Numerical Analysis –MTH603 VU

   z1   4 
5 0 0    
    
 7 19 0   z2  =  8 
 5    
 41 327    
3    
 5 19   z3  10 
Let [U](X) = (Z), then
[ L]( Z ) = (4 8 10)T
Or
   z1   4 
5 0 0    
    
 7 19 0   z2  =  8 
 5    
 41 327    
3    
 5 19   z3  10 
Which gives utilizing these values of z, the Eq becomes
By back substitution method, we obtain
46 284 366
x3 = , x2 = , x1 =
327 327 327
This is the required solution.

Example

2 x − 3 y + 10 z = 3
Solve the following system − x + 4 y + 2 x = 20
5 x + 2 y + z = −12

Solution

2 x − 3 y + 10 z = 3
− x + 4 y + 2 x = 20
5 x + 2 y + z = −12
the given system is AX = B
 2 −3 10   x  3 
A =  −1 4 2  X =  y  Β =  20 
 5 2 1   z   −12 
let LU = A
1 0 0 u11 u12 u13 
L = l21 1 0  U =  0 u22 u23 
l31 l32 1   0 0 u33 
 u11 u12 u13   2 −3 10 
l u  =  −1 4 2 
 21 11 l21u12 + u22 l21u13 + u23   
l31u11 l31u12 + l32 u22 l31u13 + l32 u23 + u33   5 2 1 

© Copyright Virtual University of Pakistan 7


Numerical Analysis –MTH603 VU

here
u11 = 2 , u12 = −3 u13 = 10
−1
l21u11 = −1 ⇒ l21 =
2
5
l31u11 = 5 ⇒ l31 =
2

−1 5
l21u12 + u22 = 4 ⇒ u22 = 4 − l21u12 = 4 − ( )(−3) =
2 2
−1
l21u13 + u23 = 2 ⇒ u23 = 2 − l21u13 = 2 − ( )10 = 7
2
1 19
l31u12 + l32 u22 = 5 ⇒ l32 = [5 − l31u12 ] =
u22 5
253
l31u13 + l32 u23 + u33 ⇒ u33 = 1 − l31u13 − l32 u23 =
5
   
1 0 0  2 −3 10 
   
 −1 5
L= 1 0 
U= 0 7 
2   2 
 5 19   
 1  0 0 −253 
2 5   5 
 y1 
let UX = Y where y =  y2  , then LY = B,
 y3 
 
1 0 0
   y1   3 
−1  y  =  20 
i.e  1 0  2  
2 
 5 19   y3   −12 
 1
2 5 
and
 
1 0 0
   x   y1 
 −1 1 0   y  =  y 
2     2
 5 19   z   y3 
 1
2 5 
now eqn (1) implies
y1 = 3
−1 43
y1 + y2 = 20 ⇒ y2 =
2 2
5 19 −506
y1 + y2 + y3 = −12 ⇒ y3 =
2 5 5

© Copyright Virtual University of Pakistan 8


Numerical Analysis –MTH603 VU

5 43 253 −506
2 x − 3 y + 10 z = 3 , y + 7 z = , − z=
2 2 5 3
by back substitution x = −4, y = 3and z = 2

Example

Solve the following system


x + 3y + 4z = 4
x + 4 y + 3 z = −2
x + 3y + 4z = 1

Solution

x + 3 y + 4z = 4
x + 4 y + 3 z = −2
x + 3 y + 4z = 1
the given system is AX = B
1 3 8   x 4
A = 1 4 3  X =  y  Β =  −2 
1 3 4   z   1 
let LU = A
 1 0 0 u11 u12 u13 

L = l21 1 0   U =  0 u22 u23 
l31 l32 1   0 0 u33 
 u11 u12 u13  1 3 8 
l u l u + u l u + u  = 1 4 3 
 21 11 21 12 22 21 13 23   
l31u11 l31u12 + l32 u22 l31u13 + l32 u23 + u33  1 3 4 
here
u11 = 1 , u12 = 3 u13 = 8
l21u11 = −1 ⇒ l21 = 1
l31u11 = 1 ⇒ l31 = 1

© Copyright Virtual University of Pakistan 9


Numerical Analysis –MTH603 VU

−1 5
l21u12 + u22 = 4 ⇒ u22 = 4 − l21u12 = 4 − ( )(−3) =
2 2
l21u13 + u23 = 2 ⇒ u23 = 4 − l21u13 = 4 − (1)3 = 1
1
l31u12 + l32 u22 = 3 ⇒ l32 = [3 − l31u12 ] = 0
u22
l31u13 + l32 u23 + u33 ⇒ u33 = 4 − l31u13 − l32 u23 = −4
1 0 0  1 3 8 
L = 1 1 0  U =  0 1 −5
1 0 1   0 0 −4 
 y1 
let UX = Y where y =  y2  , then LY = B,
 y3 
1 0 0   y1   4 
i.e  0 1 0   y2  =  −2 
1 0 1   y3   1 
and
 
1 0 0
   x   y1 
 −1 1 0   y  =  y 
2     2
 5 19   z   y3 
 1
2 5 
now eqn (1) implies
y1 = 4
y2 = −2
y1 + y3 = 1 ⇒ y3 = 1 − y1 = −3
we also have
x + 3 y + 8z = 4
y − 5 z = −2
−4 z = −3
by back substitutiton
3
z=
4
3 7
y = −2 + 5 z = −2 + 5( ) =
4 4
7 3 29
x = 4 − 3 y − 8 z = 4 − 3( ) − 8( ) =
4 4 4

© Copyright Virtual University of Pakistan 10

You might also like