Chapter 3

advertisement
Department of Engineering Mathematics and
Physics, Faculty of Engineering
Zagazig University
2009-2010
Numerical solution of non linear equations.
Numerical solution of linear equations.
Numerical integrations.
Curve fitting
Numerical solution of ordinary differential equations.
Numerical solution of partial differential equations.
Next
The Main Menu
‫ا‬Previous
Linear equation
A linear equation is an algebraic equation in which each term
is either a constant or the product of a constant and the first power of a
single variable. Linear equations can have one or more variables.
The standard form Ax + By = C.
a- Cannot have exponents (or powers). b - Cannot multiply or divide each
other. c - Cannot be found under a root sign or square root sign (sqrt)
System of linear equations
In mathematics, a system of linear equations (or linear system)
is a collection of linear equations involving the same set of variables.
i.e. A system of linear equations is simply a two or more linear
equations using the same variables. a11x1  a12 x 2  ...  a1n x n  b1
The equation may be written in
a 21x1  a 22 x 2  ...  a 2 n x n  b 2
compact form [A].
...........................................
Next
[x] = [b]
a m1x1  a m 2 x 2  ...  a m n x n b n .
The Main Menu
‫ا‬Previous
The augment matrix
The system of linear equations is [A]nxn. [x]nx1 = [b]nx1
 a11 a12

 a 21 a 22
 ... ...

a
 n1 a n 2
... a1n  x1   b1 
   
... a 2 n  x 2   b 2 
 



... ... ...
...
   
... a nn  x n   b n 
The augment matrix is
 a11 a12

 a 21 a 22
 ... ...

a
 n1 a n 2
Next
... a1n b1 

... a 2 n b 2 
... ... ... 

