You are on page 1of 10

BISECTION METHOD

Root-Finding Problem
• Given computable f (x) ∈ C[a, b], problem is to find
for x ∈ [a, b] a solution to
f (x) = 0.
• Solution r with f (r) = 0 is root or zero of f .
• Maybe more than one solution; rearrangement some-
times needed: x2 = sin(x) + 0.5.
Bisection Algorithm
• Input: computable f (x) and [a, b], accuracy level .
• Initialization:
find [a1, b1] ⊂ [a, b], with f (a1)f (b1) < 0, set i = 1.
• Basic Bisection Algorithm:
1. Set ri = (ai + bi)/2;
2. If f (ai)f (ri) < 0, set bi+1 = ri, ai+1 = ai;
otherwise, set ai+1 = ri, bi+1 = bi;
3. If (bi+1 − ai+1)/2 > , set i = i + 1 and go to step 1
4. Stop with r ≈ (bi+1 + ai+1)/2.
Notes:
careful algorithm checks for f (ri) = 0, limits i;
other stopping conditions possible, e.g. |f (ri)| < .
2
x −sin(x)−.5

2.5

1.5

0.5

−0.5

−1 −0.5 0 0.5 1 1.5 2


x

2
BISECTION METHOD CONTINUED
Example : f (x) = x2 − sin(x) − 0.5, for [a, b] = [0, 2],
 = 10−3; note f (0)f (2) < 0.
i a r b (b-a)/2
1 0 1 2 1
2 1 1.5 2 0.5
3 1 1.25 1.5 0.25
4 1 1.125 1.25 0.125
5 1.125 1.1875 1.25 0.0625
6 1.1875 1.2188 1.25 0.03125
7 1.1875 1.2031 1.2188 0.015625
8 1.1875 1.1953 1.2031 0.0078125
9 1.1953 1.1992 1.2031 0.0039062
10 1.1953 1.1973 1.1992 0.0019531
11 1.1953 1.1963 1.1973 0.00097656
f (1.1963) = −0.0015836;
[a, b] = [−1, 0]?
1 -1 -0.5 0 0.5
2 -0.5 -0.25 0 0.25
3 -0.5 -0.375 -0.25 0.125
4 -0.375 -0.3125 -0.25 0.0625
5 -0.375 -0.34375 -0.3125 0.03125
6 -0.375 -0.35938 -0.34375 0.015625
7 -0.375 -0.36719 -0.35938 0.0078125
8 -0.375 -0.37109 -0.36719 0.0039062
9 -0.37109 -0.36914 -0.36719 0.0019531
10 -0.37109 -0.37012 -0.36914 0.00097656
f (−.37012) = −0.0012839.
3
BISECTION METHOD CONTINUED

Bisection Method Analysis


• Convergence:

• Steps needed for absolute error ?

• Summary: simple method with slow (linear) but


guarenteed convergence; size of f (rn) is not used.

4
FIXED POINT-ITERATION METHODS

Background
• Terminology: given g ∈ C[a, b] a fixed point r for
g(x) is a point where r = g(r).
• Relation to rootfinding:
given g(x), a fixed point for g(x) is root of
f (x) = x − g(x);
given f (x), a root of f (x) is a fixed point for
g(x) = x − f (x).
• Fixed points from graphs: a fixed point exists if the
graph y = x crosses the graph y = g(x).
Example: g(x) = cos(x):
y = x and y = cos(x)
3

−1

−2

−3
−3 −2 −1 0 1 2 3

5
FIXED-POINT METHODS CONTINUED

Finding Fixed Points with Fixed-Point Iteration


• Basic Fixed-Point Algorithm:
1. Initialize with guess r0 and i = 0
2. Set ri+1 = g(ri);
3. If |ri+1 − ri| > , set i = i + 1 and go to step 2
4. Stop with r ≈ ri+1.
Notes:
a) Termination (3) can be unreliable, other conditions?
E.g. |ri+1 −ri |
|ri+1 | < , or |ri+1 −ri |
max(|ri+1 |,θ) < , θ small.
b) Problem: to find good g(x)? Rearrange f (x) = 0?
• Example: Solve x3 − 2x = 5. Notice
f (x) = x3 − 2x − 5 has f (2) = −1, f (3) = 16, so
r ∈ [2, 3]. Some possible rearrangments:
a) x = (x3 − 5)/2 has [g(2), g(3)] = [3/2, 22/2];
b) x = (2/x + 5/x2) has [g(2), g(3)] → [11/9, 9/4];
c) x = (2x + 5)1/3 has [g(2), g(3)] = [2, 2.41].
Fixed-Point Iterations:
i a) b) c)
0 2 2 2
1 1.5 2.25 2.0801
2 -0.8125 1.8765 2.0924
3 -2.7682 2.4857 2.0942
4 -13.106 1.6139 2.0945
5 -1128.1 3.159 2.0945

