Part I: Root FindingChapter 1 of 6

Root-Finding Methods

Solving the fundamental equation \(f(x) = 0\): from the rock-solid bisection method to the blazingly fast Newton-Raphson iteration and its relatives.

The Root-Finding Problem

Given a continuous function \(f: \mathbb{R} \to \mathbb{R}\), find \(x^*\) such that \(f(x^*) = 0\). This seemingly simple problem arises everywhere:

  • - Finding eigenvalues: \(\det(A - \lambda I) = 0\)
  • - Implicit equations of state in thermodynamics
  • - Intersection points of curves and surfaces
  • - Inverse problems: given \(y\), find \(x\) such that \(g(x) = y\) (i.e., \(f(x) = g(x) - y = 0\))

The key question is always: how fast does the method converge?

1. The Bisection Method

The simplest and most robust root-finding method. By the Intermediate Value Theorem, if \(f(a)\) and \(f(b)\) have opposite signs and \(f\) is continuous on \([a,b]\), then there exists at least one root in \((a,b)\).

Algorithm

  1. Start with \([a, b]\) where \(f(a) \cdot f(b) < 0\)
  2. Compute midpoint \(c = (a + b)/2\)
  3. If \(f(a) \cdot f(c) < 0\), set \(b = c\); otherwise set \(a = c\)
  4. Repeat until \(|b - a| < \epsilon\)

Convergence: Linear. After \(n\) iterations, the interval has width \(|b-a|/2^n\). To get \(p\) digits of accuracy, need \(n \approx 3.32 \, p\) iterations. Slow but guaranteed.

Bisection Method Implementation

Python
script.py38 lines

Click Run to execute the Python code

Code will be executed with Python 3 on the server

2. Newton-Raphson Method

The crown jewel of root finding. Linearize \(f\) at the current guess using the tangent line and solve for the next approximation:

\(x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}\)

Newton's iteration: the tangent line at \((x_n, f(x_n))\) intersects the x-axis at \(x_{n+1}\)

Convergence Analysis

Taylor expand \(f(x^*)\) around \(x_n\) where \(x^* = x_n + e_n\):

\(0 = f(x^*) = f(x_n) + f'(x_n) e_n + \frac{1}{2} f''(x_n) e_n^2 + \cdots\)

The Newton step gives \(e_{n+1} = e_n + f(x_n)/f'(x_n)\), which yields:

\(e_{n+1} \approx -\frac{f''(x^*)}{2 f'(x^*)} e_n^2\)quadratic convergence!

The number of correct digits approximately doubles each iteration. But: requires \(f'(x_n) \neq 0\) and a good initial guess.

Newton-Raphson with Convergence Comparison

Python
script.py45 lines

Click Run to execute the Python code

Code will be executed with Python 3 on the server

3. The Secant Method

What if we don't know \(f'(x)\)? Replace the derivative with a finite difference approximation using the two most recent iterates:

\(x_{n+1} = x_n - f(x_n) \frac{x_n - x_{n-1}}{f(x_n) - f(x_{n-1})}\)

Uses a secant line through \((x_{n-1}, f(x_{n-1}))\) and \((x_n, f(x_n))\)

Convergence Order

The secant method has superlinear convergence of order \(p = \phi = (1 + \sqrt{5})/2 \approx 1.618\) (the golden ratio!). Not as fast as Newton (\(p=2\)), but each step requires only one function evaluation instead of two (no derivative needed). Per function evaluation, secant can be more efficient than Newton.

Secant Method Implementation

Python
script.py37 lines

Click Run to execute the Python code

Code will be executed with Python 3 on the server

4. Fixed-Point Iteration

Rewrite \(f(x) = 0\) as \(x = g(x)\) and iterate \(x_{n+1} = g(x_n)\). The Banach Fixed-Point Theorem guarantees convergence if \(|g'(x)| < 1\) in a neighborhood of the fixed point.

Convergence Criterion

If \(|g'(x^*)| = L < 1\), then the error satisfies:

\(|e_{n+1}| \leq L |e_n|\) — linear convergence with rate \(L\)

The smaller \(L\), the faster convergence. If \(g'(x^*) = 0\), we get at least quadratic convergence (Newton's method is a special case!).

Fixed-Point Iteration: Convergent vs Divergent

Python
script.py39 lines

Click Run to execute the Python code

Code will be executed with Python 3 on the server

5. Method Comparison

MethodOrderf evals/stepRequiresGuaranteed?
Bisection\(O(1/2^n)\)1BracketYes
Newton-Raphson\(p = 2\)2 (f, f')Derivative, good \(x_0\)Locally
Secant\(p \approx 1.618\)1Two initial pointsLocally
Fixed-Point\(p = 1\) (usually)1\(|g'(x^*)| < 1\)If contraction

Head-to-Head: Convergence Race

Python
script.py48 lines

Click Run to execute the Python code

Code will be executed with Python 3 on the server

6. Practical Pitfalls

Multiple Roots

If \(f(x^*) = f'(x^*) = 0\) (double root), Newton degrades to linear convergence. Fix: use modified Newton \(x_{n+1} = x_n - m \frac{f(x_n)}{f'(x_n)}\) where\(m\) is the multiplicity.

Cycling & Divergence

Newton can cycle between points or diverge to infinity with a bad initial guess. Practical codes use hybrid methods: start with bisection to get close, then switch to Newton for fast convergence.

Near-Zero Derivatives

If \(f'(x_n) \approx 0\), the Newton step becomes huge. Always check for small derivatives and fall back to a safer method.

Catastrophic Cancellation

In the secant method, \(f(x_n) - f(x_{n-1})\) can suffer from cancellation when iterates are close. Use extended precision or reformulate.

7. Brent's Method: The Gold Standard

In practice, most scientific libraries use Brent's method (1973), which combines bisection, secant, and inverse quadratic interpolation. It has the reliability of bisection with the speed of higher-order methods. This is what scipy.optimize.brentq uses.

Using SciPy's Brent Method

Python
script.py32 lines

Click Run to execute the Python code

Code will be executed with Python 3 on the server