Skip to main content

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 between samples) gives bisection nothing to grab. Both have example chips.

/ steps an interval bound, Shift steps bigger.

Bisection facts
f continuous on [a, b] and f(a)·f(b) < 0 ⇒ a root lies inside (intermediate-value theorem)
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
Inputs
Functionf(x) or f(x) = g(x)
parsed as f(x) = exp(-x)·(1 + x + x^2/2) - 0.5 — the two sides moved onto one, solving f(x) = 0
+ − × ÷ ^ ( ) · juxtaposition (2x) · x, pi, e, tau · sin cos tan asin acos atan sinh cosh tanh exp ln log log2 sqrt cbrt abs floor ceil round sign min max pow atan2 · P Pcdf Ptail malay prob fact choose
Tryexamples
Interval starta
Left end of the search window.
|a| ≤ 10¹² and a < b
Interval endb
Right end of the search window.
|b| ≤ 10¹² and b > a
Toleranceτ
Stop once the window is this tight either side of its midpoint — the root's error bound.
Evaluate f at a point
Probex
Plug any x into the parsed f — handy for sanity-checking a root by hand.
LHSexp(-x)·(1 + x + x^2/2) at x = 2.67430.499941
RHS0.5 at x = 2.67430.500000
ff(2.6743) = exp(-x)·(1 + x + x^2/2) - 0.5LHS − RHS — zero exactly where the equation balances-5.910e-5
Scan the interval — 129 samples hunting sign flips
·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 hide1 bracket
1f flips + → − between x = 2.625 and x = 2.6875f(2.625) = 0.012172, f(2.6875) = -0.003309bracket 1
Roots
x*root 1 — closed from bracket [2.625, 2.6875] in 15 halvingsf(root) = 1.099e-72.6740599
Watch the bracket shrink
step 15/15
window [2.6740589, 2.6740608] · width 1.91e-6 · root ≈ 2.6740599
02468-0.5-0.2500.250.5
The halvings, narrated
0start 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
1window [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
2window [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
3window [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
4window [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
5window [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
6window [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
7window [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
8window [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
9window [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
10window [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
11window [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
12window [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
13window [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
14window [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
15window [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-72.6740599