0% found this document useful (0 votes)
56 views15 pages

CE304-Unit 3-Lect1-Jumah2018

The document discusses solving systems of linear equations. It begins by defining what a linear equation is - an equation of the form ax + by + c = 0. It then discusses solving simultaneous linear algebraic equations, representing them in matrix form. It presents several methods for solving such systems, including Gauss elimination, LU factorization/matrix inversion, and iterative methods. Gauss elimination involves transforming the coefficient matrix into an upper triangular matrix using forward elimination of unknowns. Forward elimination zeroes out coefficients below the diagonal to simplify the system of equations.
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)
56 views15 pages

CE304-Unit 3-Lect1-Jumah2018

The document discusses solving systems of linear equations. It begins by defining what a linear equation is - an equation of the form ax + by + c = 0. It then discusses solving simultaneous linear algebraic equations, representing them in matrix form. It presents several methods for solving such systems, including Gauss elimination, LU factorization/matrix inversion, and iterative methods. Gauss elimination involves transforming the coefficient matrix into an upper triangular matrix using forward elimination of unknowns. Forward elimination zeroes out coefficients below the diagonal to simplify the system of equations.
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/ 15

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.

1
In Unit 2, we determined the value x
This image cannot currently be display ed.

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.

2
Still remember all these??
This image cannot currently be display ed.

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


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

 an1 an 2 an 3 an 4 ann 
 A1AX   A1B
 b1   x1 
b  x  X   A1B
 B   2   x   2 
   
 bn   xn 

3
Linear Algebraic
Equation Solvers

Gauss LU Factorization Iterative


Elimination & Matrix Inversion Methods

Cramer’s rule LU Decomposition Gauss-Seidel


Naive Gauss Matrix Inverse Newton Raphson

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   x3   784.8 
  
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

4
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.

Graphical method
a11 x1  a12 x2  b1 Example 9.1
a21 x1  a22 x2  b2 (Note: Determinant = D = 8)

a  b
x2    11  x1  1
 a12  a12
a  b
x2    21  x1  2
 a22  a 22

Plot x2 vs. x1.


The intersection
of the lines present
the solution.

5
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
See Example 9.2:
Note: (Determinant = D)
a) D = 0, b) D = 0, and c) D = -0.04

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 
a a a a a a
A  a21 a22 a23  D  A  a11 a22 a23  a12 a21 a23  a13 a21 a22
32 33 31 33 31 32
a31 a32 a33 

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

6
Example 9.3 0.3 x1  0.52 x2  x 3  0.01
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 >> D=det(A)
x3   19.8
0.0022 D=
-0.0022

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  a12 a21 x2  a21b1


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

7
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 
a12 a21  a11a22

 Substitute in any of the above equations to get x1

a12 b2  a22 b1
x1 
a12a21  a11a22
See example 9.4

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

8
Forward Elimination
The goal of Forward Elimination is to transform the
coefficient matrix into an Upper Triangular Matrix
Try this??

 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  ...  a2 n xn  b2
. .
. .
. .

an1 x1  an 2 x2  an 3 x3  ...  ann xn  bn

9
Forward Elimination
Transform to an Upper Triangular Matrix
Step 1: Eliminate x1 in 2nd equation using equation 1 as
the pivot equation
 Eqn1 
   (a21 )
a
 11 
Which will yield

a21 a a
a21 x1  a12 x2  ...  21 a1n x n  21 b1
a11 a11 a11

Forward Elimination
Zeroing out the coefficient of x1 in the 2nd equation.
Subtract this equation from 2nd equation

 a21   a  a
 a22  a12  x2  ...   a2 n  21 a1n  xn  b2  21 b1
 a11   a11  a11

Or Where
a21
'
a 22 x2  ...  a2' n xn  b2'
'
a22  a22  a
a11 12

a21
a2' n  a2n  a1n
a11

10
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
'
a 22 x 2  a23
'
x3  ...  a2' n x n  b2'
'
a32 x2  a33
'
x3  ...  a3' n x n  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.

 Eqn2 
Eqn3     (a32 )
 a22 

11
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 x 2  a23
'
x 3  ...  a2' n xn  b2'
"
a33 x3  ...  a3"n x n  b3"
. .
. .
. .

an" 3 x3  ...  ann


"
x n  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'
"
a33 x3  ...  an" xn  b3"
. .
. .
. .
 
xn  bn 
n 1 n 1
ann

12
Forward Elimination
At the end of the Forward Elimination steps

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


 a'22 a'23  a'2n   x 2   b'2 

 a"33  a"3n   x 3    b"3 
    
        
 a(n
nn
1)  
  xn  b n 
(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    b2 
 0 0 a33   x 3   b3 

Example of a system of 3 equations

13
Back Substitution

Start with the last equation because it has only one


unknown

bn( n1)
xn  ( n1)
ann

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
b( i  1)
i  a
j  i 1
( i  1)
ij xj
xi  ( i  1)
for i = n - 1, n - 2, ...,1
a ii

and
bn( n 1)
xn  ( n1)
ann

14
Example 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 x1- 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) x1= 3.00000

15

You might also like