... a nn b n 
The Main Menu
‫ا‬Previous
It is iterative method for solving system of linear
equations when the systems of linear equations are very large
(large number of unknowns).
Jacobi method converge for diagonal dominant matrices A
(diagonal entries of A larger than the others).
In this method we covert the system of linear equations
[A] .[ x] = [b] to [x] = [C] . [x] + d
Generate a sequence of approximation x1,
x2,….. where xn = Cxn-1 + d
a13
a12
b
x 1n  
x 2(n 1) 
x 3(n 1)  1 ,
a11
a11
a11
a11x1  a12 x 2  a13 x 3  b1
a
a
b
a 21x1  a 22 x 2  a 23 x 3  b 2
x 2 n   21 x1(n 1)  23 x 3(n 1)  2 ,
a 22
a 22
a 22
a 31x1  a 32 x 2  a 33x 3 b 3 .
a
a
b
x 3 n   31 x1(n 1)  32 x 2 (n 1)  3
a 33
a 33
a 33
Next
The Main Menu
‫ا‬Previous
It is iterative method for solving system of linear equations [A] .[ x] = [b].
It is a modification to Jacobi’s method.
a11x1  a12 x 2  a13 x 3  b1
a 21x1  a 22 x 2  a 23 x 3  b 2
a 31x1  a 32 x 2  a 33x 3 b 3 .
Next
x 1n  
a
a12
b
x 2(n 1)  13 x 3(n 1)  1 ,
a11
a11
a11
x 2n  
a
a 21
b
x1(n 1)  23 x 3(n 1)  2 ,
a 22
a 22
a 22
x 3n  
a 31
a
b
x1(n 1)  32 x 2 (n 1)  3
a 33
a 33
a 33
The Main Menu
‫ا‬Previous
Solve the linear system by Jacobi’s method
4x -y + z = 7
4x -8y+ z = -21
-2x + y + 5z = 15.
From the system of linear equation we get:
7  y z
x
,
4
21  4 x  z
y
,
8
15  2 x  y
z
.
5
xn 
yn 
zn 
7  y (n 1)  z (n 1)
,
4
21  4 x (n 1)  z (n 1)
8
15  2 x n 1  y n 1
.
5
If we start with (x0, y0, z0) = (0, 0, 0),
Next
,
The Main Menu
‫ا‬Previous
xn 
yn 
zn 
n
7  y (n 1)  z (n 1)
,
4
21  4 x (n 1)  z (n 1)
8
,
15  2 x n 1  y n 1
.
5
xn
yn
zn
0
0
0
0
1
1.75
2.625
3
2
1.656
3.875
3.175
3
1.925
3.85
2.887
4
1.99
3.948
3
5
1.99
3.995
2.997
3.995
2.997
6
1.9995
The iteration appears to converge to the solution (2, 4, 3)
Next
The Main Menu
‫ا‬Previous
Solve the linear system by Gauss seidle method
4x -y + z = 7
4x -8y+ z = -21
-2x + y + 5z = 15.
From the system of linear equation we get:
7  y z
x
,
4
21  4 x  z
y
,
8
15  2 x  y
z
.
5
xn 
yn 
zn 
7  y (n 1)  z (n 1)
,
4
21  4 x (n 1)  z (n 1)
8
15  2 x n 1  y n 1
.
5
If we start with (x0, y0, z0) = (0, 0, 0),
Next
,
The Main Menu
‫ا‬Previous
xn 
yn 
zn 
7  y (n 1)  z (n 1)
,
4
21  4 x (n 1)  z (n 1)
,
n
xn
15  2 x n 1  y n 1
.
5
0
0
1.75
8
1
yn
zn
0
3.5
2
1.875 3.9375 2.9625
3
1.994 3.9922
2.887
4
1.998
2.999
5
3.999
1.9999 3.9998 2.9999
The iteration appears to converge to the solution (2, 4, 3)
Next
0
3
The Main Menu
‫ا‬Previous
Next
The Main Menu
‫ا‬Previous
Non Linear equation
An equation in which one or more terms have a variable of
degree 2 or higher is called a nonlinear equation. The non linear
equation f (x) = 0 and we find the roots of this equation.
System of non linear equations
A nonlinear system of equations contains at least one
nonlinear equation.
A system has no
solution.
A system has many
solutions.
Next
A system has one
solution.
The Main Menu
‫ا‬Previous
A system has two
solutions
It is one of the first numerical methods to find the root of a
nonlinear equation f(x) = 0 also called binary-search method. The method is
based on finding the root between two points.
At least one root exists between the two points if the function is real,
continuous, and changes sign. If the function does not change sign between
the two points then there may not be any root for the equation between the
two points.
The steps to apply the bisection method to find the root of the equation
are:
1- Choose a and b for the root such that f(a) f(b) < 0, or in other words, f (x)
changes sign between a and b.
2- Estimate the root xn such that xn = (an + bn) / 2.
If f(xn) = 0, then xn is the root of the equation. If f(xn )  0, f(xn) > 0 ,find the
new estimate such that the mid point between a , xn. If f(xn)  0, f(xn) < 0,
find the new estimate such that the mid point between xn , b.
Next
The Main Menu
‫ا‬Previous
It is the numerical method to find the root of a nonlinear equation
f(x) = 0 also called
method.
The steps to apply the simple iteration method to find the root of the
equation are:
1- Choose x0.
2- The function f(x) = 0 is transformed into equation x = g(x).
3- Test the convergence g(x 0 )  1
4- Compute xn+1 = g(xn)
5- If x n 1  x n  ε ; end
Next
The Main Menu
‫ا‬Previous
It is the numerical method to find the root of a nonlinear equation
f(x) = 0.
The secant method is defined by the recurrence relation:
x n 1  x n 
x n  x n 1
f(x n )
f(x n )  f(x n 1 )
It requires two initial values, x0 and x1, which should ideally be
chosen to lie close to the root.
The steps to apply the Secant method to find the root of the equation
are:
1. Select x0 and x1
2. Evaluate f(x0) and f(x1)
3. Evaluate xn+1
4. If x n 1  x n  ε ; end
Next
The Main Menu
‫ا‬Previous
It is the best numerical method and fast way to find the root of a
nonlinear equation f(x) = 0.
This method is defined by the recurrence relation:
f(x n )
f (x n )
The steps to apply the Newton-Raphson method to find the root of
the equation are:
x n 1  x n 
1- From f (x) get f\ (x)
f(x 0 ) f (x 0 )
 1.
2. Choose x0and test the convergence
2

[f (x n )]
3. Evaluate x n 1  x n  f(x n )
f (x n )
4. If x n 1  x n  ε ; end
Next
The Main Menu
‫ا‬Previous
Solve, using the Bisection method to find the positive root of the
equation:
f(x) = x3 + 4 x2 – 10 = 0.
Let x =a = 1
x = b =2
n

f(1) = –,
 f(2) = +, then the root of this equation lies between [1, 2].
