Skip to content
Module 02 of 1055 min readAdvanced

Root-finding — bisection, Newton, secant

Inverting a bond price to a yield. Newton's method, convergence rates, robust hybrids (Brent), the practical algorithm a yield-to-maturity function actually calls.

20%

Listen along

Read “Root-finding — bisection, Newton, secant” aloud

Plays in your browser using on-device text-to-speech — nothing leaves the page.

Root-finding — solving f(x) = 0 — appears constantly in finance. Inverting bond prices to yields, calibrating implied volatilities, finding break-even rates, sizing positions to risk targets. The methods are deceptively simple but the production-quality versions involve subtle choices about robustness, convergence, and termination criteria.

Bisection — the boring but bulletproof method

Given f continuous with f(a) < 0 < f(b), there exists a root in (a, b). Repeatedly bisect: evaluate at the midpoint, replace whichever endpoint has the same sign. Converges linearly — each iteration halves the interval. Guaranteed to find a root if one exists in the bracket.

Newton's method

math
x_{k+1} = x_k - f(x_k) / f'(x_k)

Use the tangent line to project to the next iterate. Quadratic convergence (error squares each step). Requires f' and a starting point near the root. Failure modes: zero or near-zero derivative, oscillation, divergence.

Secant method

Replace f'(x_k) in Newton with a finite-difference approximation. Convergence rate is the golden ratio (1.618), between linear and quadratic. Useful when f' is unavailable or expensive.

Brent's method — the production default

Combines bisection (robustness) with inverse quadratic interpolation (speed). Bracket-based: requires endpoints where f has opposite signs. Used by scipy.optimize.brentq and most professional numerical libraries. The right choice when you have a bracket; the wrong choice when you don't.

Yield-to-maturity inversion

Given bond price P and cash-flow schedule (CF_i, t_i), find y such that:

math
P = Σ_i CF_i / (1 + y)^{t_i}

Solve f(y) = P - Σ CF_i / (1+y)^{t_i} = 0 by Newton or Brent. Newton works fine because f is smooth and monotonically increasing in y. Initial guess: coupon rate or current yield.

Implied volatility inversion

Given Black-Scholes call price C_market, find σ such that:

math
C_BS(S, K, T, r, σ) = C_market

Solve by Newton with f'(σ) = vega. Vega is closed-form and always positive for vanilla options, so Newton is very fast and stable. Standard problem; trader desks invert thousands of IVs per second.

When Newton fails

If the initial guess is far from the root, Newton can overshoot. Fall back to Brent or a damped Newton that takes only half-steps when the residual increases. Production code mixes these methods — try Newton first, fall back to Brent on failure.

Termination criteria

  • Absolute error: |x_k - x_{k-1}| < ε_abs. Default ε_abs = 1e-10 for double precision.
  • Relative error: |x_k - x_{k-1}| / |x_k| < ε_rel. Default 1e-8 for typical problems.
  • Residual: |f(x_k)| < ε_res. Sometimes more meaningful than x-distance.
  • Max iterations cap: prevents runaway loops on bad inputs. Default 100.

Multi-dimensional root-finding

Solving F(x) = 0 with F: R^n → R^n is much harder. Newton's method extends naturally (use the Jacobian), but global convergence is not guaranteed. scipy.optimize.fsolve and root-finding in cvxpy use trust-region modifications. For finance applications (calibrating multi-factor models), use specialised damped-Newton or Levenberg-Marquardt methods.

Exercise

A 5-year semi-annual bond pays 4% coupons (2% per period) on a $100 face. The current bond price is $95. (1) Set up the YTM equation. (2) Apply Newton's method starting from y_0 = 4%. (3) Comment on the practical choice of solver.

Loading progress…
LeadAfrikPublic Economics Hub