6
2
y=x and y=2/x+5/x
7

1
1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3

y=x and y=(2*x+5)1/3


3

2.8

2.6

2.4

2.2

1.8

1.6

1.4

1.2

1
1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 2.8 3

7
FIXED-POINT METHODS CONTINUED
• Another example: x2 −sin(x) = 0.5, with root in [0, 2].
Some possible rearrangments:
a) x = (sin(x)
r
+ .5)/x has [g(0), g(2)] → [.7, ∞);
b) x = sin(x) + .5 has [g(0), g(2)] ⊂ [.70, 1.19].
Fixed-Point Iterations:
i a) b)
0 2 2
1 0.70465 1.1871
2 1.6288 1.1947
3 0.91986 1.1959
4 1.4084 1.1960495
5 1.0557 1.19607706
6 1.2979 1.196081273
7 1.1272 1.1960819169
Another solution in [−1, 0]?
[ga(−.5), ga(0)] ⊂ [−.05, ∞), [gb(−.5), gb(0)] ⊂ [0, .71].
c) x = sin−1(x2 − .5), has [g(−.5), g(0)] ⊂ [−.53, .53].
Fixed-Point Iterations:
i a) b) c)
0 -0.5 -0.5 -0.5
1 -0.04115 0.14344 -0.25268
2 -11.151 0.80184 -0.45132
3 -0.13343 1.1039 -0.30083
4 -2.7503 1.1802 -0.42191
5 -0.04312 1.1936 -0.32783
6 -10.596 1.1957 -0.40338
7 -0.13413 1.1960 -0.34404
8
FP METHODS ANALYSIS

Existence and Uniqueness of Fixed Points


• If g ∈ C[a, b] and g(x) ∈ [a, b] for x ∈ [a, b],
then g has at least one fixed point in [a, b].

• If, also, |g 0(x)| ≤ k < 1, ∀x ∈ (a, b),


then g(x) has a unique fixed point x ∈ [a, b].

• Example g(x) = cos(x) for x ∈ [0.5, 1];


cos(x) ∈ [.54, .88] ⇒ at least one fixed point;
|g 0(x)| = sin(x) < .842 ⇒ a unique fixed point.

9
FP METHODS ANALYSIS CONTINUED
Fixed Point Theorem: if g ∈ C[a, b], g(x) ∈ [a, b] and
|g 0(x)| ≤ k < 1 for x ∈ (a, b), then for any r0 ∈ [a, b],
rn = g(rn−1) converges to a unique fixed point r ∈ [a, b].
Proof: consider |rn − r| = |g(rn−1) − g(r)|

Corollary: given same conditions on g(x),


|rn − r| ≤ k n max{r0 − a, b − r0}, |rn − r| ≤ k n |r1−k
1 −r0 |
.
Proof: consider k|r − r0| = |(r1 − r0) + (r − r1)|

Notes:
a) Linear convergence: if ei is the error at each step i, and
ei+1
lim | | = S < 1,
i→∞ ei

the method has linear convergence with rate S.


b) FP convergence is usually linear, with |rn − r| ≈ Ck n;
if k > 1/2, the bisection method is better.
c) Estimating k? Let en = rn − r. Then for signed k,
rn−2 = r + en−2, rn−1 ≈ r + ken−2, rn ≈ r + k 2en−2,
so signed k is k ≈ (rn − rn−1)/(rn−1 − rn−2).
d) Taylor series analysis: from rn+1 = g(rn), near r
r + en+1 = g(r + en) = g(r) + eng 0(r) + e2ng 00(ξn)/2,
so en+1 ≈ eng 0(r), linear convergence with S = |g 0(r)|.

10

You might also like