an
a b
xn  n n
2
bn
f(xn)
0
1
2
1.5
2.375
1
1
1.5
1.25
-1.79687
2
1.25
1.5
1.375
0.16211
3
1.25
1.375
1.3125
-0.84839
12
1.36476094 1.365234375
Next
The Main Menu
1.364990235
‫ا‬Previous
-0.003396
Solve, using the simple iteration method to find the positive root :
f(x) = x – sin x = 0.25 correct to three decimal places.
f(x) = x –sin x - 0.25 = 0.
x
0
1
2
1.5
f(x)
- 0.25
- 0.091
0.841
0.253
Let x0 =1.2, x = sin x + 0.25.
Then x = g(x) = sin x + 0.25.  g(x)  cosx
Test the convergence g ( x0 )  cos1.2  0.362  1
Then xn+1= g(xn) =sin xn +0.25.
n
0
1
2
3
4
xn+1
1.182
1.175
1.173
1.172
1.172
Next
The Main Menu
‫ا‬Previous
Solve, using the Secant method to find the positive root :
f(x) = 0.18x3 – 0.5 x2 -2x +1 correct to four decimal places,
where x0 = 4, x1 = 6.
x n  x n 1
f(x n ) 
f(x n )  f(x n 1 )
x n  x n 1
x n 1  x n 
(0.18 x 3 n  0.5 xn2  2 xn  1)
3
2
3
2
(0.18 x n  0.5 xn  2 xn  1)  (0.18 x n 1  0.5 xn 1  2 xn 1  1)
x n 1  x n 
n
xn-1
f(xn-1)
xn
f(xn)
xn+1
1
4 -3.4800
6
9.8800
4.5210
2
6
9.8800
4.5210 -1.6287
4.7303
3
4.5210 -1.6287
4.7303 -0.5967
4.8513
4
4.7303 -0.5967
4.8513 -0.0815
4.8368
5
4.8513 -0.0815
4.8368 -0.0032 4.8373
Next
The Main Menu
‫ا‬Previous
Solve, using the Newton - Raphson method to find the positive root :
f(x) = 0.18x3 – 0.5 x2 -2x +1 correct to four decimal places,
x
1
2
3
4
5
f(x)
-1.32
-3.56
-4.64
-3.48
1
Let x0 = 4.5,
 f (x)  0.54 x 2  x  2,
f (x)  1.08 x  1.
Test the convergence
f(x 0 ) f (x 0 ) (1.7225)(3.86)

 0.33  1
[f (x n )]2
(4.435) 2
f(x n )
0.18 x 3n  0.5 x 2n  2 x n  1
.
 x n 1  x n 
 x n 1  x n 
2
0.54 x n  x n  2
f (x n )
n
0
1
2
xn+1
4.8884
4.8382
4.8373
Next
The Main Menu
‫ا‬Previous
Let there be given a system of two equations in two unknowns,
F (x, y) = 0,
G (x, y) = 0.
Let x = x0, y = y0 be the approximate values of the root of this system.
By using Newton-Raphson’s method
The general formula to get the required root is:
F
x n 1  x n 
Fy
G Gy
Fx
Fy
Gx
Gy
Next
(x n , y n )
,
y n 1  y n 
(x n , y n )
The Main Menu
Fx
F
Gx
G
Fx
Fy
Gx
Gy
(x n , y n )
‫ا‬Previous
(x n , y n )
.
Find the root of the system,
F (x, y) = 4 – x2 – y2 = 0,
G (x, y) = 1 – ex – y = 0.
Given that (x0, y0 ) = (1, -1.7). Two steps are required. Correct to 4D.
We get:
F
Fx 
 2 x,
x
Gx 
Fy 
F
 2 y,
y
G
G
 1.
  ex , G y 
y
x
For (x0, y0) = (1, -1.7), we get:
Fx  2, Fy  3.4, G x  2.7183, G y  1, F  0.11, G  0.0813.
Next
The Main Menu
‫ا‬Previous
Then,
x1  x 0 
F
Fy
0.11
G Gy
(x 0 , y 0 )
Fx
Fy
Gx
Gy
y1  y 0 
 1
F
Gx
G
Fx
Fy
Gx
Gy
 0.0183  1
 1.0043
2
3.4
 2.7183  1
(x n , y n )
Fx
3.4
2
(x 0 , y 0 )
(x 0 , y 0 )

0.11
 2.7183  0.0183
 1.7299.
2
3.4
 2.7183  1
For (x1, y1) = (1.0043, -1.7299), we get:
Fx  2.0086, G
x
 2.7300, Fy  3.4598, G y  1,F  0.0012, G  0.0001.
0.0012 3.4598
 2.0086 0.0012
 0.0001
1
x 2  1.0043 
 1.0042,
 2.7300  0.0001
 2.0086 3.4598
y 2  1.7299 
 1.7296
 2.0086 3.4598
 2.7300
1
 2.7300
1
Next
The Main Menu
‫ا‬Previous
Download