CH 3 - Linear System of Equations
CH 3 - Linear System of Equations
Numerical Analysis I
Prepared By
Biruk Endeshaw Mekonnen
March 8, 2021
Chapter 3
Linear System of Equations
3.1 INTRODUCTION
In this chapter we present the solution of n linear simultaneous algebraic equations in n un-
knowns. Linear systems of equations are associated with many problems in engineering and
science, as well as with applications of mathematics to the social sciences and quantitative
study of business and economic problems.
A system of algebraic equations has the form
where the coefficients aij and the constants bj are known and xi represents the unknowns.
In matrix notation, the equations are written as
Ax = b (3.1)
a11 a12 · · · a1n x1 b1
a21 a22 · · · a2n x2 b2
where A= .. .. . , x = .. , and b = ..
. . · · · .. . .
an1 an2 · · · ann xn bn
The matrix [A | b], obtained by appending the column b to the matrix A is called the aug-
mented matrix. That is
a11 a12 · · · a1n b1
a21 a22 · · · a2n b2
[A|b] =
.. .. . ..
. . · · · .. .
an1 an2 · · · ann bn
We define the following.
(i) The system of equations (3.1) is consistent (has at least one solution), if
rank(A) = rank[A|b] = r
If r = n, then the system has unique solution.
If r < n, then the system has (n − r) parameter family of infinite number of solutions.
The methods of solution of the linear algebraic system of equations (3.1) may be classified as
direct and iterative methods.
(a) Direct methods produce the exact solution after a finite number of steps (disregarding
the round-off errors). In these methods, we can determine the total number of opera-
tions (additions, subtractions, divisions and multiplications). This number is called the
operational count of the method.
(b) Iterative methods are based on the idea of successive approximations. We start with an
initial approximation to the solution vector x = x0 , and obtain a sequence of approxi-
mate vectors x0 , x1 , . . . , xk , . . ., which in the limit as k → ∞, converge to the exact solu-
tion vector x. Now, we derive some direct methods.
These row operations change the form of A, but do not change the row-rank of A. The matrix
B obtained after the elementary row operations is said to be row equivalent with A. In the
context of the solution of the system of algebraic equations, the solution of the new system is
identical with the solution of the original system.
The method is based on the idea of reducing the given system of equations Ax = b, to an
upper triangular system of equations Ux = z, using elementary row operations. We know that
these two systems are equivalent. That is, the solutions of both the systems are identical. This
reduced system Ux = z, is then solved by the back substitution method to obtain the solution
vector x.
We illustrate the method using the 3 × 3 system
Gauss elimination
[A | b] −−−−−−−−−−−→ [U | z]
We assume a11 6= 0. This element a11 in the 1 × 1 position is called the first pivot. We use this
pivot to reduce all the elements below this pivot in the first column as zeros. Multiply the first
row in (3.3) by a21 /a11 and a31 /a11 respectively and subtract from the second and third rows.
That is, we are performing the elementary row operations R2 −(a21 /a11 )R1 and R3 −(a31 /a11 )R1
respectively. We obtain the new augmented matrix as
a11 a12 a13 b1
(1) (1) (1)
0 a22 a23 b2 (3.4)
(1) (1) (1)
0 a32 a33 b3
(1) a21 (1) a21 (1) a21
where a22 = a22 − a11 , a23 = a23 − a13 , b2 = b2 − b1 ,
a11 a11 a11
(1) a31 (1) a31 (1) a31
a32 = a32 − a12 , a33 = a33 − a13 , b3 = b3 − b1 .
a11 a11 a11
(2)
The element a33 6= 0 is called the third pivot. This system is in the required upper triangular
form [U|z]. The solution vector x is now obtained by back substitution.
(2)
b3
From the third row, we get x3 = (2) .
a33
1 (1) (1)
From the second row, we get x2 = (1) (b2 − a23 x3 ).
a22
1
From the first row, we get x1 = (b − a12 x2 − a13 x3 ).
a11 1
In general, using a pivot, all the elements below that pivot in that column are made zeros.
Alternately, at each stage of elimination, we may also make the pivot as 1, by dividing
that particular row by the pivot.
−1 1 6 5
We perform the following elementary row transformations and do the eliminations.
1 3 −5 2 1 3 −5 2
R2 − 3R1 → 0 2 6 −2 0 2 6 −2
R3 + R1 → 0 4 1 7 R3 − 2R2 → 0 0 −11 11
1 1
z = −1, y = (−2 − 6z) = (−2 + 6) = 2, x = 2 − 3y + 5z = 2 − 6 − 5 = −9.
2 2
Example 3.2. Use the method of Gaussian elimination to solve
x1 + x2 + x3 + x4 = 3
2x1 − x2 + 3x3 = 3
2x2 + 3x4 = 1
−x1 + 2x3 + x4 = 0
Solution: The augmented matrix is
1 1 1 1 3
2 −1 3 0 3
0 2 0 3 1
−1 0 2 1 0
From the augmented matrix, we apply elementary transformations:
1 1 1 1 3 1 1 1 1 3
R2 = R2 − 2R1 0 −3 1 −2 −3 R3 = R3 + 32 R2 0 −3
1 −2 −3
m 1 m
R4 = R4 + R1
0 2 0 3 1 R4 = R4 + 3 R2 0 0 2/3 5/3 −1
0 1 3 2 3 0 0 10/3 4/3 2
1 1 1 1 3
0 −3 1 −2 −3
R4 = R4 − 5R3
−−−−−−−−−−→ 0 0 2/3 5/3 −1
0 0 0 −7 7
x2 = − 31 (−3 − x3 − 2x4 ) = 2, x1 = 3 − x2 − x3 − x4 = 1.
Pivoting:
The Gaussian elimination method fails if any one of the pivot elements becomes zero. In such
a situation, we rewritten the equations in a different order to avoid zero pivots. changing the
order of equations is called Pivoting.
For example, we may have the system
2y + 5z = 7
7x + y − 2z = 6
2x + 3y + 8z = 13
in which the first pivot is zero.
Step 1: The numerically largest coefficient of x1 is selected from all the equations are pivot
and the corresponding equation becomes the first equation.
Step 2: The numerically largest coefficient of x2 is selected from all the remaining equations
as pivot and the corresponding equation becomes the second equation. This procedure is
continued until the upper triangular system is obtained.
In this method, we select at each stage the numerically largest coefficient of the complete
matrix of coefficients. This procedure leads to an interchange of the equations as well as
interchange of the position of variables.
Remark 3.1. When the system of algebraic equations is large, how do we conclude that it is
consistent or not, using the Gauss elimination method?
A way of determining the consistency is from the form of the reduced system (3.5). We know
that if the system is inconsistent then rank(A) 6= rank[A|b]. By checking the elements of the
last rows, conclusion can be drawn about the consistency or inconsistency.
(2) (2)
Suppose that in (3.5), a33 6= 0 and b3 6= 0. Then, rank(A) = rank[A|b] = 3. The system
is consistent and has a unique solution.
Suppose that we obtain the reduced system as
a11 a12 a13 b1
(1) (1) (1)
0 a22 a23 b2
(2)
0 0 0 b3
Then, rank(A) = 2, rank[A|b] = 3 and rank(A) 6= rank[A|b]. Therefore, the system is
inconsistent and has no solution.
Suppose that we obtain the reduced system
as
a11 a12 a13 b1
(1) (1) (1)
0 a22 a23 b2
0 0 0 0
Then, rank(A) = rank[A|b] = 2 < 3. Therefore, the system has 3 − 2 = 1 parameter
family of infinite number of solutions.
2 1 3 16
We perform the following elementary row transformations and do the eliminations.
3 3 4 24 1 1 4/3 8
1
R1 ↔ R2 1 1 1 7 R1 = R1 1 1 1 7
−−−−−−→ 3
2 1 3 16 −−−−−−→ 2 1 3 16
1 1 4/3 8 1 1 4/3 8
R2 = R2 − R1
m 0 0 −1/3 −1 R2 ↔ R3 0 −1 1/3 0
R3 = R3 − 2R1 −−−−−−→
0 −1 1/3 0 0 0 −1/3 −1
4 0 2 1 8
0 3 3/2 −5/4 −7
R4 − R3 :
0 0 −1/2 1/12 17/3
0 0 0 −13/6 −52/3
9 22 79 45
We perform the following elementary row transformations and do the eliminations.
1 10 −1 3 1 01 −1 3
R2 = R2 − 2R1
m 0 −17 22 1 R3 − 4R2 0 −17 22 1
R3 = R3 − 9R1 −
− −−−−→
0 −68 88 18 0 0 0 14
Now, rank[A] = 2, and rank[A|b] = 3. Therefore, the system is inconsistent and has no
solution.
3.2.2 Gauss-Jordan Method
The method is based on the idea of reducing the given system of equations Ax = b, to a di-
agonal system of equations Ix = d, where I is the identity matrix, using elementary row op-
erations. We know that the solutions of both the systems are identical. This reduced system
gives the solution vector x. This reduction is equivalent to finding the solution as x = A−1 b.
Gauss-Jordan method
[A | b] −−−−−−−−−−−−−→ [I | X]
In this case, after the eliminations are completed, we obtain the augmented matrix for
a 3 × 3 system as
1 0 0 d1
0 1 0 d2 (3.6)
0 0 1 d3
and the solution is xi = di , i = 1, 2, 3.
Elimination procedure The first step is same as in Gauss elimination method, that is, we
make the elements below the first pivot as zeros, using the elementary row transformations.
From the second step onwards, we make the elements below and above the pivots as zeros
using the elementary row transformations. Lastly, we divide each row by its pivot so that the
final augmented matrix is of the form (3.6). Partial pivoting can also be used in the solution.
We may also make the pivots as 1 before performing the elimination.
Example 3.6. Solve the following system of equations
x+y+z =1
x + 3y − z = 6
3x + 5y + 3z = 4
using the Gauss-Jordan method (i) without partial pivoting, (ii) with partial pivoting.
3 5 3 4
(i) We perform the following elementary row transformations and do the eliminations.
1 1 1 1 1 1 1 1
R2 = R2 − 4R1
4 3 −1 6 m 0 −1 −5 2
R3 = R3 − 3R1
3 5 3 4 0 2 0 1
1 0 −4 3 4 1 0 0 1
R1 = R1 + R2 R1 = R1 − 10 R3
m 0 −1 −5 2 m 0 −1 0 −1/2
5
R3 = R3 + 2R2 R2 = R2 − 10 R3
0 0 −10 5 0 0 −10 5
1
Now, making the pivots as 1, ((R2 = −R2 ), (R3 = − 10 R3 )) we get
1 0 0 1
0 1 0 1/2
0 0 1 −1/2
(ii) We perform the following elementary row transformations and do the eliminations.
1 1 1 1 4 3 −1 6 1 3/4 −1/4 3/2
1
4 3 −1 6 R1 ↔ R2 1 1 1 1 R1 = R1 1 1 1 1
−−−−−−→ 4
3 5 3 4 3 5 3 4 −−−−−−→ 3 5 3 4
1 3/4 −1/4 3/2 1 3/4 −1/4 3/2
R2 = R2 − R1
m 0 1/4 5/4 −1/2 R2 ↔ R3 0 11/4 15/4 −1/2
R3 = R3 − 3R1 −−−−−−→
0 11/4 15/4 −1/2 0 1/4 5/4 −1/2
1 3/4 −1/4 3/2 3 1 0 −14/11 18/11
4 R1 = R1 − 4 R2
R2 = R2 0 1 15/11 −2/11 m 0 1 15/11 −2/11
1
11
−−−−−−−→ 0 1/4 5/4 R 3 = R3 − 4
R2
−1/2 0 0 10/11 −5/11
1 0 −14/11 18/11 14 1 0 0 1
11 R1 = R1 + R
11 3
R3 = R3 0 1 15/11 −2/11 m 0 1 0 1/2
15
−−−−−10
−−→ 0 0 R2 = R2 − R
11 3
1 −1/2 0 0 1 −1/2
As given in Remark 3.2, the important application of the Gauss-Jordan method is to find the
inverse of a non-singular matrix A. We start with the augmented matrix of A with the identity
matrix I of the same order. When the Gauss-Jordan procedure is completed, we obtain
Gauss-Jordan method −1
[A | I] −−−−−−−−−−−−−→ [I | A ]
since, AA−1 = I.
Remark 3.3. Partial pivoting can also be done using the augmented matrix [A | I]. However,
we cannot first interchange the rows of A and then find the inverse. Then, we would be finding
the inverse of a different matrix.
Example 3.7. Find the inverse of
the matrix
1 1 1
4 3 −1
3 5 3
using the Gauss-Jordan method
3 5 3 0 0 1
We perform the following elementary row transformations and do the eliminations.
1 1 1 1 0 0 1 1 1 1 0 0
R2 = R2 − 4R1
m 0 −1 −5 −4 1 0 R2 = −R2 0 1 5 4 −1 0
R3 = R3 − 3R1 −−−−−−−→
0 2 0 −3 0 1 0 2 0 −3 0 1
1 0 −4 −3 1 0 1 0 −4 −3 1 0
R1 = R1 − R2 1
m 0 1 5 4 −1 0 R3 = − R3 0 1 5 4 −1 0
R3 = R3 − 2R2 10
0 0 −10 −11 2 1 −−−−−−−−−→ 0 0 1 11
10
2
− 10 1
− 10
This iterative methods is not always successful to all systems of equations. If this method
is to succeed, each equation of the system must possess one large coefficient and the large
coefficient must be attached to a different unknown in that equation. This condition will be
satisfied if the large coefficients are along the leading diagonal of the coefficient matrix. When
this condition is satisfied, the system will be solvable by the iterative method. The system,
In other words, the solution will exist (iterating will converge) if the absolute values of the
leading diagonal elements of the coefficient matrix A of the system AX = B are greater than
the sum of absolute values of the other coefficients of that row. The condition is sufficient
but not necessary.
Under the category of iterative method, we shall describe the following two methods:
(i) Gauss-Jacobi’s method (ii) Gauss-Seidel method.
a1 x + b 1 y + c 1 z = d 1
a2 x + b 2 y + c 2 z = d 2
a3 x + b 3 y + c 3 z = d 3
such that a1 , b2 , and c3 are the largest coefficients of x, y, z, respectively. So that convergence
is assured. Rearranging the above system of equations and rewriting in terms of x, y, z, as:
1
x = (d1 − b1 y − c1 z)
a1
1
y = (d2 − a2 x − c2 z)
b2
1
z = (d3 − a3 x − b3 y)
c3
let x0 , y0 , z0 be the initial approximations of the unknowns x, y and z. Then, the first approxi-
mation are given by
1
x1 = (d1 − b1 y0 − c1 z0 )
a1
1
y1 = (d2 − a2 x0 − c2 z0 )
b2
1
z1 = (d3 − a3 x0 − b3 y0 )
c3
1
x2 = (d1 − b1 y1 − c1 z1 )
a1
1
y2 = (d2 − a2 x1 − c2 z1 )
b2
1
z2 = (d3 − a3 x1 − b3 y1 )
c3
1
xn+1 = (d1 − b1 yn − c1 zn )
a1
1
yn+1 = (d2 − a2 xn − c2 zn )
b2
1
zn+1 = (d3 − a3 xn − b3 yn )
c3
20x + y − 2z = 17
3x + 20y − z = −18
2x − 3y + 20z = 25
using the Jacobi iteration method. Obtain the result correct to three decimal places.
Solution: The given system of equations is diagonally dominant. Jacobi method gives the
iterations as
1
xn+1 = (17 − yn + 2zn )
20
1
yn+1 = (−18 − 3xn + zn )
20
1
zn+1 = (25 − 2xn + 3yn ), n = 0, 1, . . .
20
Choose the initial approximation as x0 = y0 = zo = 0. We obtain the following results.
First iteration:
1 1
x1 = (17 − y0 + 2z0 ) = (17) = 0.85
20 20
1 1
y1 = (−18 − 3x0 + z0 ) = (−18) = −0.9
20 20
1 1
z1 = (25 − 2x0 + 3y0 ) = (25) = 1.25
20 20
Second iteration:
1 1
x2 = (17 − y1 + 2z1 ) = (17 + 0.9 + 2(1.25)) = 1.02
20 20
1 1
y2 = (−18 − 3x1 + z1 ) = (−18 − 3(0.85) + 1.25) = −0.965
20 20
1 1
z2 = (25 − 2x1 + 3y1 ) = (25 − 2(0.85) + 3(−0.9)) = 1.03
20 20
Third iteration:
1 1
x3 = (17 − y2 + 2z2 ) = (17 + 0.965 + 2(1.03)) = 1.00125
20 20
1 1
y3 = (−18 − 3x2 + z2 ) = (−18 − 3(1.02) + 1.03) = −1.0015
20 20
1 1
z3 = (25 − 2x2 + 3y2 ) = (25 − 2(1.02) + 3(−0.965)) = 1.00325
20 20
Fourth iteration:
1 1
x4 = (17 − y3 + 2z3 ) = (17 + 1.0015 + 2(1.00325)) = 1.0004
20 20
1 1
y4 = (−18 − 3x3 + z3 ) = (−18 − 3(1.00125) + 1.0032) = −1.000025
20 20
1 1
z4 = (25 − 2x3 + 3y3 ) = (25 − 2(1.00125) + 3(−1.0015)) = 0.99965
20 20
Subsequent iterations result in the following:
Since, all the errors in magnitude are less than 0.0005, the required solution is
x = 1.0, y = −0.9999, z = 0.9999
This is a modification of Gauss-Jacobi method. As before, the system of the linear equations.
a1 x + b 1 y + c 1 z = d 1
a2 x + b 2 y + c 2 z = d 2
a3 x + b 3 y + c 3 z = d 3
is written as
1
x = (d1 − b1 y − c1 z) (3.13)
a1
1
y = (d2 − a2 x − c2 z) (3.14)
b2
1
z = (d3 − a3 x − b3 y) (3.15)
c3
1
y1 = (d2 − a2 x1 − c2 z0 )
b2
1
z1 = (d3 − a3 x1 − b3 y1 )
c3
This process is continued till the value of x, y, z, are obtained to the desired degree of accu-
racy. In general, kth iteration can be written as
1
xk+1 = (d1 − b1 yk − c1 zk )
a1
1
yk+1 = (d2 − a2 xk+1 − c2 zk )
b2
1
zk+1 = (d3 − a3 xk+1 − b3 yk+1 )
c3
The rate of convergence of Gauss-Seidel method is roughly twice that of Gauss-Jacobi method.
Example 3.12. Solve the following system of equation using Gauss-Seidel method
20x + y − 2z = 17
3x + 20y − z = −18
2x − 3y + 20z = 25
Solution: The given system of equations is strongly diagonally dominant. Hence, we can
1
xn+1 = (17 − yn + 2zn )
20
1
yn+1 = (−18 − 3xn+1 + zn )
20
1
zn+1 = (25 − 2xn+1 + 3yn+1 )
20
Starting with x0 = 0, y0 = 0, z0 = 0, we get the following results.
First iteration:
1 1
x1 = (17 − y0 + 2z0 ) = (17 + 0 + 0) = 0.85
20 20
1 1
y1 = (−18 − 3x1 + z0 ) = (−18 − 3(0.85) + 0) = −1.0275
20 20
1 1
z1 = (25 − 2x1 + 3y1 ) = (25 − 2(0.85) + 3(−1.0275)) = 1.0109
20 20
Second iteration:
1 1
x2 = (17 − y1 + 2z1 ) = (17 + 1.0275 + 2(1.0109)) = 1.0025
20 20
1 1
y2 = (−18 − 3x2 + z1 ) = (−18 − 3(1.0025) + 1.0109) = −0.9998
20 20
1 1
z2 = (25 − 2x2 + 3y2 ) = (25 − 2(1.0025) + 3(−0.9998)) = 0.9998
20 20
Third iteration:
1 1
x3 = (17 − y2 + 2z2 ) = (17 + 0.9998 + 2(0.9998)) = 0.9999
20 20
1 1
y3 = (−18 − 3x3 + z2 ) = (−18 − 3(0.9999) + 0.9998) = −0.9999
20 20
1 1
z3 = (25 − 2x3 + 3y3 ) = (25 − 2(0.9999) + 3(−0.9999)) = 1.0000
20 20
Fourth iteration:
1
x4 = (17 + 0.9999 + 2(1.0000)) = 0.9999
20
1
y4 = (−18 − 3(0.9999) + 1.0000) = −0.9999
20
1
z4 = (25 − 2(0.9999) + 3(−0.9999)) = 1.0000
20
Since, all the errors in magnitude are less than 0.0005, the required solution is
x = 0.9999, y = −0.9999, z = 1.0
Rounding to three decimal places, we get x = 1.0, y = −1, z = 1.0.