2.1 The Bisection Method - University of Notre Damezxu2/acms40390F13/Lec-2.1.pdfΒ Β· Convergence β’...
Transcript of 2.1 The Bisection Method - University of Notre Damezxu2/acms40390F13/Lec-2.1.pdfΒ Β· Convergence β’...
2.1 The Bisection Method
1
Basic Idea
β’ Suppose function π(π₯) is continuous on [π, π], and π(π), π(π) have opposite signs.
β’ By the Intermediate Value Theorem (IVT), there must exist an π in (π, π) with π π = 0.
β’ Bisect (sub)intervals and apply IVT repeatedly.
2
β’ The sequence of intervals {(ππ , ππ)}π=1β contains
the desired root. 3
β’ Intervals containing the root: π1, π1 βπ2, π2 β π3, π3 β π4, π4 β¦
β’ After π steps, the interval ππ, ππ has the length:
ππ β ππ = 12
πβ1(π β π)
β’ Let ππ =ππ+ππ
2 be the mid-point of ππ, ππ . The
limit of sequence {ππ}π=1β is the root.
4
The Algorithm
5
INPUT a,b; tolerance TOL; maximum number of iterations N0.
OUTPUT solution p or message of failure.
STEP1 Set i = 1;
FA = f(a);
STEP2 While i β€ N0 do STEPs 3-6.
STEP3 Set p = a + (b-a)/2; // a good way of computing middle point
FP = f(p).
STEP4 IF FP = 0 or (b-a) < TOL then
OUTPUT (p);
STOP.
STEP5 Set i = i +1.
STEP6 If FPβFA > 0 then
Set a = p;
FA = FP.
else
set b = p;
STEP7 OUTPUT(βMethod failed after N0 iterationsβ);
STOP.
Matlab Code
function p=bisection(f,a,b,tol) while 1 p=(a+b)/2; if p-a<tol, break; end if f(a)*f(p)>0 a=p; else b=p; end end %while 1
6
Stopping Criteria
β’ Method 1: ππ β ππβ1 < π
β’ Method 2:
|ππβππβ1|
|ππ|< π, ππ β 0 or
π ππ < π
β’ None is perfect. Use a combination in real applications.
7
Convergence
β’ Theorem
Suppose function π(π₯) is continuous on [π, π], and π π β π π < 0. The Bisection method generates a sequence {ππ}π=1
β approximating a zero π of π(π₯) with
ππ β π = 12
ππ β π , when π β₯ 1
β’ Convergence rate
The sequence {ππ}π=1β converges to π with the
rate of convergence π( 12
π):
ππ = π + π( 12
π)
8