Algorithm Search⌘K

Proofs: Chandrupatla's method

These are the human proofs of Chandrupatla's method, at full length.

Correctness, termination and the acceptance test of Chandrupatla's method full

This proof shows: correctness, termination, convergence-rate.

Let ff be continuous on the interval II between x0x_0 and x1x_1 with f(x0)f(x1)≤0f(x_0) f(x_1) \le 0, let w=∣x1−x0∣w = |x_1 - x_0|, and let δ≥0\delta \ge 0. Write tl=(4u∣xm∣+δ/2)/∣b−a∣t_l = (4u|x_m| + \delta/2)/|b - a| as in line L3 (in exact arithmetic take u=0u = 0). Line numbers refer to the pseudocode on the main page.

Theorem 1 (invariant). At every test of line L3: aa, bb lie in II, f(a)f(a) and f(b)f(b) are nonzero with opposite signs, and, after the first step, cc lies in II outside the open interval between aa and bb, on the side of aa, with f(c)f(c) nonzero and of the sign of f(a)f(a). So a root lies strictly between aa and bb, and a return at L3 with f(xm)≠0f(x_m) \ne 0 gives ∣xm−x∗∣<∣b−a∣≤2(4u∣xm∣+δ/2)=δ+8u∣xm∣|x_m - x^*| < |b - a| \le 2(4u|x_m| + \delta/2) = \delta + 8u|x_m|.

Proof. L1 returns if ff vanishes at an end, so at the first test f(a)f(b)<0f(a) f(b) < 0. Suppose the claims hold and the pass does not return. Then tl<1/2t_l < 1/2 and L4 gives t∈[tl,1−tl]⊂(0,1)t \in [t_l, 1 - t_l] \subset (0, 1), so x=a+t(b−a)x = a + t(b - a) is strictly between aa and bb, at distance at least tl∣b−a∣t_l |b - a| from each. If f(x)=0f(x) = 0, the next L3 returns xx (the implementation returns at once). Otherwise L6 and L7 replace the end of the same sign as f(x)f(x) by xx: if f(x)f(x) has the sign of f(a)f(a), the pair becomes (x,b)(x, b) and $c = $ old aa; else the pair becomes (x,old a)(x, \text{old } a) and $c = $ old bb. In both cases ff has opposite signs at the new a=xa = x and new bb, the discarded end cc has the sign of f(x)f(x), and cc lies beyond xx as seen from the new bb, because xx was between the old ends. The intermediate value theorem gives a root strictly between aa and bb, and the error bound at the return is the stopping condition tl≥1/2t_l \ge 1/2 rewritten. □\square

Theorem 2 (termination). If δ>0\delta > 0, the loop returns after at most ⌈2w/δ⌉\lceil 2w/\delta \rceil steps. For any δ≥0\delta \ge 0 it stops after at most KK steps.

Proof. By the proof of Theorem 1 the new bracket is the part of the old one on one side of xx, of length at most (1−tl)∣b−a∣=∣b−a∣−4u∣xm∣−δ/2≤∣b−a∣−δ/2(1 - t_l)|b - a| = |b - a| - 4u|x_m| - \delta/2 \le |b - a| - \delta/2. Starting from width ww, after nn steps without return the width is at most w−nδ/2w - n\delta/2, and it is positive, so n<2w/δn < 2w/\delta. The cap KK bounds the loop in all cases. □\square

Theorem 3 (the acceptance test). Let aa, bb, cc be distinct, with cc beyond aa as seen from bb, and let faf_a, fbf_b, fcf_c be values with fafb<0f_a f_b < 0, fcf_c of the sign of faf_a and fc≠faf_c \ne f_a. Put ξ=(a−b)/(c−b)\xi = (a - b)/(c - b) and Φ=(fa−fb)/(fc−fb)\Phi = (f_a - f_b)/(f_c - f_b). Let PP be the quadratic with P(fa)=aP(f_a) = a, P(fb)=bP(f_b) = b, P(fc)=cP(f_c) = c. Then the test Φ2<ξ\Phi^2 < \xi and (1−Φ)2<1−ξ(1 - \Phi)^2 < 1 - \xi holds if and only if Φ<1\Phi < 1 and P′P' has no zero on the closed interval between fbf_b and fcf_c. In that case PP is strictly monotone there and P(0)P(0) lies strictly between aa and bb.

