Beruflich Dokumente
Kultur Dokumente
METHODS TO SOLVE A
SYSTEM OF LINEAR
EQUATIONS
Introduction
Engineers frequently encounter problems involving the solution of sets of simultaneous algebric equations. Very frequently the equations are linear, so here we will
consider methods applicable for solving sets of linear equations.
Problems involving simultaneous linear equations arise in the areas of elasticity,
electric-circuit analysis, heat transfer, vibrations, and so forth. Also, the numerical integration of some types of ordinary and partial differential equations may be
reduced to the solution of such a set of equations.
To solve the sets of linear equations, the basic concepts and notation of matrices
are required. A matrix is a rectangular array of numbers in which not only the
value of the number is important but also its position in the array. The number of
its rows and columns describes the size of the matrix. A matrix of n rows and m
columns is said to be n m.
A=
a11
a21
a31
an1
a12 a13
a22 a23
a32 a33
an2 an3
a1m
a2m
a3m
anm
= [aij ],
i = 1, 2, 3, , n, j = 1, 2, 3, , m
Two matrices of the same size may be added or subtracted. The sum of A =
[aij ] and B = [bij ] is the matrix whose elements are the sum of the corresponding
elements of A and B:
C = A B = [aij bij ] = [cij ].
73
If
4 2
1 5
A = 4 2.5 and B = 2 6
3 0.0
4 3
Here A is 3 2 because it has three rows and two columns. B is also 3 2. Their
sum C is also 3 2:
5
3
C = A + B = 2 8.5
7
3
The difference D of A and B is
3 7
D = A B = 6 3.5
1 3
Multiplication of two matrices is defined when the number of columns of first matrix
is equal to the number of rows of second matrix i.e., when A is nm and B is mr :
cij =
(a11 b11
(a21 b11
(a31 b11
(an1 b11
m
X
+
+
+
aik bkj ,
i = 1, 2, 3, , n, j = 1, 2, 3, , r.
k=1
kA = C,
cij = kaij
Matrix with only one column n 1 in size, is termed as a column vector, and one
of only one row, 1 m in size, is called a row vector. Normally, term vector is
used for a column vector. If A is n n, it is called a square matrix.
Suppose
3 7 1
3 7 3 2
6
3 2
A = 6 3 2 1 , B =
1 3 5
1 3 5 4
6
3 2
74
Then
60 45 8
A B = 32
48 12
;
34 5 26
and
BA=
50 45
0
3
38
45 2 1
;
10 17 16 15
2 39 34 23
=
=
=
b1
b2
b3
= bn
(5.1)
A=
x=
x1
x2
x3
..
.
xm
b=
b1
b2
b3
..
.
bm
[1 3 2] 2
= [16]
3
gives a matrix of one row and one column. The result is a pure number, a scalar.
This product is called the scalar product of the vectors, also called the inner
product.
75
4
4 12 8
2
6 4
[1
3
2]
=
2
.
3
3 9 6
This product is called the outer product, very important in nonlinear optimization
problems.
If all the elements above the diagonal are zero, a matrix is called lowertriangular; it is called upper-triangular when all the elements below the diagonal
are zero. For example,
4 0 0
L = 2 6 0 ,
3 9 6
4 12 8
U = 0 6 0 .
0 0 6
The diagonal elements are the line of elements aii from upper left to lower right of
the matrix. If only the diagonal terms are nonzero, the matrix is called a diagonal
matrix. When the diagonal elements are each equal to unity while all off-diagonal
elements are zero, the matrix is said to be the identity matrix of order n e.g.,
1
0
0
0
0
1
0
0
0
0
1
0
0
0
0
1
= I4
Tridiagonal matrices are those that have nonzero elements only on the diagonal and in the positions adjacent to the diagonal; they will be of special importance
in certain partial differential equations. An example is
4
2
0
0
0
2
6
9
0
0
0
3
6
1
0
0
0
1
3
2
0
0
0
1
4
When a matrix is square, a quantity called its trace is defined, which is the sum of
the elements on the main diagonal. Trace of the above matrix is
tr(A) = 4 + 6 + 6 + 3 + 4 = 23
All the elements of the null matrix are zero:
A=
0
0
0
0
0
0
0
0
76
0
0
0
0
0
0
0
0
A=
2
3 4
1 3 2
3
3 4
6
1 6
2 1 3 6
then AT = 3 3 3 1
4
2 4 6
u = 0 ,
0
v = 1 ,
0
w = 0 .
1
Null vectors are defined as the vectors, with all the elements zero:
u = 0 .
0
Transpose vector of a vector
x1
u = x2
x3
is given by
uT = [x1
x2
Determinant
minor
5.1
Sigma Notation
n
X
xi = x1 + x2 + x3 + + xn
i=1
77
x3 ]
n
X
c = c
i=1
1
X
n
X
1 == c(1 + 1 + 1 + + 1) = cn
i=1
xi = x1
i=1
n
X
xi =
i=1
n
X
n
X
xj =
j=1
xk .
k=1
a1j xj =
b1
j=1
m
X
a2j xj =
b2
j=1
m
X
a3j xj =
j=1
m
X
j=1
5.2
b3
anj xj =
bn
m
X
aij xj = bi
i = 1, 2, 3, , n
j=1
Product Notaion
n
Y
x1 = x1 x2 x3 xn
i=1
5.3
The first method usually presented in algebra for the solution of the set of equations is one in which the unknowns are eliminated by combining equations. Such a
method is known as an elimination method. It is called Gaussian elimination
if a particular systematic scheme, attributed to Gauss, is used in the elimination
process. This method is the basic pattern of a large number of methods that are
classified as direct methods.
Using Gausss method, a set of n equations in n unknowns is reduced to an
equivalent triangular set (an equivalent set is a set having identical solution values),
which is then easily solved by back substitution.
Consider the general form of the set of n equations in n unknowns
(a)
(b)
(c)
(5.2)
If the bs are not all zero, the set of equations is nonhomogeneous, and all
equations must be independent to obtain unique solutions. If the bs are all zero,
the set of equations is homogeneous, then nontrivial solutions exist only if all the
equations are not independent.
The Gaussian elimination method is accomplished in the following manner:
1. Equation (??a) is divided by the coefficient of x1 in that equation to obtain
x1 +
a12
a13
a1n
b1
x2 +
x3 + +
xn =
a11
a11
a11
a11
(5.3)
= b1
= b02
= b03
..
.
= b0n
(a)
(b)
(c)
(5.4)
where the prime superscripts indicate the new coefficients which are formed
in the reduction process.
The equation used to eliminate the unknowns in the equations which follow it
is called the pivot equation(eq. (??a) in the preceding steps). In the pivot
equation the coefficient of the unknown, which is to be eliminated from the
subsequent equations, is known as the pivot coefficient(a11 in the preceding
steps).
2. Following the above steps, (??b) becomes the pivot equation, and the steps of
part 1 are repeated to eliminate x2 from all the equations following this pivot
79
= b1
= b02
= b003
..
.
= b00n
(a)
(b)
(c)
(5.5)
3. Equation (??c) is next used as the pivot equation, and the procedure described
is used to eliminate x3 from all the equations following this pivot equation
(??c). This procedure, using successive pivot equations, is continued until the
original set of equations has been reduced to a triangular set
a11 x1 + a12 x2 + a13 x3 + + a1n1 xn1 + a1n xn
a022 x2 + a023 x3 + + a02n1 xn1 + a02n xn
a0033 x3 + + a003n1 xn1 + a003n xn
..
.
(n2)
(n2)
an1n1 x3 + an1n xn
a(n1)
xn
nn
= b1
(a)
= b02
(b)
00
= b3
(c)
..
.
(n2)
= bn1
= b(n1)
n
(5.6)
4. After the triangular set of equations has been obtained, the last equation in
this equivalent set yields the value of xn directly. This value is then substituted
into the next -to-the-last equation of the triangular set to obtain a value of
xn1 , which is, in turn, used along with the value of xn in the second-to-the-last
equation to obtain a value of xn2 , and so on. This is the back-substitution
procedure.
To illustrate the method, let us apply these procedurs to solve the following set
of equations:
x1 + 6x2 x3 = 13
2x1 x2 + 2x3 = 5
Using the first equation as the pivot
obtain
2x1 + 8x2 +
2x2
9x2
(5.7)
80
2x3
= 14
2x3
=
6
(0)x3 = 9
(5.8)
Next, using the second equation of (??) as the pivot equation and repeating the
procedure, we obtain the following triangular set of equations
2x1 + 8x2 + 2x3 = 14
2x2 2x3 = 6
9x3 = 18
(5.9)
2 8
2
x1
14
1 6 1 x2 = 13
2 1
2
x3
5
(5.10)
.
2 .. 14
.
6 1 .. 13
..
2 1
2 . 5
A/b = 1
(5.11)
The computer solution is involved with the reduction of this augmented matrix
to the augmented matrix of the equivalent triangular set of equations. The necessary
successive matrix reductions are accomplished by the same procedures given in steps
1 through 3, above although in working with matrices we are now concerned with
the pivot row and pivot element rather than with the pivot equation and pivot
coefficient, as before.
The first matrix reduction should result in the augmented matrix
.
2 .. 14
.
2 2 ..
6
..
0 9
0 . 9
0
A = 0
(5.12)
Reviewing the procedure outlined in step 1, the elements of the reduced matrix A0
can be written directly from the original matrix A, using the following formula:
a0ij
aik
= aij
akj
akk
where
a
a0
i
j
k
n
m
=
=
=
=
=
=
=
82
k j m
k+1 i n
(5.13)
..
.
14
..
.
6
..
0 0 9 . 18
2 8
2
00
A = 0 2 2
(5.14)
which is determined from the matrix A0 utilizing (??). Note that the matrix of
equation(??) is the augmented matrix of equation (??). After obtaining the augmented matrix of the equivalent triangular set of equations, the xi values are obtained by back substitution, giving the same results.
For an efficient way of programming Gausss elimination method for the computer, we write a general procedure for reducing matrices as
(
k1
akj
k
k1
k1
aij = aij k1 aik
akk
k+1 j m
k+1 i n
(5.15)
where the is, js, ks, and so on, are as previously defined. The superscripts shown
merely correspond to the primes used in identifying successive reduced matrices,
and are not needed in a computer program.
The back substitution procedure may be generalized in the form of the following
set of equations:
anm
ann
P
aim nj=i+1 aij xj
=
aii
xn =
xi
(5.16)
i = n 1, n 2, , 1
(5.17)
There are two points, yet to be considered. First, we must guard against dividing by zero. Observe that zeros may be created in the diagonal positions even
if they are not present in the original matrix of coefficients. A useful strategy to
avoid (if possible) such zero divisors is to rearrange the equations so as to put the
coefficient of large magnitude on the diagonal at each step. This is called pivoting.
Complete pivoting may require both row and column interchanges. This is not
frequently done. Partial pivoting which places a coefficient of larger magnitude
on the diagonal by row interchanges only, will guarantee a nonzero divisor if there
is a solution to the set of equations, and will have the added advantage of improved
arithmetic precision. The diagonal elements that result are called pivot elements.
The second important point is the effect of the magnitude of the pivot elements
on the accuracy of the solution. If the magnitude of the pivot element is appreciably
smaller than the magnitude (absolute), in general, of the other elements in the
83
matrix, the use of the small pivot element will cause a decrease in the solution
accuracy. Therefore, for overall accuracy, using as a pivot row the row having the
largest pivot element should make each reduction. Such a provision should always
be incorporated in a computer program that is to solve fairly large numbers of
simultaneous equations.
We note that in terms of matrix operations, we transform the augmented coefficient matrix by elementary row transformations until an upper triangular matrix
is created on the left. Then back substitution gives the results (solution).
There exists the possibility that the set of equations has no solution or that
the prior procedure will fail to find it. During the triangularization step, if a
zero is encountered on the diagonal, we cannot use that row to eliminate coefficients
below that zero element. However, in that case, we will continue by interchanging
rows and eventually achieve an upper triangular matrix of coefficients. The real
stumbling block is finding a zero on the diagonal after we have trangularized. If
that occurs, the back substitution fails, for we cannot divide by zero. It also means
that the determinant is zero: there is no solution.
5.4
The use of determinant method (Cramers rule) is not recommended for the solution
of linear simultaneous equations. The reason is that, except for systems of only two
or three equations, this method is too inefficient. For example, for a set of 10
simultaneous equations, about 70,000,000 multiplications and divisions are required
if the usual method of expansion in terms of minors is used. A more efficient method
of evaluating the determinants can reduce this to about 3000 multiplications, but
even this is inefficient compared to Gaussian elimination, which would require about
380. It may at times be necessary to evaluate a determinant. For large determinants,
the use of Gaussian elimination is much more efficient than expansion by minors.
From the definition of a determinant and the rules of expansion by minors, it may
be shown that
1. A determinant is changed only in sign by interchanging any two of its rows
(or columns).
2. A determinant is not changed in value if we add (or subtract) a constant
multiple of the elements of a row (or column) to the corresponding elements
of another row (or column).
The Gaussian reduction procedure is illustrated by evaluating the determinant of
the coefficient matrix of equation (??). The determinant is
84