Skip to content
LeetQuant
E04 Numerical Methods

E04 · Numerical Methods · Lesson 2 of 4

Root Finding

Orders of convergence derived and measured (bisection, secant, Newton), Brent's method, the ways Newton fails, Newton's method for systems with a Jacobian, and a robust implied-volatility solver.

20 min

Objective

Bisection, Newton and Brent's method were introduced elsewhere. Here we derive their convergence orders, measure them numerically, explain each failure mode with a concrete example, extend Newton to systems, and build an implied-volatility solver that cannot fail on a valid price.

Order of convergence

Let en=∣xn−r∣e_n = |x_n - r| be the error at step nn. A method has order pp with rate constant CC if

lim⁡n→∞en+1en p=C.\lim_{n \to \infty} \frac{e_{n+1}}{e_n^{\,p}} = C .

With p=1p = 1 (and C<1C < 1) you gain a fixed number of digits per step, −log⁡10C-\log_{10} C; bisection has C=1/2C = 1/2, about 0.3 digits per step. With p>1p > 1 the number of correct digits is multiplied by about pp per step. Taking logs of en+1≈Cenpe_{n+1} \approx C e_n^p at two consecutive steps gives the estimate used in practice:

p≈ln⁡(en+1/en)ln⁡(en/en−1).p \approx \frac{\ln(e_{n+1}/e_n)}{\ln(e_n/e_{n-1})} .

When the root is unknown, the step size ∣xn+1−xn∣|x_{n+1} - x_n| is a good proxy for ene_n once convergence is superlinear.

Newton: order 2

Expand ff about xnx_n and evaluate at the root: 0=f(xn)+f′(xn)(r−xn)+12f′′(ξ)(r−xn)20 = f(x_n) + f'(x_n)(r - x_n) + \tfrac12 f''(\xi)(r - x_n)^2. Dividing by f′(xn)f'(x_n) and using xn+1=xn−f(xn)/f′(xn)x_{n+1} = x_n - f(x_n)/f'(x_n),

xn+1−r=f′′(ξ)2f′(xn) (xn−r)2,C=∣f′′(r)2f′(r)∣.x_{n+1} - r = \frac{f''(\xi)}{2 f'(x_n)}\,(x_n - r)^2, \qquad C = \left|\frac{f''(r)}{2 f'(r)}\right| .

This needs f′(r)≠0f'(r) \ne 0 (a simple root) and a start close enough that the neglected terms stay small.

Secant: order (1+5)/2(1 + \sqrt 5)/2

The secant method replaces f′(xn)f'(x_n) by the slope through the last two iterates. The same expansion gives en+1≈Cenen−1e_{n+1} \approx C e_n e_{n-1} with the same CC. Try en+1≈Aenpe_{n+1} \approx A e_n^p: then en≈Aen−1pe_n \approx A e_{n-1}^p, so en−1≈(en/A)1/pe_{n-1} \approx (e_n/A)^{1/p} and

Aen p≈Cen(enA)1/p⟹p=1+1p⟹p=1+52≈1.618.A e_n^{\,p} \approx C e_n \left(\frac{e_n}{A}\right)^{1/p} \quad\Longrightarrow\quad p = 1 + \frac1p \quad\Longrightarrow\quad p = \frac{1 + \sqrt 5}{2} \approx 1.618 .

Per function evaluation the secant method usually wins: it needs one new ff per step, while Newton needs ff and f′f'. If f′f' costs as much as ff, Newton's order per evaluation is 21/2≈1.414<1.6182^{1/2} \approx 1.414 < 1.618. Newton wins when f′f' comes almost free, as vega does alongside a Black–Scholes price.

Worked example

measuring the orders on x³ − 2x − 5

f(x)=x3−2x−5f(x) = x^3 - 2x - 5 has a simple root r=2.0945514815423265…r = 2.0945514815423265\ldots. Run bisection on [2,3][2, 3], the secant method from x0=2,x1=3x_0 = 2, x_1 = 3 and Newton from x0=3x_0 = 3. Estimate each order and check Newton's rate constant against C=∣f′′(r)/(2f′(r))∣C = |f''(r)/(2f'(r))|.

