Você está na página 1de 25

Introduction

Problem given a f(x) real-valued find a root v


for function s.t f(r) = 0
1. f(x) x 2 5x 6 0
Root might not be unique
2. f(x) x 2 4x 10 0
No roots
3. f(x) x 3 cosx e x x 1
Very hard to find exactly solution
Numerical approximation

Given f(x) continuous function !!


Basic idea (iteration)!!
I. Bisection method
(Interval Halving)
Numerical solution of Non-linear equation
Bit Independent

To find a solution f(x) = 0 given the


continuous function on the interval [a,b],
where f(a) and f(b) have opposite sign
[a,b]

a+b/2

[a,c] [c,b]

f(a)f(c) < 0

yes no

[a,b] [a,c] [a,b][c,b]


Find a, b s.t f (a) f (b) 0
r a, b s.t f (r ) 0
ab
let c compute f (c)
2
if f (c) . f (a) 0, than r [a, c]
if f (c) . f (b) 0 , than r [a, c]
if f (c) 0 ; r r , In general it doesn' t happend !!
Repeat this until Stop criteria is met
Stop Criteria
6
1. f (c) tol (10 )
2. b a tol
3. Max iter is met
4. Combination of the above
Convergence analysis

Yes always Robost(sta ble)


Speed of convergenc e consider
a 0 b0
a 0 , b 0 c0 ; let r (a 0 , b 0 )
2
b0 c0
Error 0 r c 0
2
a n bn
Denote a n , b n cn
2
at iter n
bn a n b0 a 0 1
n r cn . n
2 2 2
Given tolerance , find min of iter
b0 a 0 1
n . n
2 2
b0 a 0 1
n . n
2 2
b0 a 0 1
. 2 n

2
b0 a 0
ln nln2
2
ln b 0 a 0 - ln(2. )
n
ln2
+&-
Robost (very nice and very stable)
Each time iter only cut half of error
Many iteration 50 ~ 60
Very slow
a b 1
6
tol 10
Examples
1. Given that f ( x) x 3 2 x 2 0
has a root between 0 and 1. Find the root to
1 decimal place (1 dp), using the bisection
method
2. f(x) 2x 4 3x 8 0 ; 1 & 1.5
3. f(x) e x 5x 2 interval 0, 1 dan 0.00001
II. Fixed Point Iteration : x = g(x) method

Want to solve N.L f(x) = 0


Rewrite into x = g(x)
Always to this x = x f(x) = g(x)
Idea the root r = g(x), r : fixed point
Intial guess x1, compute g(x0)
Hopefully, x1 = g(x0) is closer to r
Algorithm
Choose x0
Do iteration until stop criteria
- xk+1 = g(xk)
- End
Stop criteria
- x k 1 x1 tol, g(x k ) g k tol
- Max iteration is met
- Combination
Convergence analysis
Let r be a root, i.e r = g(r)
Iteration xk+1 = g(xk )

Error e k x k r g(x k ) g(r)


g' ( ) x k r : kasai
b/t x k , r g' ( ) . e k
Observation
if g ' 1 ek 1 ek ; Convergence

if g ' ( ) 1 ek 1 ek ; Divergen
Convergence Condition
There exist an interval
I = [r c, r + c] for some c > 0, s.t |g(x)| < 1
On I, and x0 I
Back to example
1 g(x) cos(x), g' (x) sin(x)
[0.5 , 1] m max g' (x) sin(1) 1
2 g(x) e 2x (x 1 ) x
g' (x) 2e 2x (x 1) e 2x 1
g' (1) e 2 1 1 Divergen
Pseudo Code
r = fixed point(g, x, tol, nmax)
r = g(x) ; nit = 1;
while(abs r g(r) > tol and nit < nmax)
r = g(r),
nit = nit + 1;
end
end
How many iteration to achieve !!
Q : Assume convergence given x0 , find minimum iteration
needed
A :Assume g' (x) m 1 on [r c, r c]
e k 1 m . e k induction steps
e k m . e k 1 m . me k 2 . . . . m k e 0 ; e 0 unknown
e 0 r x 0 r x1 x1 x 0 r x1 x1 x 0
m.e 0 x1 x 0 e1 m.e 0

x1 x 0
(1 m)e 0 x1 x 0 e0
1 m
Plug in :
x1 x 0
ek m . k

1 m
Given tolerance (e) i.e e k e
x1 x 0
m k
e
1 m
e1 m e(1 m)
m k
k(ln m) ln

x1 x 0 x
1 x 0
e(1 m)
k(ln m) ln

x1 x 0

e(1 m)
k ln
ln m
x
1 x 0
Ex.3
x = g(x) = cos(x) |g(x)| = sin(x)
x0 = 1 ; r 0.7 I = [0,1]
M = max |sin(x)| = sin(1) = 0.8415
0 x 1
X1 = cos(1) = 0.5403
Tol e = 10-5
By formula k 73 (worst possible scenario)
Real time simulation (iteration = 25)

Você também pode gostar