Proof. By the position of cc, ξ∈(0,1)\xi \in (0, 1). Since fa−fbf_a - f_b and fc−fbf_c - f_b have the sign of faf_a, Φ>0\Phi > 0, and Φ≠1\Phi \ne 1 since fc≠faf_c \ne f_a. If Φ>1\Phi > 1, then Φ2>1>ξ\Phi^2 > 1 > \xi and the test fails, so both sides of the equivalence are false. Take Φ∈(0,1)\Phi \in (0, 1). Change variables to v=(y−fb)/(fc−fb)v = (y - f_b)/(f_c - f_b) and P=b+(c−b)W(v)P = b + (c - b) W(v). Then WW is a quadratic with W(0)=0W(0) = 0, W(1)=1W(1) = 1 and W(Φ)=ξW(\Phi) = \xi, so W(v)=v+κv(v−1)W(v) = v + \kappa v(v - 1) with κ=(ξ−Φ)/(Φ(Φ−1))\kappa = (\xi - \Phi)/(\Phi(\Phi - 1)). The derivative W′(v)=1+κ(2v−1)W'(v) = 1 + \kappa(2v - 1) is affine in vv, so it has no zero on [0,1][0, 1] if and only if W′(0)W'(0) and W′(1)W'(1) are nonzero with the same sign; their sum is 2, so the sign is positive. Since Φ(Φ−1)<0\Phi(\Phi - 1) < 0,

W′(0)=1−κ=Φ2−ξΦ(Φ−1),W′(1)=1+κ=Φ2−2Φ+ξΦ(Φ−1),W'(0) = 1 - \kappa = \frac{\Phi^2 - \xi}{\Phi(\Phi - 1)}, \qquad W'(1) = 1 + \kappa = \frac{\Phi^2 - 2\Phi + \xi}{\Phi(\Phi - 1)},

so W′(0)>0W'(0) > 0 if and only if Φ2<ξ\Phi^2 < \xi, and W′(1)>0W'(1) > 0 if and only if (1−Φ)2<1−ξ(1 - \Phi)^2 < 1 - \xi. This is the equivalence, as P′P' is a nonzero multiple of W′W'. Under the test WW is strictly increasing on [0,1][0, 1]. The value y=0y = 0 lies strictly between fbf_b and faf_a, that is v0=−fb/(fc−fb)∈(0,Φ)v_0 = -f_b/(f_c - f_b) \in (0, \Phi), and WW maps (0,Φ)(0, \Phi) onto (0,ξ)(0, \xi). So P(0)=b+(c−b)W(v0)P(0) = b + (c - b)W(v_0) lies strictly between bb and b+(c−b)ξ=ab + (c - b)\xi = a. □\square

When fc=faf_c = f_a the ratio Φ\Phi equals 1, the test fails, and L10 bisects, so the IQI formula, which divides by fc−faf_c - f_a, is never evaluated then.

The test is sufficient for monotonicity of PP between fbf_b and faf_a, which is all the step needs, but not necessary: in a random experiment with a=0a = 0, b=1b = 1, c∈(−3,0)c \in (-3, 0) and random values of the right signs, 5569 of 20000 cases passed the test and all of them gave a monotone PP on [fb,fa][f_b, f_a], while 1372 more cases had PP monotone there but failed the test, because PP turned back between faf_a and fcf_c.

Remark (rate). In line L9, a+t(b−a)=P(0)a + t(b - a) = P(0), the inverse quadratic interpolation point; the L4 clamp changes it only when it lies within tl∣b−a∣t_l|b - a| of an end. So when the test accepts every step from some point on and the clamp is inactive, the iterates are those of inverse quadratic interpolation. For f∈C3f \in C^3 near a simple root with f′(x∗)≠0f'(x^*) \ne 0, that iteration has order q≈1.839q \approx 1.839, the real root of q3=q2+q+1q^3 = q^2 + q + 1 (Brent 1973, Chapter 3). This is a local statement. That the test eventually accepts every step is not proved here; it is observed on the smooth examples of the main page, where every step after the first was accepted.

In floating point the computed ξ\xi, Φ\Phi and tt carry rounding errors, so Theorem 3 holds only up to rounding. Theorems 1 and 2 do not depend on it: whatever tt L9 computes, L4 clamps it into [tl,1−tl][t_l, 1 - t_l], and the computed xx stays strictly inside since tl∣b−a∣≥4u∣xm∣t_l|b - a| \ge 4u|x_m| exceeds the rounding error of a+t(b−a)a + t(b - a). If tt is NaN, min and max in Python return a clamp end, so the step is still inside.

Back to Chandrupatla's method