Bisection Calculator
The Poisson Calculator recovers λ from a target
probability with a higher-or-lower search: guess a rate, compare, keep the
half of the window that must hold the answer. This page is that same search set
loose on any expression you type. Enter f(x) — or a full equation
f(x) = g(x), which is solved as f − g = 0 — plus an interval, and it scans
for sign flips, then bisects every bracket it finds, narrating each halving and
plotting the window as it shrinks. Type something without an x and it simply
evaluates the expression — a plain calculator with the same grammar.
The grammar covers + − × ÷ ^, parentheses, implicit multiplication (2x,
2(x+1)), the constants pi, e, tau, and the usual scientific functions
(sin, ln, log, sqrt, abs, min, pow, …). Angles are radians.
Seeded from the engine's worked example, written out as raw math: a fair Total quote says P(over 2.5) = 0.5, i.e. P(X ≤ 2) = 0.5, and for a Poisson count that is e−λ(1 + λ + λ²/2) = 0.5. The root the search converges on is the same λ_total ≈ 2.6743 the Odds Generation engine recovers — and the same answer the Poisson page's inverse solve returns.
It is honest about the two classic traps: a sign flip across a pole (like
1/(x − 2)) pinches down to a point where |f| explodes instead of vanishing —
reported as a jump, not a root — and a curve that touches zero without
crossing (like x² + 0.05, or x² between samples) gives bisection nothing
to grab. Both have example chips.
↑/↓ steps an interval bound, Shift steps bigger.
After k halvings the window is (b − a)/2k wide — the midpoint misses the root by at most (b − a)/2k+1
Halvings to a tolerance τ: ⌈log₂((b − a)/τ)⌉ — here ⌈log₂(8/1e-6)⌉ = 23
| LHS | exp(-x)·(1 + x + x^2/2) at x = 2.6743 | 0.499941 |
| RHS | 0.5 at x = 2.6743 | 0.500000 |
| f | f(2.6743) = exp(-x)·(1 + x + x^2/2) - 0.5LHS − RHS — zero exactly where the equation balances | -5.910e-5 |
| · | sampled 129 points, one every 0.0625, across [0, 8]two neighbours with opposite signs trap a crossing between them — roots closer together than one spacing can hide | 1 bracket |
| 1 | f flips + → − between x = 2.625 and x = 2.6875f(2.625) = 0.012172, f(2.6875) = -0.003309 | bracket 1 |
| x* | root 1 — closed from bracket [2.625, 2.6875] in 15 halvingsf(root) = 1.099e-7 | 2.6740599 |
| 0 | start with the scan's bracket: [2.625, 2.6875], width 0.062500f(2.625) = 0.012172 and f(2.6875) = -0.003309 — opposite signs, so a crossing is trapped inside | |
| 1 | window [2.6250000, 2.6875000] → midpoint 2.6562500f(mid) = 0.004402 — same sign as the positive low end, so the crossing sits above the midpoint | ▲ keep upper half |
| 2 | window [2.6562500, 2.6875000] → midpoint 2.6718750f(mid) = 0.000539 — same sign as the positive low end, so the crossing sits above the midpoint | ▲ keep upper half |
| 3 | window [2.6718750, 2.6875000] → midpoint 2.6796875f(mid) = -0.001387 — opposite sign to the positive low end, so the crossing sits below the midpoint | ▼ keep lower half |
| 4 | window [2.6718750, 2.6796875] → midpoint 2.6757813f(mid) = -0.000424 — opposite sign to the positive low end, so the crossing sits below the midpoint | ▼ keep lower half |
| 5 | window [2.6718750, 2.6757813] → midpoint 2.6738281f(mid) = 5.726e-5 — same sign as the positive low end, so the crossing sits above the midpoint | ▲ keep upper half |
| 6 | window [2.6738281, 2.6757813] → midpoint 2.6748047f(mid) = -0.000184 — opposite sign to the positive low end, so the crossing sits below the midpoint | ▼ keep lower half |
| 7 | window [2.6738281, 2.6748047] → midpoint 2.6743164f(mid) = -6.315e-5 — opposite sign to the positive low end, so the crossing sits below the midpoint | ▼ keep lower half |
| 8 | window [2.6738281, 2.6743164] → midpoint 2.6740723f(mid) = -2.947e-6 — opposite sign to the positive low end, so the crossing sits below the midpoint | ▼ keep lower half |
| 9 | window [2.6738281, 2.6740723] → midpoint 2.6739502f(mid) = 2.715e-5 — same sign as the positive low end, so the crossing sits above the midpoint | ▲ keep upper half |
| 10 | window [2.6739502, 2.6740723] → midpoint 2.6740112f(mid) = 1.210e-5 — same sign as the positive low end, so the crossing sits above the midpoint | ▲ keep upper half |
| 11 | window [2.6740112, 2.6740723] → midpoint 2.6740417f(mid) = 4.578e-6 — same sign as the positive low end, so the crossing sits above the midpoint | ▲ keep upper half |
| 12 | window [2.6740417, 2.6740723] → midpoint 2.6740570f(mid) = 8.155e-7 — same sign as the positive low end, so the crossing sits above the midpoint | ▲ keep upper half |
| 13 | window [2.6740570, 2.6740723] → midpoint 2.6740646f(mid) = -1.066e-6 — opposite sign to the positive low end, so the crossing sits below the midpoint | ▼ keep lower half |
| 14 | window [2.6740570, 2.6740646] → midpoint 2.6740608f(mid) = -1.252e-7 — opposite sign to the positive low end, so the crossing sits below the midpoint | ▼ keep lower half |
| 15 | window [2.6740570, 2.6740608] → midpoint 2.6740589f(mid) = 3.451e-7 — same sign as the positive low end, so the crossing sits above the midpoint | ▲ keep upper half |
| ✓ | window is 1.91e-6 wide — at most the 1e-6 tolerance either side of the midpointcheck: f(2.6740599) = 1.099e-7 | 2.6740599 |