Show solution

Errors computed against a 50-digit reference root (the secant and Newton runs use high-precision Decimal arithmetic so the asymptotic order is visible before rounding takes over):

StepNewton ene_nNewton pp estimateSecant ene_nSecant pp estimate
09.05×10−19.05 \times 10^{-1}9.46×10−29.46 \times 10^{-2}
12.65×10−12.65 \times 10^{-1}9.05×10−19.05 \times 10^{-1}
23.26×10−23.26 \times 10^{-2}1.7083.57×10−23.57 \times 10^{-2}
35.85×10−45.85 \times 10^{-4}1.9191.33×10−21.33 \times 10^{-2}
41.92×10−71.92 \times 10^{-7}1.9942.73×10−42.73 \times 10^{-4}3.929
52.08×10−142.08 \times 10^{-14}2.0002.05×10−62.05 \times 10^{-6}1.258
62.44×10−282.44 \times 10^{-28}2.0003.15×10−103.15 \times 10^{-10}1.796
73.63×10−163.63 \times 10^{-16}1.557
86.44×10−266.44 \times 10^{-26}1.642
91.32×10−411.32 \times 10^{-41}1.609
104.77×10−674.77 \times 10^{-67}1.622

Continuing, the secant estimates go 1.617,1.619,1.6181.617, 1.619, 1.618: the golden ratio. Early estimates are meaningless (the method has not reached its asymptotic regime), which is why you read the order from the tail.

Newton's constant. f′′(r)=6r=12.567f''(r) = 6r = 12.567 and f′(r)=3r2−2=11.161f'(r) = 3r^2 - 2 = 11.161, so C=12.567/22.322=0.563C = 12.567/22.322 = 0.563. The measured ratios en+1/en2e_{n+1}/e_n^2 are 0.5610.561 (step 3 to 4) and 0.5640.564 (step 4 to 5). In double precision, x5=2.0945514815423474x_5 = 2.0945514815423474 and x6=2.0945514815423265x_6 = 2.0945514815423265, the double nearest rr; further steps stay there, since no step can beat the accuracy with which ff itself is evaluated.

Bisection. The midpoint errors go 0.41,0.16,0.030,0.032,0.0008,0.015,…0.41, 0.16, 0.030, 0.032, 0.0008, 0.015, \ldots: not monotone, because the midpoint can land near the root by luck. The quantity that halves every step is the bracket width, which bounds the error. Ten steps give a width of 2−10≈10−32^{-10} \approx 10^{-3}; Newton reaches 2×10−142 \times 10^{-14} in five.

How Newton fails

The quadratic rate is local. Away from the root, or when the root is not simple, it disappears.

FailureExampleWhat happens
Multiple rootf=(x−1)2(x+2)f = (x - 1)^2 (x + 2) from x0=2x_0 = 2f′(r)=0f'(r) = 0, so convergence is linear with ratio (m−1)/m=1/2(m - 1)/m = 1/2 for multiplicity m=2m = 2: errors 1,0.556,0.298,0.155,0.080,…1, 0.556, 0.298, 0.155, 0.080, \ldots
Overshoot and divergencef=arctan⁡xf = \arctan x from x0=1.5x_0 = 1.5Iterates 1.5,−1.694,2.321,−5.114,32.3,−15751.5, -1.694, 2.321, -5.114, 32.3, -1575. From 1.31.3 it converges. The dividing point solves 2x=(1+x2)arctan⁡x2x = (1 + x^2)\arctan x, x≈1.3917x \approx 1.3917
Cyclef=x3−2x+2f = x^3 - 2x + 2 from x0=0x_0 = 0x1=0−2/(−2)=1x_1 = 0 - 2/(-2) = 1, x2=1−1/1=0x_2 = 1 - 1/1 = 0: a 2-cycle forever
Flat derivativeimplied vol, deep out of the money, low startVega near 0 makes the step enormous (shown below)

