Numerical Methods · Learn
How to solve $f(x)=0$ when no formula exists — by guessing, then improving. Three classic methods, why one rearrangement converges while another explodes, and how fast each one closes in.
Find the root $x^*$ where $f(x^*)=0$. A few equations factor nicely; most — $\cos x = x$, $x e^x = 1$, a pressure-drop correlation — don't. So we build a sequence of guesses $x_0, x_1, x_2,\dots$ from a rule that drives them toward the root, and stop when successive guesses barely move. The questions that matter: does it converge, and how fast?
Rewrite $f(x)=0$ algebraically as $x = g(x)$. A root is now a fixed point — a value the map $g$ leaves unchanged. Iterate it:
Geometrically, a fixed point is where $y=g(x)$ meets the diagonal $y=x$. The iteration draws a cobweb: up to the curve, across to the diagonal, repeat. Whether it spirals in or staircases out depends entirely on the slope of $g$ at the root:
If $g$ is flatter than the diagonal there, errors shrink each step; if steeper, they grow. The convergence is linear — the error multiplies by roughly $|g'(x^*)|$ each iteration.
This has a single real root, $x^*\approx 1.3247$. Rearrange it three different ways — all algebraically identical — and watch their fates diverge:
| Rearrangement $g(x)$ | $|g'(x^*)|$ | Result |
|---|---|---|
| $x = x^3 - 1$ | ≈ 5.3 | diverges |
| $x = (x+1)^{1/3}$ | ≈ 0.19 | converges |
| $x = 1/(x^2-1)$ | ≈ 4.6 | diverges |
Same equation, opposite outcomes — the rearrangement is everything. There's no guarantee any given $g$ works; part of the craft is finding one that does.
Switch between these three with the preset chips and watch the cobweb spiral in or staircase to infinity, with the live $|g'|$ readout telling you which side of 1 you're on. Open the lab →
Don't guess a rearrangement — use the function's own slope. Stand at $x_n$, follow the tangent line down to where it crosses the axis, and land at $x_{n+1}$:
Newton's method is famously fast: near a simple root the number of correct digits roughly doubles every step — quadratic convergence. The price: you need the derivative, and a poor starting guess can send it wandering. (At a flat spot, $f'\to 0$, the tangent is nearly horizontal and the step blows up.)
What if you don't have $f'$? Replace the tangent with the line through your last two points — a finite-difference stand-in for the derivative:
No derivative needed, and only one new function evaluation per step. Its convergence order is the golden ratio $\varphi\approx 1.618$ — slower than Newton but often cheaper overall, which is why it's a workhorse in practice.
| Method | Needs | Speed | Watch out for |
|---|---|---|---|
| Fixed-point | a good $g(x)$ | linear | $|g'|\ge 1$ → diverges |
| Newton | $f$ and $f'$ | quadratic | $f'\approx 0$, bad start |
| Secant | $f$ only | ≈1.6 (superlinear) | nearly equal $f$ values |
In the lab, derivatives for Newton are estimated numerically, so you only ever type the function itself.
EngineeringCandy · Learn · the theory behind the playground