0% found this document useful (0 votes)
22 views

NM Lect4 A

The document discusses solving systems of linear equations. It introduces linear equations and simultaneous linear equations. It describes Gaussian elimination and other direct methods for solving systems of linear equations including LU factorization, Cramer's rule and graphical methods. It also discusses iterative methods and solving systems using MATLAB.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

NM Lect4 A

The document discusses solving systems of linear equations. It introduces linear equations and simultaneous linear equations. It describes Gaussian elimination and other direct methods for solving systems of linear equations including LU factorization, Cramer's rule and graphical methods. It also discusses iterative methods and solving systems using MATLAB.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

PART THREE:

LINEAR SYSTEMS OF EQUATIONS


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.

(2) ©Dr. Khaldoon Bani-Hani 10/17/2007


In Chapter 2, we determined the value x
from f(x)=0. Now, we are dealing with
the value x1, x2,….xn that satisfy a set
of Simultaneous linear algebraic equations;
a11 x1  a12 x2  .....a1n xn  b1
a21 x1  a22 x2  .....a2 n xn  b2

an1 x1  an 2 x2  .....ann xn  bn
where a= constant coefficients,
b=constants and n=number of equation.
3 ©Dr. Khaldoon Bani-Hani 10/17/2007
(4) ©Dr. Khaldoon Bani-Hani 10/17/2007
Still remember all these??

 a11 a12 a13 ... a1m  AX   B


a a a23 ... a2 m 
A   21 22

      

an1 an 2 an 3 an 4 ann 
 A AX   A B
1 1

 b1   x1 
b  x  X   A B
1

 B   2   x   2 
   
 bn   xn 
(5) ©Dr. Khaldoon Bani-Hani 10/17/2007
(6) ©Dr. Khaldoon Bani-Hani 10/17/2007
Linear Algebraic
Equation Solvers

Gauss LU Factorization Iterative


Elimination & Matrix Inversion Methods

Naive Gauss LU Decomposition Gauss-Seidel


Gauss-Jordan Matrix Inverse Newton Raphson

(7) ©Dr. Khaldoon Bani-Hani 10/17/2007


Solving Linear Algebraic Equations With MATLAB
• MATLAB provide two direct method to solve system of linear
equations :
>> x=A\b  150 100 0   x1   588.6 
 100 150 50   x    686.7 
>> x= inv(A)*b   2  
 0  50 50 

  784.8 
 3 
x 
Example

>> K=[150 -100 0;-100 150 -50;0 -50 50];


>> mg= [588.6 786.7 784.8];
>> x=K\mg
x=
41.2020
55.9170
71.6130

(8) ©Dr. Khaldoon Bani-Hani 10/17/2007


Gauss Elimination
Basic for linear equation solving on
many popular software packages.
Called as Gauss elimination because it
involves combining equations to eliminate
unknowns.
For solving small sets of equation (n≤ 3),
use graphical method, Cramer’s rule and
elimination of unknown.

(9) ©Dr. Khaldoon Bani-Hani 10/17/2007


Graphical method
a11 x1  a12 x2  b1
a21 x1  a22 x2  b2
 a11  b1
x2     x1 
 a12  a12
 a21  b2
x2     x1 
 a22  a22

Plot x2 vs. x1.


The intersection
of the lines present
the solution.
(10) ©Dr. Khaldoon Bani-Hani 10/17/2007
a) No solution, b) infinite solutions, and c) ill-conditioned system
where slopes are so close that the point of intersection is difficult to
detect visually

(11) ©Dr. Khaldoon Bani-Hani 10/17/2007


Cramer’s rule
Cramer’s rule expresses the solution of a systems of
linear equations in terms of ratios of determinants.
AX   B
a11 a12 a13 
  a22 a23 a21 a23 a21 a22
A  a21 a22 a23  D  A  a11 a a  a12 a a  a13 a a
a31 a32 a33 
32 33 31 33 31 32

b1 a12 a13 a11 b1 a13 a11 a12 b1


b2 a22 a23 a21 b2 a23 a21 a22 b2
b3 a32 a33 a31 b3 a33 a31 a32 b3
x1  , x2  , x3 
D D D
(12) ©Dr. Khaldoon Bani-Hani 10/17/2007
0.3 x1  0.52 x2  x3  0.01
Example 9.2
Use Cramer’s rule to solve: 0.5 x1  x2  1.92 x3  0.67
0.1 x1  0.3 x2  0.5 x3  0.44
Check it
1 1.9 0.5 1.9 0.5 1
D  0.3  0.52 1  0.0022
0.3 0.5 0.1 0.5 0.1 0.3

0.01 0.52 1 0.3 0.01 1


0.67 1 1.92 0.5 0.67 1.92
0.44 0.3 0.5 0.1 0.44 0.5
x1   14.9, x2   29.5,
0.0022 0.0022
0.3 0.52 0.01
0.5 1 0.67 MATLAB Function “det”
>> A=[0.3 0.52 1;0.5 1 1.92;0.1 0.3 0.5];
0.1 0.3 0.44
x3   19.8 >> D=det(A)
0.0022 D=
-0.0022

(13) ©Dr. Khaldoon Bani-Hani 10/17/2007


Elimination of unknown
Solve one of the equations of the set for one of the unknowns and to
eliminate that variable from the remaining equations by substitution.
 Example: Set of two equations

a11 x1  a12 x2  b1
a21 x1  a22 x2  b2

 Eliminating x1:

a21 .(a11 x1  a12 x2  b1 )  a11a21 x1  a12a21 x2  a21b1


a11 .(a21 x1  a22 x2  b2 )  a11a21 x1  a11a22 x2  a11b2

(14) ©Dr. Khaldoon Bani-Hani 10/17/2007


