🎯 Root-Finder Lab — Newton vs Bisection vs Secant

Three legendary ways to hunt for where f(x) = 0, run side by side with every iteration, error and failure mode on display: guaranteed-but-slow bisection, lightning-fast Newton–Raphson (and exactly when it spectacularly diverges), and the secant method that skips the derivative.

Bisection (bracket a,b)

Never fails if f changes sign. Error is guaranteed to halve every step — about 0.3 digits per iteration.

Newton–Raphson (start x₀)

x ← x − f/f′. Doubles correct digits per step near a simple root; tiny slope or a flat spot and it flies off.

Secant (x₀, x₁)

Newton with a finite-difference slope: order of convergence 1.618… (the golden ratio) — no derivative needed.

Result

Reading the race

Run the demos: bisection marches at a constant angle (log-error drops 0.301 per step), Newton bends down almost instantly (quadratic), and the secant line sits between them. Watch Newton stall on the double-root demo — its slope never quite gets sharp there, so it degrades to a pedestrian ×1.9 per step.