For a root of known multiplicity mm, the step x−mf/f′x - m f/f' restores quadratic convergence; on the double root above it gives errors 1,0.111,1.9×10−3,6.3×10−7,6.7×10−141, 0.111, 1.9 \times 10^{-3}, 6.3 \times 10^{-7}, 6.7 \times 10^{-14}. If mm is unknown, apply Newton to f/f′f/f', which has a simple root at rr.

Brent's method: the default when you have a bracket

Brent's method keeps a bracket [a,b][a, b] with f(a)f(b)<0f(a) f(b) < 0 at all times. Each step it tries a fast interpolation step, inverse quadratic interpolation through the last three points (fit xx as a quadratic in ff and evaluate at f=0f = 0) or a secant step, and accepts it only if it lands inside the bracket and the bracket has been shrinking fast enough; otherwise it bisects. So it never does much worse than bisection, and near a simple root it converges superlinearly (inverse quadratic interpolation has order about 1.84). On the implied-volatility problem below, SciPy's brentq on [10−6,5][10^{-6}, 5] with xtol=1e-14 needs 13 function evaluations against 51 for bisect.

Use Brent (or a safeguarded Newton, below) whenever a sign change can be guaranteed; use plain Newton only when the start is known to be good.

Newton for systems

For F:Rn→RnF: \mathbb R^n \to \mathbb R^n the linearisation is F(x+Δ)≈F(x)+J(x)ΔF(x + \Delta) \approx F(x) + J(x)\Delta with Jacobian Jij=∂Fi/∂xjJ_{ij} = \partial F_i/\partial x_j. Each step solves the linear system

J(xk) Δk=−F(xk),xk+1=xk+Δk,J(x_k)\,\Delta_k = -F(x_k), \qquad x_{k+1} = x_k + \Delta_k ,

by LU factorisation, never by forming J−1J^{-1}. Convergence is quadratic near a root where JJ is nonsingular, and the conditioning of JJ at the root limits the attainable accuracy, exactly as κ(A)\kappa(A) did for linear systems. A step costs n2n^2 derivatives plus an O(n3)O(n^3) solve; quasi-Newton methods (Broyden) update an approximate Jacobian with rank-one corrections instead. Typical uses: calibrating a model with nn parameters to nn prices, or solving first-order conditions of an optimisation.

Worked example

a 2 × 2 Newton iteration

Solve x2+y2=4x^2 + y^2 = 4, ex+y=1e^x + y = 1 starting from (x,y)=(1,−1)(x, y) = (1, -1). Write down the Jacobian and track the residual norm ∥F∥2\lVert F \rVert_2.

Show solution
F(x,y)=(x2+y2−4ex+y−1),J(x,y)=(2x2yex1).F(x, y) = \begin{pmatrix} x^2 + y^2 - 4 \\ e^x + y - 1 \end{pmatrix}, \qquad J(x, y) = \begin{pmatrix} 2x & 2y \\ e^x & 1 \end{pmatrix} .
import math

def F(x, y):
    return x * x + y * y - 4, math.exp(x) + y - 1

x, y = 1.0, -1.0
for k in range(1, 6):
    f1, f2 = F(x, y)
    a, b, c, d = 2 * x, 2 * y, math.exp(x), 1.0     # Jacobian [[a, b], [c, d]]
    det = a * d - b * c
    dx = -(d * f1 - b * f2) / det                    # Cramer's rule for J @ delta = -F
    dy = -(-c * f1 + a * f2) / det
    x, y = x + dx, y + dy
    print(k, repr(x), repr(y), f"{math.hypot(*F(x, y)):.2e}")
# 1 1.0757656854799804 -1.9242343145200196 8.60e-01
# 2 1.0094707926109934 -1.7378448607830892 3.96e-02
# 3 1.0041885798487606 -1.7296532313345403 1.02e-04
# 4 1.0041687386935545 -1.7296372870860777 8.42e-10
# 5 1.0041687384746592 -1.72963728702587 0.00e+00

