(ℝ → ℝ) → ℝ → ℝ × ℝ → ℝ × ℝ
One bisection step toward f x = C on the bracket I = (a, b): evaluate f at the midpoint m, keep (m, b) if f m < C and (a, m) otherwise.
The bisection method looks for a solution of f x = C on a bracket [lo, hi]: evaluate f at the midpoint, keep the half whose endpoints still straddle C, repeat.
Bisection only ever asks whether f m < C. So the hypothesis it needs is that σ is the threshold of f against C on the bracket: f x < C ↔ x < σ for x ∈ [lo, hi]. The estimates converge to that threshold. A strictly increasing f with f σ = C has this property (StrictMonoOn.lt_iff_lt), and then the limit is the solution. The property itself asks for neither continuity nor strictness, and in general σ need not solve f σ = C. At a threshold, a step maps the trap [lo, σ] × [σ, hi] (left endpoint below σ, right endpoint above) into itself: the two branches of the step are the two directions of the threshold equivalence. Set.MapsTo.iterate then traps σ in every bracket. Separately, and whatever f is, each step halves the width. A bracket of width (hi − lo) / 2ⁿ that contains σ puts its midpoint within (hi − lo) / 2ⁿ⁺¹ of it.
The iteration is a noncomputable definition over ℝ. Floating-point rounding and stopping rules are out of scope.
bisectStep: one bisection step toward f x = C on a bracket: evaluate f at the midpoint and keep the half whose endpoints still straddle C.bisect: the n-th bisection bracket from (a, b).bisectMid: the n-th bisection estimate, the midpoint of the n-th bracket.bisectStep, bisect, bisectMid: one step, the n-th bracket, and the n-th estimate (the midpoint of the n-th bracket, counted from n = 0); bisect_zero and bisect_succ unfold the iteration.bisectStep_snd_sub_fst, bisect_snd_sub_fst: a step halves the bracket, so from any starting bracket (a, b) the n-th one has width (b − a) / 2ⁿ.mapsTo_bisectStep, bisect_mem: at a threshold σ the trap is invariant, so every bracket contains σ.bisectMid_mem_Icc: at a threshold σ ∈ [lo, hi], every estimate lies in [lo, hi].abs_bisectMid_sub_le, tendsto_bisectMid: the n-th estimate is within (hi − lo) / 2ⁿ⁺¹ of σ, and the estimates converge to σ.bisection method, root finding, implied volatility solver, threshold, interval halving, JEL C63, MSC 65M06
Above: what it imports. Below: what imports it.
(ℝ → ℝ) → ℝ → ℝ × ℝ → ℝ × ℝ
One bisection step toward f x = C on the bracket I = (a, b): evaluate f at the midpoint m, keep (m, b) if f m < C and (a, m) otherwise.
(ℝ → ℝ) → ℝ → ℝ → ℝ → ℕ → ℝ × ℝ
The n-th bisection bracket for f x = C, starting from (a, b).
(ℝ → ℝ) → ℝ → ℝ → ℝ → ℕ → ℝ
The bisection estimate after n steps: the midpoint of the n-th bracket. At n = 0 it is the midpoint of the starting bracket.
∀ (f : ℝ → ℝ) (C a b : ℝ), bisect f C a b 0 = (a, b)
∀ (f : ℝ → ℝ) (C a b : ℝ) (n : ℕ), bisect f C a b (n + 1) = bisectStep f C (bisect f C a b n)
∀ (f : ℝ → ℝ) (C : ℝ) (I : ℝ × ℝ), (bisectStep f C I).2 - (bisectStep f C I).1 = (I.2 - I.1) / 2
A bisection step halves the bracket, whatever f and C are.
∀ (f : ℝ → ℝ) (C a b : ℝ) (n : ℕ), (bisect f C a b n).2 - (bisect f C a b n).1 = (b - a) / 2 ^ n
Halving: the n-th bracket has width (b − a) / 2ⁿ, whatever f and C are.
∀ {f : ℝ → ℝ} {C lo hi σ : ℝ}, (∀ x ∈ Set.Icc lo hi, f x < C ↔ x < σ) → Set.MapsTo (bisectStep f C) (Set.Icc lo σ ×ˢ Set.Icc σ hi) (Set.Icc lo σ ×ˢ Set.Icc σ hi)The trap is invariant. If σ is the threshold of f against C on [lo, hi], a bisection step keeps the left endpoint in [lo, σ] and the right endpoint in [σ, hi]: at the midpoint m, f m < C means m < σ, and otherwise σ ≤ m.
∀ {f : ℝ → ℝ} {C lo hi σ : ℝ}, (∀ x ∈ Set.Icc lo hi, f x < C ↔ x < σ) → σ ∈ Set.Icc lo hi → ∀ (n : ℕ), bisect f C lo hi n ∈ Set.Icc lo σ ×ˢ Set.Icc σ hiEvery bisection bracket traps the threshold: the n-th bracket (aₙ, bₙ) from (lo, hi) has aₙ ∈ [lo, σ] and bₙ ∈ [σ, hi].
∀ {f : ℝ → ℝ} {C lo hi σ : ℝ}, (∀ x ∈ Set.Icc lo hi, f x < C ↔ x < σ) → σ ∈ Set.Icc lo hi → ∀ (n : ℕ), |bisectMid f C lo hi n - σ| ≤ (hi - lo) / 2 ^ (n + 1)Error bound: the n-th estimate is within (hi − lo) / 2ⁿ⁺¹ of the threshold, half the width of a bracket that contains both.
∀ {f : ℝ → ℝ} {C lo hi σ : ℝ}, (∀ x ∈ Set.Icc lo hi, f x < C ↔ x < σ) → σ ∈ Set.Icc lo hi → ∀ (n : ℕ), bisectMid f C lo hi n ∈ Set.Icc lo hiThe estimate stays in the bracket: the n-th bisection estimate lies in [lo, hi], since it is the midpoint of a sub-bracket of [lo, hi].
∀ {f : ℝ → ℝ} {C lo hi σ : ℝ}, (∀ x ∈ Set.Icc lo hi, f x < C ↔ x < σ) → σ ∈ Set.Icc lo hi → Filter.Tendsto (bisectMid f C lo hi) Filter.atTop (nhds σ)Convergence: the bisection estimates converge to the threshold.