You are on page 1of 28

KIL1005: NUMERICAL METHODS FOR ENGINEERING

SEMESTER 2, SESSION 2022/2023

LECTURE 6: LINEAR ALGEBRAIC


EQUATIONS

DR MAHAR DIANA HAMID


DEPARTMENT OF CHEMICAL ENGINEERING
INTRODUCTION
• An equation of the form ax+by+c=0 or equivalently ax+by=-c is
called a linear equation in x and y variables.
• ax+by+cz=d is a linear equation in three variables, x, y, and z.
• Thus, a linear equation in n variables is
a1x1+a2x2+ … +anxn = b
where the a’s are constant coefficients and the b’s are constants.
• A solution of such an equation consists of real numbers c1, c2, c3, … ,
cn. If you need to work more than one linear equations, a system of
linear equations must be solved simultaneously.

2
Solving Small Numbers of Equations
• There are many ways to solve a system of linear equations:
• Graphical method
• Cramer’s rule For n ≤ 3
• Method of elimination
• Computer methods

3
4
5
GRAPHICAL METHOD
• For two equations:
a11x1  a12 x2  b1
a21x1  a22 x2  b2

• Solve both equations for x2: These lines can be


a  b graphed on Cartesian
x2   11  x1  1  x2  (slope) x1  intercept coordinates with x2 as the
 a12  a12 ordinate and x1 as the
abscissa.
a  b The values of x1 and x2 at
x2   21  x1  2 the intersection of the
 a22  a22 lines represent the
solution 6
EXAMPLE 1 Fig. 9.1

• Use graphical method to solve


3𝑥 + 2𝑥 = 18
−𝑥 + 2𝑥 = 2

• Plot x2 vs. x1 on graph paper, the


intersection of the lines present
the solution.
8
FIGURE
9.2

› However there are cases where graphical methods are not suitable
to solve two sets of linear algebraic equations:
(a) Parallel line: no intersection between the two equations
(b) Parallel and similar line: the lines for both equation overlap each other
(c) The lines for both equations are very hard to distinguished
› Hence, it is needed to use numerical methods to solve for linear
algebraic equations. 9
CRAMER’S RULE
1. Determinant can be 3. Assuming all matrices are square matrices,
illustrated for a set of three there is a number associated with each
equations: square matrix [A] called the determinant,
Ax  B D, of [A]. If [A] is order 1, then [A] has
one element:
[A]=[a11]
2. Where [A] is the
D=a11
coefficient matrix:
4. For a square matrix of order 3, the minor
a11 a12 a13 
of an element aij is the determinant of the
A  a21 a22 a23  matrix of order 2 by deleting row i and
column j of [A].
a31 a32 a33  10
11
1 2
a11 a12 a13 a22 a23 a21 a23 a21 a22
D  a11  a12  a13
D  a21 a22 a23 a32 a33 a31 a33 a31 a32
a31 a32 a33
• Cramer’s rule expresses the solution
a22 a23 of a systems of linear equations in terms
D11   a22 a33  a32 a23
a32 a33 of ratios of determinants of the array of
coefficients of the equations. For
a21 a23 example, x1 would be computed as:
D12   a21 a33  a31 a23
a31 a33
b1 a12 a13
a21 a22
D13   a21 a32  a31 a22 b2 a22 a23
a31 a32
b3 a32 a33
x1 
D 12
Use Cramer’s rule to solve
0.3𝑥 + 0.52𝑥 + 𝑥 = −0.01
0.5𝑥 + 𝑥 + 1.9𝑥 = 0.67
0.1𝑥 + 0.3𝑥 + 0.5𝑥 = −0.44
THE ELIMINATION OF UNKNOWNS
• For a set of two equations;
𝑎 𝑥 +𝑎 𝑥 =𝑏
𝑎 𝑥 +𝑎 𝑥 =𝑏
• Multiply the equations by constants so that one of the unknowns will be
eliminated when the two equations are combined.
• The results is a single equation that can be solved for the remaining unknowns.
• This value can then be substituted into either the original equations to compute
the other variables

14
15
16
EXAMPLE 3
Solve the following using the elimination of unknowns
3𝑥 + 2𝑥 = 18
−𝑥 + 2𝑥 = 2
18
NAIVE GAUSS ELIMINATION
1. Extension of method of elimination to large sets of equations by developing a
systematic scheme or algorithm to eliminate unknowns and to back substitute.
2. As in the case of the solution of two equations, the technique for n equations
consists of two phases:
1. Forward elimination of unknowns
2. Back substitution

19
FORWARD ELIMINATION OF UNKNOWNS
• Designed to reduce the set of
equations to an upper triangular
system (Figure 9.3)
• Initial step: eliminate the first
unknown x1 from the second through
the nth equations
• Repeated for the remaining
equations
• Refer to the example for clearer
procedures.
BACK SUBSTITUTION
• The result from forward
elimination can be back-
substituted into the (n-1)the
equation to solve for xn-1.
Use Gauss elimination to solve
3𝑥 − 0.1𝑥 − 0.2𝑥 = 7.85
0.1𝑥 + 7𝑥 − 0.3𝑥 = −19.3
0.3𝑥 + 0.2𝑥 + 10𝑥 = 71.4
23
24
25
PITFALLS OF ELIMINATION METHODS
1. Division by zero. It is possible that during both elimination and back-substitution
phases a division by zero can occur.
2. Round-off errors.
3. Ill-conditioned systems. Systems where small changes in coefficients result in
large changes in the solution. Alternatively, it happens when two or more
equations are nearly identical, resulting a wide ranges of answers to
approximately satisfy the equations. Since round off errors can induce small
changes in the coefficients, these changes can lead to large solution errors.
4. Singular systems. When two equations are identical, we would loose one degree
of freedom and be dealing with the impossible case of n-1 equations for n
unknowns. For large sets of equations, it may not be obvious however. The fact
that the determinant of a singular system is zero can be used and tested by
computer algorithm after the elimination stage. If a zero diagonal element is
created, calculation is terminated.

26
TECHNIQUES FOR IMPROVING SOLUTIONS
• Use of more significant figures.
• Pivoting. If a pivot element is zero, normalization step leads to division by zero.
The same problem may arise, when the pivot element is close to zero. Problem
can be avoided:
• Partial pivoting. Switching the rows so that the largest element is the pivot element.
• Complete pivoting. Searching for the largest element in all rows and columns then
switching.

27
GAUSS-JORDAN
• It is a variation of Gauss elimination. The major differences are:
• When an unknown is eliminated, it is eliminated from all other equations rather than
just the subsequent ones.
• All rows are normalized by dividing them by their pivot elements.
• Elimination step results in an identity matrix.
• Consequently, it is not necessary to employ back substitution to obtain solution.

28

You might also like