Algorithm Search⌘K

Proofs: Bisection method

These are the human proofs of Bisection method, at full length.

Bisection returns a point within the tolerance of a root, after a known number of steps full

This proof shows: correctness, termination, evaluations.worst.

We work in exact real arithmetic. Let ff be continuous on [a0,b0][a_0, b_0] with a0<b0a_0 < b_0 and f(a0)f(b0)<0f(a_0) f(b_0) < 0, and let δ>0\delta > 0. Write ak,bka_k, b_k for the values of a,ba, b after kk passes of the loop of lines L4 to L11, and w=b0−a0w = b_0 - a_0. In exact arithmetic the midpoint c=a+(b−a)/2c = a + (b - a)/2 lies strictly between aa and bb, so line L6 never returns.

Invariant (B). After kk passes that did not return: ak<bka_k < b_k; fa=f(ak)fa = f(a_k) and fb=f(bk)fb = f(b_k); both are nonzero and have opposite signs; and bk−ak=w/2kb_k - a_k = w / 2^k.

Initialization. For k=0k = 0, line L1 sets fa=f(a0)fa = f(a_0) and fb=f(b0)fb = f(b_0). Line L2 returns if one is zero, and line L3 returns if they have the same sign. Otherwise (B) holds with b0−a0=wb_0 - a_0 = w.

Maintenance. Assume (B) after kk passes and that pass k+1k+1 does not return. Line L5 sets c=(ak+bk)/2c = (a_k + b_k)/2, so ak<c<bka_k < c < b_k and c−ak=bk−c=(bk−ak)/2=w/2k+1c - a_k = b_k - c = (b_k - a_k)/2 = w/2^{k+1}. Line L8 did not return, so f(c)≠0f(c) \ne 0. The signs of fafa and fbfb differ, and f(c)f(c) has one of the two signs. If f(c)f(c) has the sign of fafa, line L9 sets ak+1=ca_{k+1} = c, fa=f(c)fa = f(c), and bk+1=bkb_{k+1} = b_k. Then f(ak+1)f(a_{k+1}) has the sign of f(ak)f(a_k), which is opposite to the sign of f(bk+1)f(b_{k+1}). Otherwise f(c)f(c) has the sign of fbfb, and line L10 sets bk+1=cb_{k+1} = c, with the symmetric argument. In both cases the new width is w/2k+1w/2^{k+1}, so (B) holds after k+1k + 1 passes.

Lemma (a root in the bracket). If (B) holds, then [ak,bk][a_k, b_k] holds a root of ff.

Proof. ff is continuous on [ak,bk]⊆[a0,b0][a_k, b_k] \subseteq [a_0, b_0], and f(ak)f(a_k) and f(bk)f(b_k) have opposite signs. By the intermediate value theorem there is x∗∈(ak,bk)x^* \in (a_k, b_k) with f(x∗)=0f(x^*) = 0. □\square

Theorem. Let N=max⁡(0,⌈log⁡2(w/(2δ))⌉)N = \max(0, \lceil \log_2(w/(2\delta)) \rceil). If kmax⁡≥Nk_{\max} \ge N, then BISECT returns a point x^\hat x such that some root x∗x^* of ff in [a0,b0][a_0, b_0] has ∣x^−x∗∣≤δ|\hat x - x^*| \le \delta. It makes at most NN passes and at most N+2N + 2 evaluations of ff. If no end and no midpoint is a root and w>2δw > 2\delta, it makes exactly NN passes and N+2N + 2 evaluations.

Proof. There are four ways to return.

  1. Line L2 returns a0a_0 or b0b_0, which is a root, so the error is 0.
  2. Line L8 returns a midpoint cc with f(c)=0f(c) = 0, a root in [a0,b0][a_0, b_0].
  3. Line L11 returns the midpoint mm of [ak,bk][a_k, b_k] when bk−ak≤2δb_k - a_k \le 2\delta. By the lemma there is a root x∗∈[ak,bk]x^* \in [a_k, b_k], and each point of this interval is within (bk−ak)/2≤δ(b_k - a_k)/2 \le \delta of mm.
  4. Line L12 is reached only if kmax⁡k_{\max} passes end without a return.

We show that case 4 does not happen when kmax⁡≥Nk_{\max} \ge N. If w≤2δw \le 2\delta we have N=0N = 0. Then the first pass either returns at line L8, or reaches line L11 with width w/2≤2δw/2 \le 2\delta and returns. If w>2δw > 2\delta, then N≥1N \ge 1 is the least integer with w/2N≤2δw/2^N \le 2\delta. By (B) the width after kk passes is w/2kw/2^k, which is greater than 2δ2\delta for k<Nk < N and at most 2δ2\delta for k=Nk = N. So the test of line L11 fails in passes 1 to N−1N - 1 and holds in pass NN, unless line L8 returned earlier. This proves the bound of NN passes. Each pass evaluates ff once (line L7), and line L1 evaluates it twice, which gives N+2N + 2. When no end and no midpoint is a root, no early return happens, so the counts are exact. ■\blacksquare

The error of each midpoint. After kk passes the midpoint mkm_k of [ak,bk][a_k, b_k] satisfies ∣mk−x∗∣≤w/2k+1|m_k - x^*| \le w/2^{k+1} for a root x∗x^* in the bracket, by (B) and the lemma. This bound halves at each pass. The error ∣mk−x∗∣|m_k - x^*| itself need not decrease: it can grow from one step to the next when x∗x^* is close to mkm_k and far from mk+1m_{k+1}.

Floating point. In floating point, the computed midpoint cc satisfies a≤c≤ba \le c \le b when a+(b−a)/2a + (b - a)/2 is computed with b−ab - a finite and rounding to nearest, because rounding is monotone. Line L6 returns when cc equals an end, which happens when aa and bb are adjacent numbers. A pass that does not return at line L6 replaces one end by a number strictly between aa and bb, so the number of floating-point numbers in [a,b][a, b] falls by at least one. That number is finite, so the loop ends after finitely many passes for every δ≥0\delta \ge 0, even when the test of line L11 never holds. The invariant (B) then holds for the computed values f^\hat f in place of ff, except for the exact width. If ∣f^−f∣≤εf|\hat f - f| \le \varepsilon_f on the bracket and both ∣f(ak)∣|f(a_k)| and ∣f(bk)∣|f(b_k)| exceed εf\varepsilon_f, the computed signs are the true signs, and the lemma gives a true root in [ak,bk][a_k, b_k]. Otherwise an end of the final bracket lies in the set {x:∣f(x)∣≤εf}\{x : |f(x)| \le \varepsilon_f\}.

Back to Bisection method