The residuals 0.86→0.040→1.0×10−4→8.4×10−10→00.86 \to 0.040 \to 1.0 \times 10^{-4} \to 8.4 \times 10^{-10} \to 0 show the squaring: 0.0402≈1.6×10−30.040^2 \approx 1.6 \times 10^{-3} and (1.0×10−4)2=10−8(1.0 \times 10^{-4})^2 = 10^{-8}, each within a modest constant of the next residual. The root is (1.00416873847,−1.72963728703)(1.00416873847, -1.72963728703). The system has a second root with x<0x < 0 (the circle meets the curve twice); which one Newton finds depends on the start, a general feature of nonlinear systems.

For 2×22 \times 2, Cramer's rule is fine; for larger systems call numpy.linalg.solve(J, -F).

Application: a robust implied-volatility solver

The Black–Scholes call price C(σ)C(\sigma) is strictly increasing in σ\sigma (vega >0> 0), so any price strictly between the no-arbitrage bounds has exactly one implied volatility, and a bracket is available. Two facts make Newton reliable:

  1. Vega is free. ∂C/∂σ=ST φ(d1)\partial C/\partial\sigma = S\sqrt T\,\varphi(d_1) reuses d1d_1 from the price.
  2. The inflection point is known. Volga is ∂2C/∂σ2=vega⋅d1d2/σ\partial^2 C/\partial\sigma^2 = \text{vega} \cdot d_1 d_2/\sigma, and with m=ln⁡(F/K)m = \ln(F/K) for forward F=SerTF = S e^{rT},
d1d2=m2σ2T−σ2T4,d_1 d_2 = \frac{m^2}{\sigma^2 T} - \frac{\sigma^2 T}{4},

which is zero at σ∗2=2∣m∣/T\sigma_*^2 = 2|m|/T. So CC is convex for σ<σ∗\sigma < \sigma_* and concave above. Started at σ∗\sigma_*, the tangent at the inflection lies below the convex part and above the concave part, so the first Newton step lands on the same side of the root as σ∗\sigma_*, and from then on the iterates move monotonically to the root without overshooting.

A production solver still keeps a bracket and falls back to bisection if a step leaves it, which covers rounding trouble and tiny vega.

Worked example

implied volatility by safeguarded Newton

A 6-month call with S=100S = 100, K=120K = 120, r=2%r = 2\% is priced at σ=25%\sigma = 25\%. Recover σ\sigma from the price, and show what plain Newton does from a start of σ0=5%\sigma_0 = 5\%.

Show solution
import math

def N(x):
    return 0.5 * math.erfc(-x / math.sqrt(2))

def bs_call(S, K, T, r, sig):
    d1 = (math.log(S / K) + (r + 0.5 * sig**2) * T) / (sig * math.sqrt(T))
    return S * N(d1) - K * math.exp(-r * T) * N(d1 - sig * math.sqrt(T))

def vega(S, K, T, r, sig):
    d1 = (math.log(S / K) + (r + 0.5 * sig**2) * T) / (sig * math.sqrt(T))
    return S * math.sqrt(T) * math.exp(-0.5 * d1**2) / math.sqrt(2 * math.pi)

def implied_vol(price, S, K, T, r, tol=1e-12, verbose=False):
    lo, hi = 1e-6, 5.0                        # the call price is increasing in sigma
    m = math.log(S * math.exp(r * T) / K)     # log-moneyness ln(F/K)
    sig = max(math.sqrt(2 * abs(m) / T), 0.1) # start at the inflection point
    for it in range(1, 101):
        diff = bs_call(S, K, T, r, sig) - price
        if verbose:
            print(it, f"{sig:.15f}", f"{diff:+.3e}")
        if abs(diff) < tol:
            return sig
        if diff > 0:
            hi = sig
        else:
            lo = sig
        v = vega(S, K, T, r, sig)
        step = sig - diff / v if v > 0 else lo
        sig = step if lo < step < hi else 0.5 * (lo + hi)   # Newton if safe, else bisect
    raise RuntimeError("no convergence")