Elimination of unknown

 Subtracting the second equation from the first one:

a12a21 x2  a11a22 x2  a21b1  a11b2


a21b1  a11b2
(a12 a21  a11a22 ) x2  (a21b1  a11b2 )  x2 
a12a21  a11a22

 Substitute in any of the above equations to get x1

a12b2  a22b1
x1 
a12a21  a11a22

(15) ©Dr. Khaldoon Bani-Hani 10/17/2007


Naive Gauss Elimination
It was designed to solve general set of n equations.
AX  C
Extension of elimination of unknown.
Consists of 2 phases:

1. Forward elimination of unknown

2. Solution through back substitution


(16) ©Dr. Khaldoon Bani-Hani 10/17/2007
Forward Elimination
The goal of Forward Elimination is to transform the
coefficient matrix into an Upper Triangular Matrix

 25 5 1  25 5 1 
 64 8 1  0 4.8 1.56 
   
144 12 1  0 0 0.7 
Forward Elimination

Linear Equations
A set of n equations and n unknowns

a11 x1  a12 x2  a13 x3  ...  a1n xn  b1


a21 x1  a22 x2  a23 x3  ...  a2n xn  b2
. .
. .
. .
an1 x1  an2 x2  an3 x3  ...  ann xn  bn
Forward Elimination
Transform to an Upper Triangular Matrix
Step 1: Eliminate x1 in 2nd equation using equation 1 as
the pivot equation
 Eqn1 
   (a21 )
 a11 
Which will yield

a21 a21 a21


a21 x1  a12 x2  ...  a1n xn  b1
a11 a11 a11
Forward Elimination
Zeroing out the coefficient of x1 in the 2nd equation.
Subtract this equation from 2nd equation

 a21   a21  a21


 a22  a12  x2  ...   a2 n  a1n  xn  b2  b1
 a11   a11  a11

Or Where
a21
a x2  ...  a xn  b
' ' ' a  a22 
'
22 a12
22 2n 2 a11

a21
a 
'
2n a2 n  a1n
a11
Forward Elimination
Repeat this procedure for the remaining equations to
reduce the set of equations as
a11 x1  a12 x2  a13 x3  ...  a1n xn  b1
'
a22 x2  a23
'
x3  ...  a2' n xn  b2'
'
a32 x2  a33
'
x3  ...  a3' n xn  b3'
. . .
. . .
. . .

an' 2 x2  an' 3 x3  ...  ann


'
xn  bn'
Forward Elimination
Step 2: Eliminate x2 in the 3rd equation.
Equivalent to eliminating x1 in the 2nd equation
using equation 2 as the pivot equation.

 Eqn 2 
Eqn3     (a32 )
 a22 
Forward Elimination
This procedure is repeated for the remaining equations to
reduce the set of equations as

a11 x1  a12 x2  a13 x3  ...  a1n xn  b1


'
a22 x2  a23
'
x3  ...  a2' n xn  b2'
"
a33 x3  ...  a3"n xn  b3"
. .
. .
. .

an"3 x3  ...  ann


"
xn  bn"
Forward Elimination
Continue this procedure by using the third equation as the pivot
equation and so on.
At the end of (n-1) Forward Elimination steps, the system of
equations will look like:

a11 x1  a12 x2  a13 x3  ...  a1n xn  b1


'
a22 x2  a23
'
x3  ...  a2' n xn  b2'
a x3  ...  a xn  b
"
33
"
n
"
3
. .
. .
. .
 
xn  bn 
n 1 n 1
ann
Forward Elimination
At the end of the Forward Elimination steps

a11 a12 a13 a1n   x1   b1 


 a '
a ' '     ' 
a 2n   x 2   b 2 
 22 23
 a "
33
"
a 3n   x3  b3 
  "

    
    
 (n 1)    
ann   xn  bn (n-1) 
Back Substitution

The goal of Back Substitution is to solve each of the


equations using the upper triangular matrix.

 a11 a12 a13   x1   b1 


     
 0 a22 a23  x
   2
2  b
 0 0 a33   x 3   b3 

Example of a system of 3 equations


Back Substitution

Start with the last equation because it has only one


unknown

( n 1)
b
xn  n
( n 1)
a nn

Solve the second from last equation (n-1)th


using xn solved for previously.
This solves for xn-1.
Back Substitution
Representing Back Substitution for all equations by
formula
n
bi( i 1)  
j  i 1
aij( i 1) x j
xi  ( i 1)
for i = n - 1, n - 2, ...,1
a ii

and
( n 1)
b
xn  n
( n 1)
a nn
Example 9.3 (9.5) 3.0 x1- 0.1 x2 - 0.2 x3 = 7.85 (1)
0.1 x1+ 7.0 x2 - 0.3 x3 = -19.3 (2)
Forward elimination: 0.3 x1- 0.2 x2 + 10.0 x3 = 71.4 (3)

3 x 1- 0.1 x2 - 0.2 x3 = 7.85 (1)


(2) – (0.1/3)*(1)
7.00333 x2 - 0.29333 x3 = -19.5617 (2)
(3) – (0.3/3)*(1)
-0.19000 x2 + 10.0200 x3 = 70.6150 (3)

(3) –(-0.190000/7.00333)* (2)

3. x1- 0.1 x2 - 0.2 x3 = 7.85 (1)


7.00333 x2 - 0.29333 x3 = -19.5617 (2)
Back Substitution: + 10.0120 x3 = 70.0843 (3)

(3) x3 = 7.00003
(2) x2 = -2.50000
(1) x3 = 3.00000

(33) ©Dr. Khaldoon Bani-Hani 10/17/2007


(34) ©Dr. Khaldoon Bani-Hani 10/17/2007

You might also like