Answers to exercises
Exercise 1
For example, we could define
f(x)={−10≤x<12112≤x≤1Exercise 2
As each successive [an,bn] has half the length of [an−1,bn−1], the interval [an,bn] is 12n times the size of [a0,b0]. Thus bn−anb−a=12n.
Exercise 3
Suppose that f(a0) is positive and f(b0) is negative. We will prove by induction that for all non-negative integers n, f(an) is positive and f(bn) is negative. The claim is clearly for n=0. Now suppose the claim holds for n=k, so f(ak)>0 and f(bk)<0; we will prove the claim for n=k+1, showing that f(ak+1)>0 and f(bk+1)<0.
Bisecting [ak,bk], we consider f(ak+bk2). If f(ak+bk2) is positive, then [ak+1,bk+1]=[ak+bk2,bk+1], so f(ak+1)>0 and f(bk+1)<0 as claimed. Alternatively, if f(ak+bk2)<0, then [ak+1,bk+1]=[ak,ak+bk2], so f(ak+1)>0 and f(bk+1)<0 again. Either way, f(ak+1)>0 and f(bk+1)<0. By induction, all f(an)>0 and all f(bn)<0.
One can prove, by a similar method, that if f(a0) is negative and f(b0) is positive, then for all non-negative integers n, f(an) is negative and f(bn) is positive.
Exercise 4
Let f(x)=lnx−1, so we solve f(x)=0 using the bisection method with [a0,b0]=[2,3]. We tabulate the calculation as follows.
Step n | an | Sign of f(an) | bn | Sign of f(bn) | Midpoint an+bn2 | Sign of f(an+bn2) |
0 | 2 | − | 3 | + | 52=2.5 | − |
1 | 52=2.5 | − | 3 | + | 114=2.75 | + |
2 | 52=2.5 | − | 114=2.75 | + | 218=2.625 | − |
3 | 218=2.625 | − | 114=2.75 | + | 4316=2.6875 | − |
4 | 4316=2.6875 | − | 114=2.75 | + | 8732 | + |
5 | 4316=2.6875 | − | 8732=2.71875 | + | 17364 | − |
6 | 17364=2.703125 | − | 8732=2.71875 | + |
Thus e∈[17364,8732]=[2.703125,.71875], and e has been calculated to within an accuracy of 8732−17364=164=0.015625<0.02.
Exercise 5
There is just one solution. Let f(x)=cosx−x. We note f(0)=1 and f(1)<0, so there is a solution in [0,1]. (One can check that for negative x, f(x)>0, and for x>1, f(x)<0.) Using the bisection method starting from [a0,b0]=[0,1], after 7 iterations we arrive at [a7,b7]=[4764,95128]=[0.734375,0.7421875], which has length 1/128<0.01. To 6 decimal places the solution is 0.739085.
Exercise 6
Letting f(x)=3x−1, we apply the bisection method to solve f(x)=0 starting from the interval [0,1].
Step n | an | Sign of f(an) | bn | Sign of f(bn) | Midpoint an+bn2 | Sign of f(an+bn2) |
0 | 0 | − | 1 | + | 12=0.5 | + |
1 | 0 | − | 12=0.5 | + | 14=0.25 | − |
2 | 14=0.25 | − | 12=0.5 | + | 38=0.375 | + |
3 | 14=0.25 | − | 38=0.375 | + | 516=0.3125 | − |
4 | 516=0.3125 | − | 38=0.375 | + | 1132=0.34375 | + |
5 | 516=0.3125 | − | 1132=0.34375 | + | 2164=0.328125 | − |
6 | 2164=0.328125 | − | 1132=0.34375 | + | 43128=0.3359375 | + |
7 | 2164=0.328125 | − | 43128=0.3359375 | + | 85256=0.33203125 | − |
8 | 85256=0.33203125 | − | 43128=0.3359375 | + | 171512=0.333984375 | + |
9 | 85256=0.33203125 | − | 171512=0.333984375 | + | 3411024=0.3330078125 | − |
10 | 3411024=0.3330078125 | − | 171512=0.333984375 | + |
So to within accuracy of 11024<0.001, 1/3 is approximated to lie in the interval [3411024,171512]=[0.3330078125,0.333984374].
We note that the signs of f(an+bn2) alternate +, −, +, −, etc. This corresponds to the fact that, in binary, 1/3 is written as 0.0101010101⋯=0.¯01. The alternating zeroes and ones correspond to the alternating between positive and negative signs. See the section "Bisection and binary numbers" above for details.
Exercise 7
In the example, we obtained an interval of [181128,9164]=[1.4140625,1.421875] of length 1128 approximating √2. The best guess for √2 is then the midpoint of this interval, 363256=1.41796875. It is within 1256=0.00390625 of a solution.
Exercise 8
The next intervals obtained after [a5,b5]=[258,10132]=[3.125,3.15625] are [a6,b6]=[3.140625,3.15625], [a7,b7]=[3.140625,3.1484375], [a8,b8]=[3.140625,3.14453125]. As both a8 and b8 round to 3.14 to two decimal places, we have approximated π∼3.14, to two decimal places.
Exercise 9
After [a7,b7]=1.4140625,1.421875] the bisection method yields [a8,b8]=[1.4140625,1.41796875], [a9,b9]=[1.4140625,1.416015625], [a10,b10]=[1.4140625,4.4150390625], [a11,b11]=[1.4140625,1.41455078125]. Both endpoints round to 1.41 to 2 decimal places, so √2∼1.41 to 2 decimal places.
Exercise 10
For part (a), since f(x)=x2−2 and f′(x)=2x, we have
xn+1=xn−f(xn)f′(xn)=xn−x2n−22xn=xn−12xn+1xn=xn2+1xn.Now substituting xn=yn+√2 gives yn+1+√2=yn+√22+1yn+√2 so
yn+1=yn+√22+1yn+√2−√2=(yn+√2)2+2−2√2(yn+√2)2(√2+yn)=y2n2(√2+yn).For part (b), let g(x)=x2+1x, so xn+1=g(xn). The function g is graphed below. When x>0, g(x)>0; and when x<0, g(x)<0. For x>0, the minimum value of g is given by g(√2)=√2; when x<0, the maximum value of g is given by g(−√2)=−√2. Hence if x>0 then g(x)≥√2; and if x<0 then g(x)≤−√2. So if x1>0 then x2=g(x1)≥√2, and all subsequent xn≥√2. Similarly, if x1<0 then all subsequent xn≤−√2.
For part (c), suppose 0<yn<10−k. Then yn+1=y2n2(√2+yn) is positive, and
yn+1=y2n2(√2+yn)<y2n2√2<10−2k2√2<10−2kas desired.For part (d), if xn differs from √2 by less than 10−k, for an integer k≥1, then xn is positive. By (b) above x1 is positive; and as n≥2 then xn>√2. So yn=xn−√2∈(0,10−k). By (c) above then yn+1∈(0,10−2k), so xn+1 differs from √2 by less than 10−2k.
Exercise 11
We apply Newton's method to f(x)=cosx−x. We know, by the intermediate value theorem, that there is a solution in [0,1], so we can start at x1=1. We obtain (to 9 decimal places) x1=0.750363868, x2=0.739112891, x3=0.739085133, x4=0.739085133.
After only 3 iterations we have the solution to 9 decaimal places. This is much better than the bisection method, which took 7 iterations to obtain 6 decimal places.
Exercise 12
We have f(x)=x(x−1)(x−2)=2x−3x2+x3 and f′(x)=2−6x+3x2=3[(x−1)2−13]. Substituting x=1±1√5, we obtain
f(x)=x(x−1)(x−2)=(1±1√5)(±1√5)(−1±1√5)=±15√5(12−(√5)2)=∓45√5f′(x)=3[(±1√5)2−13]=3[15−13]=−25x−f(x)f′(x)=1±1√5−∓45√5−25=1±1√5∓2√5=1∓1√5Thus if x1=1+1√5 then x2=1−1√5 and x3=1+1√5.
Exercise 13
The original interval has length b−a. Afer n iterations the interval has length b−a2n. The best guess is the midpoint of this interval; its distance from the solution can be no more than half the length of this interval. So this best guess is within b−a2n+1 of a solution.
Exercise 14
The first interval [a0,b0]=[−5,5] has length 10, so after n iterations, the interval [an,bn] has length 102n. To obtain an accuracy of 0.05 we require 102n<0.05, so 2n>100.05=200, hence n>log2(200)∼7.64, so 8 steps are required.
Exercise 15
The first interval has length b−a, so after n iterations, the interval [an,bn] has length b−a2n. To obtain an accuracy of ϵ, we require b−a2n<ϵ. Rearranging this gives 2n>b−aϵ, or n>log2(b−aϵ). So the bisection method will require at least log2(b−aϵ) steps.
Exercise 16
Given an interval [a,b]=[a0,b0], you could divide it into ten subintervals at the 9 points 110,210,…,910 from a to b, i.e. at the points a+110(b−a), a+210(b−a), …, a+910(b−a). The j'th point is a+j10(b−a)=10−j10a+j10b. You could then evaluate f at these 9 points. If f=0 at any of these points, we have an exact solution. Otherwise, as f changes sign between a and b, it must change sign on at least one of the sub-intervals; one such sub-interval is chosen as [a1,b1]. Repeating this method produces a sequence of nested intervals [a0,b0]⊃[a1,b1]⊃[a2,b2]⊃⋯, each of which contains a solution, and each of which is one tenth the size of the previous interval. If [a0,b0]=[0,1], then each successive [an,bn] determines a successive decimal digit of the solution.