M02 — Root finding
A rule has to hold at a point: . When the rule cannot be rearranged, you iterate, and three questions decide whether the answer can be trusted: does the iteration reach a root at all, which root, and how fast. This notebook answers them for bisection, Newton's method and the secant method, and measures each rate with the observed-order tool from M01.
Book pages: Root finding and Why Newton is fast, and when it is not in
books/numerical-methods.
The question. You need a root of . Which method finds it, how fast does it get there, and how do you know when to stop?
By the end you can:
- say what bisection guarantees and count its steps before running it
- derive Newton's step from the tangent, and its squared error
- measure an iteration's order from successive errors or steps
- explain why a start can land on a distant root, cycle or diverge
- recognise a multiple root from a constant error ratio, and restore order 2
- choose between Newton and the secant method by cost per digit
- make Newton safe with a line search, and pick a stopping test that means something
Assumes: M01 (relative error, observed order, the round-off floor), and Taylor's theorem with the remainder.
How to use it: predict before you reveal, commit before you check, and move the controls until the equation's behaviour stops surprising you.
Warm-up: remember M01 (closed book)
1. Bisection: one bit per step
Setting: the problem, its sets and its symbols
Problem. Given with and a tolerance , find a bracket with and , and the number of halvings it takes.
| Symbol | In | Meaning |
|---|---|---|
| the continuous function whose root we seek; here | ||
| the starting bracket; here | ||
| a root, ; here | ||
| the tolerance on the bracket width, in the units of | ||
| the slider: | ||
| the number of halvings (the unknown) | ||
| the bracket after halvings | ||
| its midpoint, the estimate of | ||
| the error of the estimate; bounded by |
How these symbols connect
Given a continuous map whose endpoint values satisfy , the intermediate value theorem guarantees a root . Each halving evaluates at the midpoint of and retains the half preserving the sign change until (where carries the units of ). The unknown step count follows directly from the dimensionless ratio , and the estimate error (in the units of ) is always bounded by half the bracket width.
Symbol-by-symbol notes
$f \in C([a, b])$ and $f(a) f(b) < 0$ — continuity and sign change
is the space of functions continuous on the closed interval ; no derivative is needed. The strict inequality means the endpoints have opposite signs, forcing at least one root into the open interval .
$[a\lt em>k, b\lt /em>k]$ and $f(a\lt em>k) f(b\lt /em>k) \le 0$ — nested brackets
The brackets form a nested chain whose widths halve every step. Using rather than handles the edge case where a midpoint lands exactly on a root, giving .
$m\lt em>k$ vs $\lvert m\lt /em>k - x^* \rvert$ — midpoint estimate vs error bound
Because both and the midpoint lie inside , is at most . The true error can jump up on an individual step even though the half-width bound shrinks strictly.
$\tau$ and $k$ — width tolerance and step count
bounds the bracket width in the units of , not the function value . Because every step halves the width independently of , the integer is known before running a single iteration.
Take on . is continuous and , so a root lies between (the intermediate value theorem). The midpoint gives , so the root is in . Repeat.
Each step keeps the half whose ends differ in sign, so the root never leaves the bracket. After halvings the width is , and making it at most a tolerance takes
steps, whatever is. That is linear convergence with ratio : one binary digit per step, or decimal digits, about 3.3 steps per digit. The price of the guarantee is that bisection reads only the sign of , never its size.
needs halvings. They leave the bracket of width 5.82e-11; its midpoint is 1.8e-11 from .
The error itself is not monotone: 0.086 at step 0, 0.164 at step 1. The ratio of successive errors, M01's raw material, wanders from 0.006 to 82.5 over this run. Only the bound halves cleanly, so bisection's order is read from the bound: 1, with ratio .
When bisection breaks
- Assumes: is continuous on and , have opposite signs
- When it fails: a root of even multiplicity has no sign change, so no bracket exists; at a pole ( on ) the bracket shrinks onto the pole and reports it as a root
- Check: evaluate at the returned point: at a pole it grows as the bracket shrinks
2. Newton: the tangent, and a squared error
Setting: the problem, its sets and its symbols
Problem. Given with a simple root (, ) and a start , find iterates with , and the order and constant such that .
| Symbol | In | Meaning |
|---|---|---|
| the function whose root we seek; here | ||
| its derivative; here | ||
| the simple root; here | ||
| the -th iterate; | ||
| the iteration index | ||
| the error | ||
| a point between and , from Taylor's theorem | ||
| the order (an unknown) | ||
| the asymptotic constant (an unknown) | ||
| the step , a stand-in for | ||
| the relative error in the derivative: the solver uses |
How these symbols connect
Given , its derivative , and a starting value , each iterate produces from the zero of the tangent line at , generating errors in the units of . Taylor's theorem at with remainder point between and links to and determines the unknown order and asymptotic constant in . When is unknown, the observable step stands in for , and the dimensionless perturbation tests how an inexact derivative affects that rate.
Symbol-by-symbol notes
$x^*$ — simple root ($f(x^*) = 0$, $f'(x^*) \ne 0$)
A root is simple when the graph crosses the axis with non-zero slope, so . Requiring keeps and continuous near , ensuring division by stays well-defined close to the root.
$e\lt em>k$ vs $s\lt /em>k$ — true error vs observable step
is signed and requires knowing , whereas is non-negative and computed purely from consecutive iterates. Both share the units of , and replaces when measuring without an exact root.
$\xi$ — Taylor remainder point
is an unspecified real number strictly between and supplied by Taylor's theorem, and it changes at every step . Only the fact that as is needed.
$p$ and $C$ — iteration order and asymptotic constant
Unlike M01 §3's step-size error , here error decays from one iterate to the next via . The order is dimensionless, while carries units of so both sides have the units of .
$\delta$ — relative error in $f'$
is dimensionless and models replacing with , as from a finite-difference derivative or a coding slip. Setting recovers exact Newton; would zero out the denominator.
Bisection ignores the size of . At , and : the curve is one unit below the axis and climbing at slope 2, so the straight line that matches it there reaches zero half a unit to the right, at 1.5. That line is the tangent
and setting gives Newton's step
Why it is fast. Write . Taylor's theorem about , evaluated at the root, gives for some between and . Divide by and subtract from the step:
For the constant is .
Measuring the order of an iteration. If , then ; subtract the same line one step earlier and goes:
This is M01 §3 with the iteration count in place of halving . With no exact root, use the steps in place of , as M01 §4 used differences between runs.
Reveal result (lock in your prediction above first)
| k | x_k | e_k | e_k / e_(k-1)^2 | order from errors | order from steps |
|---|---|---|---|---|---|
| 0 | 1.000000000000000 | 4.14e-01 | |||
| 1 | 1.500000000000000 | 8.58e-02 | 0.5000 | ||
| 2 | 1.416666666666667 | 2.45e-03 | 0.3333 | 2.258 | 1.968 |
| 3 | 1.414215686274510 | 2.12e-06 | 0.3529 | 1.984 | 2.000 |
| 4 | 1.414213562374690 | 1.59e-12 | 0.3535 | 2.000 | 2.000 |
| 5 | 1.414213562373095 | 0.00e+00 | |||
| 6 | 1.414213562373095 | 2.22e-16 | |||
| 7 | 1.414213562373095 | 0.00e+00 |
Newton is within after 5 steps. After the first row, taken from a distant start, the ratio column climbs to the predicted from below: is still travelling towards the root on the early steps. The observed order reads 2 within three rows, and the order from steps agrees with no root in hand. The last rows sit on the round-off floor (M01 §5): an error of 0 or one spacing, where an order means nothing; the chart stops a run at its first exact zero, which a log axis cannot show. Bisection's points scatter under §1's bound, which falls by a factor of 2 per step.
A derivative that is slightly wrong. Multiply by , as a coding slip or a difference quotient does. Near the root , so the step removes and leaves
The order falls to 1. The limit does not move: the step is still zero only where is. Choose and watch the ratio column settle.
| k | e_k | e_k / e_(k-1) | observed order |
|---|---|---|---|
| 0 | 4.14e-01 | ||
| 1 | 4.03e-02 | 0.0974 | |
| 2 | 4.17e-03 | 0.1035 | 0.974 |
| 3 | 3.85e-04 | 0.0922 | 1.051 |
| 4 | 3.51e-05 | 0.0910 | 1.006 |
| 5 | 3.19e-06 | 0.0909 | 1.001 |
| 6 | 2.90e-07 | 0.0909 | 1.000 |
| 7 | 2.63e-08 | 0.0909 | 1.000 |
| 8 | 2.39e-09 | 0.0909 | 1.000 |
| 9 | 2.18e-10 | 0.0909 | 1.000 |
| 10 | 1.98e-11 | 0.0909 | 1.000 |
| 11 | 1.80e-12 | 0.0909 | 1.000 |
Predicted ratio ; the last ratio above in the table, row 11, is 0.0909. A factor near is too small to see before the floor, which is why a difference-quotient Jacobian is usually harmless. A factor of 0.1 is a linear method dressed as Newton.
When Newton's quadratic rate breaks
- Assumes: the root is simple and is the true derivative at each iterate
- When it fails: a derivative with relative error still converges to the root, but linearly, with ratio
- Check: the observed order from successive errors or steps should read 2; check against a central difference (M01 §3) before blaming the start
3. Far from the root: basins, cycles and divergence
Setting: the problem, its sets and its symbols
Problem. Given a differentiable with roots , and a start , find whether the Newton sequence converges, and to which root; that is, find the basin of each .
| Symbol | In | Meaning |
|---|---|---|
| here ; later and | ||
| the roots of ; for , | ||
| the Newton map | ||
| the start; the slider sets it | ||
| the -th iterate, applied times to | ||
| the basin of attraction of the root (the unknown) | ||
| for : the start that maps to |
How these symbols connect
A differentiable map defines both its zero set and the Newton iteration map wherever . Choosing a start and applying repeatedly generates the sequence in the units of . Classifying starts by their limit divides into the unknown basins of attraction for each , alongside starts that hit , cycle (such as for ), or diverge.
Symbol-by-symbol notes
$Z = f^{-1}(0)$ — zero set (pre-image of $0$)
means the pre-image , not an inverse function of . Every root with is a fixed point of , because .
$N : \{x : f'(x) \ne 0\} \to \mathbb{R}$ — the Newton map and its domain
is undefined at stationary points where , because a horizontal tangent never meets the axis. Iterating composes it with itself (, , …) as long as no iterate lands where .
$B(r)$ — basin of attraction
For each root , collects every start whose iterates converge to . Basins of distinct roots cannot overlap, and their union need not cover all of because some starts fail to converge.
$x_c$ — symmetric 2-cycle threshold for $\arctan x$
For the odd function , is the positive start satisfying ; by symmetry , so starting at bounces between and forever. It marks a boundary between different long-term behaviours of on .
§2's rate is local: it needs and near . Far away the tangent can point anywhere. Take , with roots , 0 and 1. Each root has a basin of attraction, the set of starts from which Newton reaches it.
Reveal result (lock in your prediction above first)
The strip colours each of 801 starts by the root it reaches: 311 reach , 179 reach 0, 311 reach 1, 0 none. Between , where Newton maps to (a 2-cycle), and , where , the basins interleave in ever thinner bands, and the same happens on the negative side. A start there is a coin toss.
| k | x_k | f(x_k) |
|---|---|---|
| 0 | 0.5500000000 | -3.84e-01 |
| 1 | -3.5972972973 | -4.30e+01 |
| 2 | -2.4616062888 | -1.25e+01 |
| 3 | -1.7366012767 | -3.50e+00 |
| 4 | -1.3015994195 | -9.04e-01 |
| 5 | -1.0802832289 | -1.80e-01 |
| 6 | -1.0081450681 | -1.65e-02 |
| 7 | -1.0000976576 | -1.95e-04 |
| 8 | -1.0000000143 | -2.86e-08 |
| 9 | -1.0000000000 | -4.44e-16 |
| 10 | -1.0000000000 | 0.00e+00 |
Cycles and divergence. Newton on from 0 visits 0, 1, 0, 1, 0, 1: a 2-cycle that never converges, though a real root lies at -1.7693.
Newton on maps . A start that maps to its own negative bounces for ever; it solves , and bisection (§1) on gives . Inside the iterates shrink; outside they grow. From 1.5: 1.5, -1.694, 2.321, -5.114, 32.3, -1575. The residual climbs towards the whole time, which is the warning sign §6 acts on.
When Newton from a distant start breaks
- Assumes: lies in the basin of the root you want; the convergence theorem is local
- When it fails: the iterate lands on another root, cycles ( from 0) or diverges ( from beyond about 1.39)
- Check: should fall at every step; if it does not, damp the step (§6) or bracket the root first (§1)
4. Multiple roots: Newton goes linear
Setting: the problem, its sets and its symbols
Problem. Given with smooth, and (a multiple root when ), and Newton's iterates from , find how depends on near , and the limiting ratio where one exists.
| Symbol | In | Meaning |
|---|---|---|
| here | ||
| the multiple root; here | ||
| the multiplicity of ; the slider sets it | ||
| the factor left after removing ; here | ||
| the -th iterate; | ||
| the error | ||
| the limit of (the unknown) | ||
| machine epsilon, , for the floor in the reveal |
How these symbols connect
Factoring near a root as with separates the integer multiplicity from the non-vanishing smooth factor . Running Newton from generates iterates and errors (in the units of ), whose dimensionless ratios determine the unknown limiting ratio . Comparing exact behaviour against double-precision evaluation then shows how machine epsilon limits how close can get to .
Symbol-by-symbol notes
$m$ and $g$ — multiplicity and the non-vanishing factor
is the highest power of dividing , and ensures no extra factor of is hidden inside . When the root is simple (); when both and vanish.
$C^\infty(\mathbb{R})$ — infinitely differentiable functions
Polynomials such as have continuous derivatives of all orders on , placing and in . This guarantees every derivative needed around exists and is continuous.
$\rho \in [0, 1]$ — limiting error ratio
is dimensionless. A limit means the step-to-step reduction factor shrinks to zero with the error (as at §2's simple root), whereas means each step multiplies the error by a constant factor .
$\epsilon$ — floating-point floor near a multiple root
Although the iterates are analysed in , evaluating an expanded polynomial in doubles adds rounding errors of size proportional to . Because flattens near , rounding noise can swamp well before reaches .
§2 divided by . At a root where the curve touches the axis instead of crossing it, too. Take , which touches zero at 1.
Reveal result (lock in your prediction above first)
With the last ratio above is 0.5000, against . The modified step reaches 0.0e+00 in 5 steps.
How close can you get? Written as , the same function evaluates to exactly 0 at , 7.7e-09 from the root, and Newton stops there after 28 steps. Near a double root , while the sum cancels terms of size about 2 and carries a rounding error of a few (M01 §2). Once is below that, the computed is noise: , about 1.5e-08. The factored form has no cancellation, which is why it keeps converging.
Why the ratio is . At a root of multiplicity , with . Then , and
The step removes all of to first order, and order 2 returns. The catch is that must be known; a steady ratio estimates it as .
When Newton at a multiple root breaks
- Assumes:
- When it fails: the order drops to 1 with ratio , and a double root in a form that cancels can be located only to about
- Check: a steady ratio of successive errors or steps gives ; use the step with that
5. The secant method: no derivative
Setting: the problem, its sets and its symbols
Problem. Given with a simple root and two starts , using values of only, find iterates , the order of the iteration, and which of it and Newton reaches a given error with less work .
| Symbol | In | Meaning |
|---|---|---|
| here | ||
| the simple root; here | ||
| the two starts; here and | ||
| the -th iterate | ||
| the error | ||
| the observed order (the unknown) | ||
| the cost of one , in evaluations of ; the slider sets it | ||
| the work so far, in evaluations of | ||
| a bracket with , for Brent's method; here |
How these symbols connect
Using only values of and two starts , the secant rule constructs from the line through and , producing errors in the units of . Those errors give the unknown dimensionless order and let us plot error against work (measured in evaluations of ), with the slider pricing one Newton derivative relative to . Pairing a sign-change bracket with derivative-free interpolation then leads to Brent's method.
Symbol-by-symbol notes
$x\lt em>0, x\lt /em>1$ — why two starts are needed
Replacing with the secant slope needs two distinct starts with before the first step. Unlike bisection's , and do not have to bracket the root.
$c$ and $W$ — relative derivative cost and total work
Both and are measured in units of one evaluation of , putting methods with different step costs on a common axis. Each secant step reuses and adds to , whereas each Newton step computes both and and adds .
$p$ — observed order of the secant iteration
As in §2, is dimensionless and estimated from three successive errors by . It measures convergence speed per iteration, before weighting by work .
$[a, b]$ — sign-change bracket for Brent's method
Plain secant iterates can wander off without a bracket, just like plain Newton. Brent's method starts from with (as in §1) so every step stays inside a shrinking enclosure of .
Newton needs . Replace it by the slope of the line through the last two iterates:
Each step costs one new evaluation of and no derivative. Start from , .
Per step Newton costs one and one ; count an as evaluations of . The chart in the reveal plots error against total work.
Reveal result (lock in your prediction above first)
| k | e_k | observed order |
|---|---|---|
| 0 | 4.14e-01 | |
| 1 | 5.86e-01 | |
| 2 | 8.09e-02 | -5.713 |
| 3 | 1.42e-02 | 0.878 |
| 4 | 4.21e-04 | 2.025 |
| 5 | 2.12e-06 | 1.502 |
| 6 | 3.16e-10 | 1.667 |
| 7 | 2.22e-16 | |
| 8 | 0.00e+00 | |
| 9 | 2.22e-16 |
The first two orders are pre-asymptotic ( is further from the root than ); then they swing about until the floor. The reason: the same Taylor argument as §2, with the secant's slope, gives . Put and ; matching powers of gives , so and .
Order per unit of work. One Newton step multiplies the digits by 2 for evaluations, so per evaluation by ; the secant method multiplies them by . Newton wins only when : its derivative must cost less than about half an .
Keep the bracket. The secant method has no bracket, so a poor pair of starts can send it away just as Newton is sent. Brent's method keeps a sign-change bracket and takes a secant or inverse-quadratic step when it lands inside, bisecting otherwise: bisection's guarantee at nearly the secant's speed. scipy.optimize.brentq on with xtol=1e-15 takes 8 iterations and 9 evaluations of , error 2.2e-16.
When the secant method breaks
- Assumes: the two latest points are near a simple root and
- When it fails: with no bracket it leaves a good region as Newton does, and equal residuals give a horizontal secant and a division by zero
- Check: keep a sign-change bracket and bisect whenever the secant step leaves it, which is what Brent's method does
6. Safeguards and stopping
Setting: the problem, its sets and its symbols
Problem. Given a differentiable and a start from which plain Newton may diverge, find step lengths such that at every step; and find a stopping test, in tolerances , and a cap , that bounds the error and not only the residual.
| Symbol | In | Meaning |
|---|---|---|
| here , root ; then | ||
| the start for ; the slider sets it | ||
| the Newton direction | ||
| the step length; | ||
| §3's critical start for | ||
| the rescaled , run from | ||
| the scale exponent; the slider sets it | ||
| the residual tolerance, in the units of | ||
| the relative step tolerance, dimensionless | ||
| the cap on the number of steps; here | ||
| the ratio of a linearly convergent run | ||
| in otkd: the residual vector, root at | ||
| in otkd: the Jacobian of , and the Newton step solving |
How these symbols connect
From a start (including beyond §3's threshold for ), each step computes the Newton direction in the units of and scales it by a dimensionless step length so reduces ; in otkd's vector solver, the residual and its Jacobian define the Newton step via . For stopping, the rescaled family contrasts a residual test in (units of ) against a dimensionless relative step test in , both bounded by the step cap and adjusted by when convergence is linear.
Symbol-by-symbol notes
$d\lt em>k$ and $\alpha\lt /em>k$ — Newton direction vs step length
is the full tangent step in the units of , while is a dimensionless scaling factor. Taking gives plain Newton; reducing keeps the same descent direction while preventing overshoot.
$f_s$ and $s$ — rescaled test function
Multiplying by leaves the roots and every Newton direction unchanged because cancels in the quotient. Sweeping mimics changing the units of across twenty orders of magnitude.
$\tau\lt em>f$ vs $\tau\lt /em>x$ — residual tolerance vs relative step tolerance
is compared against , so it carries the units of and shifts whenever is rescaled. is dimensionless and tests , acting as an absolute tolerance near and a relative one for large .
$K$ and $\rho$ — iteration cap and linear-rate correction
ensures the solver always terminates even when a tolerance is unreachable due to scaling or rounding noise. When errors shrink linearly with ratio , a single step underestimates the remaining error whenever is close to .
$r$, $J$ and $\delta$ — multidimensional Newton in otkd
In unknowns, the scalar function becomes a vector residual , the derivative becomes the Jacobian matrix , and dividing by becomes solving for the vector step . Do not confuse this vector step with §2's scalar derivative error.
Far from the root Newton's direction is still right when its length is not. Along ,
so some step with makes smaller, unless is already zero. Two ways to use that:
- Fixed damping, with a constant . Near the root : safe, but linear.
- Backtracking line search: try , and halve it until falls. Far away it shortens the step; near the root the full step passes, and the rate stays quadratic.
The test is from §3, where plain Newton diverges from beyond .
Plain Newton ends at x = 3.89e+06 after 6 steps. Backtracking chose = 0.5, 1, 1, 1: short steps while far away, then 1 and a quadratic finish. Fixed damping is still at 1.8e-07 after 20 steps, halving each time.
The two solvers this repository ships make the two choices.
source: `open_textbook.otkd.solvers.newton.newton` — `solvers/otkd/src/open_textbook/otkd/solvers/newton.py:11`
otkd's newton solves (least squares if is singular), then backtracks: halves until falls, and once it takes the step anyway. It stops on the residual alone, by default, which is safe only if the rows are scaled so that means something.
def newton(
system: System,
q0: np.ndarray,
*,
rows: list[int] | None = None,
tol: float = 1e-12,
max_steps: int = 60,
) -> tuple[np.ndarray, int, list[tuple[np.ndarray, np.ndarray]]]:
"""Solve `rows(q) = 0` from `q0`. Returns the solution, step count and residual history."""
q = np.array(q0, dtype=float)
history: list[tuple[np.ndarray, np.ndarray]] = []
for step in range(max_steps):
r = system.residual(q, rows)
history.append((q.copy(), r.copy()))
error = float(np.max(np.abs(r))) if r.size else 0.0
if error < tol:
return q, step, history
jac = system.jacobian(q, rows)
try:
delta = np.linalg.solve(jac, -r)
except np.linalg.LinAlgError:
delta, *_ = np.linalg.lstsq(jac, -r, rcond=None)
if not np.all(np.isfinite(delta)):
raise SolverError("Newton step is not finite", residual=error)
base = float(np.max(np.abs(r)))
alpha = 1.0
for _ in range(40):
trial = q + alpha * delta
if float(np.max(np.abs(system.residual(trial, rows)))) < base or alpha < 1e-8:
break
alpha *= 0.5
q = q + alpha * delta
r = system.residual(q, rows)
index = (rows or system.constrained)[int(np.argmax(np.abs(r)))]
raise SolverError(
f"Newton did not converge in {max_steps} steps: |r|inf = {np.max(np.abs(r)):.3e}, "
f"worst row {system.problem.rows[index].name}",
residual=float(np.max(np.abs(r))),
)
source: solvers/ot-solve/src/kernels/newton.rs:90-125
The browser kernel solves with a fixed damping factor from a slider (0.1 to 1.5). It flags convergence at and reports Unstable once . A factor above 1 overshoots: changes sign every step.
pub fn step(a: &mut Arena<'_>) -> Status {
let damping = a.params()[P_DAMPING];
if !damping.is_finite() || damping <= 0.0 {
return Status::BadParameter;
}
let iteration = a.diag()[D_ITER] as usize;
let converged = a.diag()[D_CONVERGED] > 0.0;
if converged {
return Status::Ok;
}
let (x, f, df) = {
let state = a.state();
(state[S_X], state[S_F], state[S_DF])
};
if df == 0.0 || !df.is_finite() {
return Status::NotConverged;
}
let next = x - damping * f / df;
let (next_f, next_df) = evaluate(next);
let state = a.state_mut();
state[S_X] = next;
state[S_F] = next_f;
state[S_DF] = next_df;
let slot = (iteration + 1).min(HISTORY - 1);
let out = a.out_mut();
out[O_X + slot] = next;
out[O_F + slot] = next_f;
let diag = a.diag_mut();
diag[D_ITER] += 1.0;
diag[D_RESIDUAL] = next_f;
diag[D_CONVERGED] = if next_f.abs() < 1.0e-12 { 1.0 } else { 0.0 };
if !next.is_finite() || next.abs() > 1.0e6 {
return Status::Unstable;
}
Status::Ok
}
Stopping. Three tests are in use: the residual , the step , and a cap on the number of steps. The residual reads , the error times the slope, so its meaning changes with the units of . The step measures itself. For Newton , which overstates the error of (about ), so the step test is safe. At a linear rate the error left is steps, so a slow run needs a tighter step test.
Rescale and run Newton from 3 with and a cap of 60.
| test | steps | error at stop |
|---|---|---|
| residual | 0 | 1.59e+00 |
| relative step | 6 | 2.22e-16 |
The step test does not notice the units. The residual test stops at once when is small everywhere, and never when is so large that one spacing of at the root moves it by more than .
When damping and the line search breaks
- Assumes: the Newton step is a descent direction for , which holds whenever and is right and non-zero
- When it fails: at a local minimum of that is not a root, shrinks to its floor and the run stalls with
- Check: watch : a collapse to its floor means a residual minimum, not a root; restart elsewhere or continue from a solved case
Practice
Hint 1
, with .
Hint 2
and .
Mixed practice: which method, and why?
Check yourself (closed book)
Keep these:
- Bisection is certain given a sign change: steps, one bit each, whatever is.
- Newton squares the error near a simple root, ; measure from successive errors or steps.
- Newton's convergence is local: a start can land on a far root, cycle or diverge, so should fall at every step.
- A root of multiplicity makes Newton linear with ratio ; the step restores order 2.
- The secant method has order for one per step, and beats Newton when costs more than about of an .
- Backtracking keeps Newton safe far away and quadratic near the root; stop on a relative step and a residual in units that mean something.
Your connection
Where does a root finder run in something you use or maintain (otkd's assembly solve, a spreadsheet's goal seek, a CAD sketch)? What does it stop on, and what would a double root do to it?
Answers
Practice A. .
Practice B. .
Practice C. .
Mixed practice. Brent's method; the derivative code; the observed order from successive steps.
Where the maths is derived
Optional. These notes give the intuition and application; the sources below give the full derivations and proofs.
§2 Newton's method
- Nocedal and Wright (2006), Numerical Optimization: Newton's method for nonlinear equations and its local quadratic convergence, with the assumptions on the Jacobian it needs.
§5 The secant method
- Nocedal and Wright (2006), Numerical Optimization: the secant idea in several variables: quasi-Newton (Broyden) updates and their superlinear convergence.
§6 Damping, line search and stopping
- Nocedal and Wright (2006), Numerical Optimization: line-search globalisation of Newton's method with a merit function, and why the full step is accepted near the solution.
§4 Multiple roots
- Higham (2002), Accuracy and Stability of Numerical Algorithms: the rounding error of evaluating a polynomial by Horner's rule, which bounds how small a computed residual can be near a root.
Compiled from notebooks/methods/m02_root_finding.py — run locally with cd notebooks && uv run marimo edit methods/m02_root_finding.py for live Python scratch cells.
Back to the book: Root finding · Why Newton is fast, and when it is not