S, K, T, r = 100.0, 120.0, 0.5, 0.02
price = bs_call(S, K, T, r, 0.25)
print(f"price = {price:.6f}")
implied_vol(price, S, K, T, r, verbose=True)

sig = 0.05                                    # plain Newton from a poor start
diff, v = bs_call(S, K, T, r, sig) - price, vega(S, K, T, r, sig)
print("plain Newton:", f"vega={v:.2e}", f"next sigma={sig - diff / v:.1f}")

Output:

price = 1.679752
1 0.830232634371728 +1.522e+01
2 0.290584242519715 +8.259e-01
3 0.252201427936204 +4.210e-02
4 0.250008949533932 +1.704e-04
5 0.250000000150952 +2.875e-09
6 0.250000000000000 -3.553e-15
plain Newton: vega=2.13e-04 next sigma=7870.5

Reading it. m=ln⁡(100e0.01/120)=−0.1723m = \ln(100 e^{0.01}/120) = -0.1723, so σ∗=2×0.1723/0.5=0.830\sigma_* = \sqrt{2 \times 0.1723/0.5} = 0.830. The true vol is below σ∗\sigma_*, in the convex region, so every iterate overestimates and decreases monotonically: 0.830,0.291,0.2522,0.250009,0.250000000150.830, 0.291, 0.2522, 0.250009, 0.25000000015. The vol errors 4.1×10−2,2.2×10−3,8.9×10−6,1.5×10−104.1 \times 10^{-2}, 2.2 \times 10^{-3}, 8.9 \times 10^{-6}, 1.5 \times 10^{-10} show the quadratic rate. The bisection fallback never fires.

Plain Newton from σ0=0.05\sigma_0 = 0.05 is 20% out of the money with vega 2×10−42 \times 10^{-4}: the first step jumps to σ=7870\sigma = 7870, where the option is worth almost SS and vega underflows to exactly 0, so the next step divides by zero.

Tolerance. A price tolerance δ\delta maps to a vol tolerance of about δ/vega\delta/\text{vega}. For deep out-of-the-money options with tiny vega, a price accurate to 10−1210^{-12} can still leave the vol uncertain, and a quoted price rounded to a cent may not pin down the vol at all; that is conditioning again (κ\kappa of the inverse map is large when vega is small).

Knowledge check

Successive errors of an iteration are 10−310^{-3}, 10−510^{-5}, 10−810^{-8}. What order does this suggest?

Knowledge check

Newton's method is applied to f(x)=(x−1)2g(x)f(x) = (x - 1)^2 g(x) with g(1)≠0g(1) \ne 0. How do the errors behave near x=1x = 1?

Knowledge check

Evaluating f' costs as much as evaluating f, and you can afford a fixed number of evaluations. Which method usually gains more digits per evaluation near a simple root?

Knowledge check

Why start an implied-vol Newton iteration at σ∗=2∣ln⁡(F/K)∣/T\sigma_* = \sqrt{2|\ln(F/K)|/T}?

Key takeaways

  • Order pp means en+1≈Cenpe_{n+1} \approx C e_n^p; estimate pp from ln⁡(en+1/en)/ln⁡(en/en−1)\ln(e_{n+1}/e_n)/\ln(e_n/e_{n-1}) in the tail. Bisection is linear with C=1/2C = 1/2, secant has p=(1+5)/2p = (1 + \sqrt 5)/2, Newton p=2p = 2 with C=∣f′′/(2f′)∣C = |f''/(2f')|.
  • Count evaluations, not steps: secant beats Newton per evaluation unless f′f' is cheap.
  • Newton fails at multiple roots (linear rate), from poor starts (overshoot, cycles) and where f′f' is small. Safeguard it with a bracket, or use Brent's method.
  • For systems, solve JΔ=−FJ\Delta = -F each step; quadratic convergence needs a nonsingular Jacobian at the root.
  • Implied vol: unique by monotonicity, Newton with vega from the inflection point, bracket and bisection fallback, and remember that vol accuracy is price accuracy divided by vega.

Practice problems

Finished reading?

Answer the 4 knowledge checks to complete this lesson (0 done).