Professional Documents
Culture Documents
The equation : x 4 3 x 3 7 x 2 15 x 18
has four roots : 2, 3, 3 , and 1 .
i.e., x 4 3 x 3 7 x 2 15 x 18 ( x 2)( x 3) 2 ( x 1)
Zeros of a Function
Let f(x) be a real-valued function of a real
variable. Any number r for which f(r)=0 is
called a zero of the function.
Examples:
2 and 3 are zeros of the function f(x) = (x-2)(x-3).
Graphical Interpretation of
Zeros
f(x)
Simple Zeros
f ( x) x 1 ( x 2)
f ( x) ( x 1) x 2 x x 2
Multiple Zeros
f ( x) x 1
f ( x) x 1 x 2 x 1
2
Multiple Zeros
f ( x) x 3
f ( x) x
has a zero with muliplicit y 3 at x 0
3
Facts
Numerical Methods
Many methods are available to solve nonlinear
equations:
Bisection Method
Newtons Method
Secant Method
Bracketing Methods
10
Open Methods
11
Convergence Notation
A sequence x1 , x2 ,..., xn ,... is said to converge to x if
to every 0 there exists N such that :
xn x n N
12
Introduction
Intermediate Value
Theorem
f(a)
b
f(b)
14
Examples
15
16
Bisection Method
Bisection Method
Assumptions:
Given an interval [a,b]
f(x) is continuous on [a,b]
f(a) and f(b) have opposite signs.
These assumptions ensure the existence of at
least one zero in the interval [a,b] and the
bisection method can be used to obtain a
smaller interval that contains the zero.
18
Bisection Algorithm
Assumptions:
f(a)
c b
a
f(b)
19
Bisection Method
b0
a0
a1
a2
20
Example
+
21
yes
b=c; v= w
is
no
u w <0
no
is
(b-a) /2<
yes
Stop
a=c; u= w
22
Example
Can you use Bisection method to find a zero of :
f ( x) x 3 3 x 1 in the interval [0,2]?
Answer:
f ( x) is continuous on [0,2]
and f(0) * f(2) (1)(3) 3 0
Assumption s are not satisfied
Bisection method can not be used
23
Example
Can you use Bisection method to find a zero of :
f ( x) x 3 3 x 1 in the interval [0,1]?
Answer:
f ( x) is continuous on [0,1]
and f(0) * f(1) (1)(-1) 1 0
Assumption s are satisfied
Bisection method can be used
24
25
26
Stopping Criteria
Two common stopping criteria
1.
2.
27
Stopping Criteria
cn :
r:
After n iterations :
0
b
x
error r - cn Ean n n
2
2
28
Example
29
30
Bisection Method
Initial Interval
f(a)=-0.3776
a =0.5
f(b) =0.2784
c= 0.7
b= 0.9
31
Bisection Method
-0.3776
0.5
-0.0648
0.7
-0.0648
0.7
0.1033
0.8
0.2784
0.9
0.2784
0.9
32
Bisection Method
-0.0648
0.7
0.8
-0.0648
0.70
0.0183
0.1033
0.75
-0.0235
0.725
0.0183
0.75
33
Summary
After 5 iterations:
Interval containing the root: [0.725, 0.75]
Best estimate of the root is 0.7375
| Error | < 0.0125
34
c=
0.7000
fc =
-0.0648
c=
0.8000
fc =
0.1033
c=
0.7500
fc =
0.0183
c=
0.7250
fc =
-0.0235
35
Example
Find the root of:
f(x) is continuous
f( 0 ) 1, f (1) 1 f (a ) f (b) 0
36
Example
c= (a+b)
Iteration
f(c)
(b-a)
2
0.5
-0.375
0.5
0.5
0.25
0.266
0.25
0.25
0.5
.375
-7.23E-3
0.125
0.25
0.375
0.3125
9.30E-2
0.0625
0.3125
0.375
0.34375
9.37E-3
0.03125
37
Bisection Method
Advantages
Disadvantage
Slow to converge
Newton-Raphson Method
(Also known as Newtons Method)
Given an initial guess of the root x0,
Newton-Raphson method uses
information about the function and its
derivative at that point to find a better
guess of the root.
Assumptions:
f(x) is continuous and the first derivative is
known
An initial guess x0 such that f(x0)0 is given
39
40
Newtons Method
Given f ( x), f ' ( x), x0
F ( X ) X * *3 3 * X * *2 1
FP( X ) 3 * X * *2 6 * X
Assumpution f ' ( x0 ) 0
______________________
for i 0: n
f ( xi )
xi 1 xi
f ' ( xi )
end
FORTRAN PROGRAM
X 4
DO 10 I 1, 5
X X F ( X ) / FP( X )
PRINT *, X
10
CONTINUE
STOP
END
42
Newtons Method
Given f ( x), f ' ( x), x0
F.m
function [ F ] F ( X )
F X ^3 3 * X ^ 2 1
FP.m
Assumpution f ' ( x0 ) 0
______________________
for i 0 : n
f ( xi )
xi 1 xi
f ' ( xi )
end
% MATLAB PROGRAM
X 4
for i 1 : 5
X X F ( X ) / FP( X )
end
43
Example
Find a zero of the function f(x) x 3 2 x 2 x 3 , x0 4
f ' (x) 3 x 2 4 x 1
Iteration 1 :
f ( x0 )
33
x1 x0
4
3
f ' ( x0 )
33
Iteration 2 :
f ( x1 )
9
x2 x1
3 2.4375
f ' ( x1 )
16
Iteration 3 :
f ( x2 )
2.0369
x3 x2
2.4375
2.2130
f ' ( x2 )
9.0742
44
Example
k (Iteration)
xk
f(xk)
f(xk)
xk+1
|xk+1 xk|
33
33
16
2.4375
0.5625
2.4375
2.0369
9.0742
2.2130
0.2245
2.2130
0.2564
6.8404
2.1756
0.0384
2.1756
0.0065
6.4969
2.1746
0.0010
45
46
Multiple Roots
f ( x) x 3
f ( x) x 1
f(x)has three
zeros at x 0
zeros at x -1
47
x0
x1
48
x0
x1=x3=x5
x0=x2=x4
F ( X )
f1
x
f1 ( x1 , x2 ,...)
1
f
f 2 ( x1 , x2 ,...) , F ' ( X ) 2
x1
f1
x2
f 2
x2
51
Example
y x 2 0.5 x
1
2x 1
1
F
, X0
, F'
2
x 5 xy y
2 x 5 y 5 x 1
0
52
x 2 5 xy y
1 1 1
X1
0 2 6
Iteration 2 :
1 1 1
0.5
2x 1
,
F
'
1
2
x
5
y
5
x
1
2
0.5 1.25
1 0.25
1
0.0625
1.5
F
,
F
'
1.25 7.25
0.25
1
1.25 1.5
X2
0.0625 1.2332
- 0.25 0.2126
53
Example
Try this
1
y x 2 1 x
2x 1
0
F 2
, X0
, F'
2
4 y 1
2x
0
x 2y y
54
Example
Solution
Iteration
0
1
2
3
4
5
_____________________________________________________________
Xk
0
0
1
0
0.6
0. 2
0.5287
0.1969
0.5257
0.1980
0.5257
0.1980
55
Secant Method
f ( x h) f ( x )
f ' ( x)
h
if xi and xi 1 are two initial points :
f ( xi ) f ( xi 1 )
f ' ( xi )
( xi xi 1 )
f ( xi )
xi 1 xi
f ( xi ) f ( xi 1 )
( xi xi 1 )
( xi xi 1 )
xi f ( xi )
f ( xi ) f ( xi 1 )
57
Secant Method
Assumption s :
Two initial points xi and xi 1
such that f ( xi ) f ( xi 1 )
New estimate (Secant Method) :
( xi xi 1 )
xi 1 xi f ( xi )
f ( xi ) f ( xi 1 )
58
Secant Method
f ( x) x 2 x 0.5
2
x0 0
x1 1
( xi xi 1 )
xi 1 xi f ( xi )
f ( xi ) f ( xi 1 )
59
( xi xi 1 )
;
f ( xi ) f ( xi 1 )
i i 1
NO
Yes
xi 1 xi
Stop
60
Example
50
40
30
20
10
0
-10
-20
-30
-40
-2
-1.5
-1
-0.5
0.5
1.5
61
Example
x(i)
f(x(i))
x(i+1)
|x(i+1)-x(i)|
-1.0000
1.0000
-1.1000
0.1000
-1.1000
0.0585
-1.1062
0. 0062
-1.1062
0.0102
-1.1052
0.0009
-1.1052
0.0001
-1.1052
0.0000
62
COMPARISON OF ROOT
FINDING METHODS
Advantages/disadvantages
Examples
63
Summary
Method
Pros
Cons
Bisection
- Slow
- Needs an interval [a,b]
containing the root, i.e.,
f(a)f(b)<0
Newton
- May diverge
- Needs derivative and an
initial guess x0 such that
f(x0) is nonzero
Secant
- May diverge
- Needs two initial points
guess x0, x1 such that
f(x0)- f(x1) is nonzero
64
Example
Use Secant method to find the root of :
f ( x) x 6 x 1
Two initial points x0 1 and x1 1.5
( xi xi 1 )
xi 1 xi f ( xi )
f ( xi ) f ( xi 1 )
65
Solution
_______________________________
k
xk
f(xk)
_______________________________
0
1.0000 -1.0000
1
1.5000 8.8906
2
1.0506 -0.7062
3
1.0836 -0.4645
4
1.1472 0.1321
5
1.1331 -0.0165
6
1.1347 -0.0005
66
Example
Use Newton' s Method to find a root of :
f ( x) x 3 x 1
Use the initial point : x0 1.
Stop after three iterations , or
if xk 1 xk 0.001, or
if
f ( xk ) 0.0001.
67
xk
f(xk)
f(xk)
ERROR
______________________________________
0
1.0000 -1.0000 2.0000
1
1.5000 0.8750 5.7500 0.1522
2
1.3478 0.1007 4.4499 0.0226
3
1.3252 0.0021 4.2685 0.0005
4
1.3247 0.0000 4.2646 0.0000
5
1.3247 0.0000 4.2646 0.0000
68
Example
Use Newton' s Method to find a root of :
f ( x) e x x
Use the initial point : x0 1.
Stop after three iterations , or
if xk 1 xk 0.001, or
if
f ( xk ) 0.0001.
69
Example
Use Newton' s Method to find a root of :
f ( x ) e x x,
xk
f ( xk )
f ' ( x ) e x 1
f ' ( xk )
f ( xk )
f ' ( xk )
70
Example
Estimates of the root of:
0.60000000000000
0.74401731944598
0.73909047688624
0.73908513322147
0.73908513321516
x-cos(x)=0.
Initial guess
1
4
10
14
correct
correct
correct
correct
digit
digits
digits
digits
71
Example
In estimating the root of: x-cos(x)=0, to
get more than 13 correct digits:
72
Numerical Integration
73
Integration
Indefinite Integrals
2
x
x dx 2 c
Indefinite Integrals of a
function are functions that
differ from each other by a
constant.
Definite Integrals
1
2 1
x
0 xdx 2
74
f(x)
Area
a
b
a
f(x)dx
b
75
Partition P a x0 x1 x2 ... xn b
Define
mi min f ( x) : xi x xi 1
M i max f ( x) : xi x xi 1
f(x)
n 1
Lower sum L( f , P ) mi xi 1 xi
i 0
n 1
Upper sum U ( f , P ) M i xi 1 xi
i 0
x0 x1 x2 x3
a
b
76
Lower sum L( f , P ) mi xi 1 xi
i 0
n 1
Upper sum U ( f , P ) M i xi 1 xi
f(x)
i 0
L U
2
U L
Error
2
x0 x1 x2 x3
a
b
77
Example
1
0
x 2 dx
1 2 3
Partition : P 0, , , ,1
4 4 4
n 4 (four equal intervals )
1
1
9
m0 0,
m1 , m2 , m3
16
4
16
1
1
9
M 0 , M1 , M 2 , M 3 1
16
4
16
1
xi 1 xi
4
for i 0,1, 2, 3
1
4
1
2
3
4
78
Example
n 1
Lower sum L( f , P ) mi xi 1 xi
i 0
L( f , P)
1
1 1 9 14
0
4
16 4 16 64
n 1
Upper sum U ( f , P ) M i xi 1 xi
i 0
U ( f , P)
1 1 1 9
30
4 16 4 16 64
1 30 14 11
Estimate of the integral
2 64 64 32
1 30 14 1
Error
2 64 64 8
1
4
1
2
3
4
79
80
Newton-Cotes Methods
In Newton-Cote Methods, the function
is approximated by a polynomial of
order n.
Computing the integral of a
polynomial is easy.
f ( x)dx
a
x
...
a
x
dx
0
1
n
(b 2 a 2 )
(b n 1 a n 1 )
f ( x)dx a0 (b a ) a1
... an
2
n 1
81
Newton-Cotes Methods
f ( x)dx
b
a
a0 a1x dx
82
Trapezoid Method
b
f (b) f (a )
f (a )
( x a)
ba
f(x)
I f ( x)dx
a
f (b) f (a )
I f (a)
( x a) dx
a
ba
f (b) f (a )
f (a) a
x
ba
a
2 b
f (b) f (a ) x
ba
2
a
f (b) f (a )
b a
2
83
Trapezoid Method
Derivation-One Interval
f (b) f (a)
I f ( x)dx f (a )
( x a ) dx
a
a
ba
b
f (b) f (a ) f (b) f (a )
I f (a) a
x dx
a
ba
ba
2 b
f (b) f (a )
f (b) f (a ) x
f (a) a
x
ba
ba
2
f (b) f (a )
f (b) f (a ) 2
f (a) a
(b a 2 )
b a
ba
2(b a )
f (b) f (a )
b a
2
84
Trapezoid Method
f(x)
f (b)
f (a)
ba
f (a) f (b)
Area
2
b
85
Trapezoid Method
Multiple Application Rule
f(x)
f ( x2 ) f ( x1 )
x2 x1
Area
2
x1
x2
x3
b
86
Trapezoid Method
General Formula and Special Case
If the interval is divided into n segments (not necessaril y equal)
a x0 x1 x2 ... xn b
n 1
1
f ( x)dx xi 1 xi f ( xi 1 ) f ( xi )
i 0 2
b
a
b
a
n 1
1
f ( x)dx h f ( x0 ) f ( xn ) f ( xi )
i 1
2
87
Example
Given a tabulated
values of the velocity of
an object.
Time (s)
0.0
1.0
2.0
3.0
10
12
14
Obtain an estimate of
the distance traveled in
the interval [0,3].
Distance = integral of the velocity
Distance
V (t ) dt
88
Example 1
The interval is divided
into 3 subinterva ls
Base points are 0,1,2,3
Trapezoid
Time (s)
0.0
1.0
2.0
3.0
Velocity
(m/s)
0.0
10
12
14
Method
h xi 1 xi 1
n 1
T h
i 1
f ( xi ) f ( x0 ) f ( xn )
2
89
Example
sin( x )dx,
0
1
find h so that error 105
2
ba 2
h max f ' ' ( x )
12
x[ a ,b ]
b ; a 0; f ' ( x ) cos( x ); f ' ' ( x ) sin( x )
2 1
f ' ' ( x ) 1 Error h 105
12
2
2 6
h 105 h 0.00437
(b a )
719 intervals
h
0.00437
Error
90
Example
x
1.0
1.5
2.0
2.5
3.0
f(x)
2.1
3.2
3.4
2.8
2.7
3
1
f ( x)dx
n 1
1
Trapezoid T ( f , P ) xi 1 xi f ( xi 1 ) f ( xi )
i 0 2
Special Case : h xi 1 xi for all i,
n 1
T ( f , P) h
i 1
f ( xi ) f ( x0 ) f ( xn )
2
91
Example
x
1.0
1.5
2.0
2.5
3.0
f(x)
2.1
3.2
3.4
2.8
2.7
n 1
i 1
f ( x)dx h
1
f ( xi ) f ( x0 ) f ( xn )
2
5.9
92
Recursive Trapezoid
Method
Estimate based on one interval :
f(x)
h ba
ba
f ( a ) f (b)
R (0,0)
2
ah
93
Recursive Trapezoid
Method
Estimate based on 2 intervals :
h
f(x)
ba
2
ba
1
R (1,0)
f
(
a
h
)
f
(
a
)
f
(
b
)
2
2
R (1,0)
1
R(0,0) h f (a h )
2
ah
a 2h
Recursive Trapezoid
Method
f(x)
ba
h
4
R (2,0)
R (2,0)
ba
f (a h) f (a 2h) f (a 3h)
4
1
f (a ) f (b)
2
1
R(1,0) h f (a h) f (a 3h)
2
a 2h
a 4h
ba
f (a) f (b)
R (0,0)
2
1
R(n,0) R (n 1,0) h
2
2 ( n1)
k 1
f a (2k 1)h
ba
h n
2
96
Recursive Trapezoid
Method
h b a,
h
ba
,
2
ba
f (a) f (b)
2
1
1
R (0,0)
ba
h 2 ,
2
R(2,0) R (1,0) h
2
ba
h 3 ,
2
1
R (3,0) R (2,0) h
2
f a (2k 1)h
k 1
22
k 1
f a (2k 1)h
..................
ba
h n ,
2
1
R(n,0) R (n 1,0) h
2
2 ( n1)
k 1
f a (2k 1)h
97
/2
n h
R(n,0)
(b-a)=/2
(/4)[sin(0) + sin(/2)]=0.785398
(b-a)/2=/4
(b-a)/4=/8
(b-a)/8=/16
R(2,0)/2 + (/16)[sin(/16)+sin(3/16)+sin(5/16)+
sin(7/16)] = 0.996785
98
Advantages of Recursive
Trapezoid
Recursive Trapezoid:
Gives the same answer as the standard
Trapezoid method.
Makes use of the available information to
reduce the computation time.
Useful if the number of iterations is not
known in advance.
99