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 be continuous on the interval between and with , let , and let . Write as in line L3 (in exact arithmetic take ). Line numbers refer to the pseudocode on the main page.
Theorem 1 (invariant). At every test of line L3: , lie in , and are nonzero with opposite signs, and, after the first step, lies in outside the open interval between and , on the side of , with nonzero and of the sign of . So a root lies strictly between and , and a return at L3 with gives .
Proof. L1 returns if vanishes at an end, so at the first test . Suppose the claims hold and the pass does not return. Then and L4 gives , so is strictly between and , at distance at least from each. If , the next L3 returns (the implementation returns at once). Otherwise L6 and L7 replace the end of the same sign as by : if has the sign of , the pair becomes and $c = $ old ; else the pair becomes and $c = $ old . In both cases has opposite signs at the new and new , the discarded end has the sign of , and lies beyond as seen from the new , because was between the old ends. The intermediate value theorem gives a root strictly between and , and the error bound at the return is the stopping condition rewritten.
Theorem 2 (termination). If , the loop returns after at most steps. For any it stops after at most steps.
Proof. By the proof of Theorem 1 the new bracket is the part of the old one on one side of , of length at most . Starting from width , after steps without return the width is at most , and it is positive, so . The cap bounds the loop in all cases.
Theorem 3 (the acceptance test). Let , , be distinct, with beyond as seen from , and let , , be values with , of the sign of and . Put and . Let be the quadratic with , , . Then the test and holds if and only if and has no zero on the closed interval between and . In that case is strictly monotone there and lies strictly between and .
Proof. By the position of , . Since and have the sign of , , and since . If , then and the test fails, so both sides of the equivalence are false. Take . Change variables to and . Then is a quadratic with , and , so with . The derivative is affine in , so it has no zero on if and only if and are nonzero with the same sign; their sum is 2, so the sign is positive. Since ,
so if and only if , and if and only if . This is the equivalence, as is a nonzero multiple of . Under the test is strictly increasing on . The value lies strictly between and , that is , and maps onto . So lies strictly between and .
When the ratio equals 1, the test fails, and L10 bisects, so the IQI formula, which divides by , is never evaluated then.
The test is sufficient for monotonicity of between and , which is all the step needs, but not necessary: in a random experiment with , , and random values of the right signs, 5569 of 20000 cases passed the test and all of them gave a monotone on , while 1372 more cases had monotone there but failed the test, because turned back between and .
Remark (rate). In line L9, , the inverse quadratic interpolation point; the L4 clamp changes it only when it lies within 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 near a simple root with , that iteration has order , the real root of (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 , and carry rounding errors, so Theorem 3 holds only up to rounding. Theorems 1 and 2 do not depend on it: whatever L9 computes, L4 clamps it into , and the computed stays strictly inside since exceeds the rounding error of . If is NaN, min and max in Python return a clamp end, so the step is still inside.