MathLabs

Applied and computational mathematics

Approximate solutions of equations

Numerical methods like bisection and Newton's method that find roots a computer can compute step by step.

IntuitionIntuition: zooming in near a root

Suppose you are hunting for a root rr of an equation f(x)=0f(x)=0, but there is no algebraic formula that produces rr exactly. A numerical method builds a sequence of guesses x0,x1,x2,…x_0, x_1, x_2,\dots that gets closer and closer to rr at every step, much like repeatedly zooming a graph of ff toward the point where it crosses the horizontal axis lets you read off more and more correct decimal digits. The three methods below differ only in how cleverly they turn the current guess xnx_n into the next, better guess xn+1x_{n+1}.

A secant line through two nearby points on a curve rotating to become the tangent line as the step size shrinks to zero, illustrating the geometric idea behind Newton's method.
Drag the secant line's step size hh toward zero and watch it settle onto the tangent line at x0x_0 with slope f′(x0)f'(x_0): this is exactly the tangent line that Newton's method follows downhill to its next guess x1=x0−f(x0)f′(x0)x_1 = x_0 - \dfrac{f(x_0)}{f'(x_0)}, instead of the cruder secant slope f(x0+h)−f(x0)h\dfrac{f(x_0+h)-f(x_0)}{h}.

UndergraduateDefinition: three root-finding methods

Definition: Bisection method

If a continuous function ff satisfies f(a)f(b)<0f(a)f(b)<0 on an interval [a,b][a,b], the Intermediate Value Theorem guarantees a root inside. Bisection halves this interval at every step: compute the midpoint c=a+b2c=\dfrac{a+b}{2}, evaluate f(c)f(c), then keep whichever half still has a sign change and repeat.

∣xn−r∣≤b−a2n+1|x_n - r| \le \dfrac{b-a}{2^{n+1}}

Here ∣xn−r∣≤b−a2n+1|x_n - r| \le \dfrac{b-a}{2^{n+1}} bounds how far the nn-th midpoint xnx_n can be from the true root rr: since the interval width L=b−aL=b-a halves at every single step, the worst-case error is cut in half too, so after only n=4n=4 steps the uncertainty shrinks to L/32L/32. This guaranteed, predictable shrink rate is the whole appeal of bisection — it never fails to converge, though it is slow.

Definition: Newton's method

Newton's method replaces the curve near xnx_n by its tangent line y=f(xn)+f′(xn)(x−xn)y=f(x_n)+f'(x_n)(x-x_n) and takes the next guess xn+1x_{n+1} to be where that tangent line crosses zero, giving the iteration xn+1=xn−f(xn)f′(xn)x_{n+1} = x_n - \dfrac{f(x_n)}{f'(x_n)}. It needs the derivative f′f' at every step but converges far faster than bisection when it works.

xn+1=xn−f(xn)f′(xn)x_{n+1} = x_n - \dfrac{f(x_n)}{f'(x_n)}

A third viewpoint unifies both: rewrite the equation as a fixed-point problem x=g(x)x=g(x) for some function gg, so that a root of ff becomes a fixed point of gg, and iterate xn+1=g(xn)x_{n+1} = g(x_n) starting from any x0x_0. Both bisection and Newton's method are special cases of this idea with different choices of gg.

Comparing the three root-finding methods
MethodIterationOrder of convergenceRequirement
Bisectionc=a+b2c=\dfrac{a+b}{2}Linear (11)ff continuous, f(a)f(b)<0f(a)f(b)<0
Newtonxn+1=xn−f(xn)f′(xn)x_{n+1} = x_n - \dfrac{f(x_n)}{f'(x_n)}Quadratic (22)ff twice differentiable, f′(r)≠0f'(r) \ne 0, x0x_0 close to rr
Fixed-point iterationxn+1=g(xn)x_{n+1} = g(x_n)Linear (11), generically∣g′(x)∣≤L<1|g'(x)| \le L < 1 near rr

UndergraduateKey theorems

Let ff be continuous on [a,b][a,b] with f(a)f(b)<0f(a)f(b)<0. Then the bisection method produces midpoints xn=an+bn2x_n=\dfrac{a_n+b_n}{2} with xn→rx_n \to r for some root rr in [a,b][a,b], and the error after nn steps satisfies ∣xn−r∣≤b−a2n+1|x_n - r| \le \dfrac{b-a}{2^{n+1}}.

Why is it true?

Every step traps the root inside a shrinking box, and a box that shrinks to a point with a root always inside it must shrink onto the root itself.

Proof

Step 1 (the invariant). Set a0=aa_0=a, b0=bb_0=b. At step nn, we maintain the invariant that f(an)f(bn)<0f(a_n)f(b_n)<0, i.e. the root is trapped somewhere in [an,bn][a_n,b_n]. This holds initially by hypothesis. Given [an,bn][a_n,b_n], compute the midpoint xn=an+bn2x_n=\dfrac{a_n+b_n}{2} and evaluate f(xn)f(x_n): if it has the opposite sign to f(an)f(a_n) set an+1=an, bn+1=xna_{n+1}=a_n,\ b_{n+1}=x_n, otherwise set an+1=xn, bn+1=bna_{n+1}=x_n,\ b_{n+1}=b_n (if f(xn)=0f(x_n)=0 exactly, xnx_n is the root and the process stops). Either way f(an+1)f(bn+1)<0f(a_{n+1})f(b_{n+1})<0 again, so the invariant is preserved by induction.

Step 2 (shrinking width). By construction each new interval is exactly half the previous one, so bn−an=b−a2nb_n-a_n = \dfrac{b-a}{2^n} for every n≥0n \ge 0. Since the root rr lies in [an,bn][a_n,b_n] at every step (by Step 1), and the midpoint xnx_n also lies in [an,bn][a_n,b_n], both are within the same interval of width b−a2n\dfrac{b-a}{2^n} of each other, so ∣xn−r∣≤b−a2n|x_n - r| \le \dfrac{b-a}{2^n} already holds; a slightly sharper count (measuring from the midpoint to either endpoint) gives the stated bound ∣xn−r∣≤b−a2n+1|x_n - r| \le \dfrac{b-a}{2^{n+1}}.

Step 3 (convergence). Since b−a2n+1→0\dfrac{b-a}{2^{n+1}} \to 0 as n→∞n\to\infty, the squeeze from Step 2 forces xn→rx_n \to r. No continuity of ff beyond the initial sign condition is even needed for this part — only for guaranteeing a root existed inside [a,b][a,b] to begin with, which is the Intermediate Value Theorem applied at step 0.

Suppose ff is twice continuously differentiable near a root rr with f′(r)≠0f'(r) \ne 0. Then there is a neighborhood of rr such that, if the Newton iteration starts inside it, the iterates converge to rr and satisfy ∣xn+1−r∣≤C ∣xn−r∣2|x_{n+1}-r| \le C\,|x_n-r|^2 for a constant C=max⁡∣f′′∣2min⁡∣f′∣C=\dfrac{\max|f''|}{2\min|f'|} (the maximum and minimum taken over that neighborhood).

Why is it true?

The tangent line is such a good approximation to a smooth curve that the error it makes is proportional to the square of the distance already traveled, so each correct digit roughly doubles the number of correct digits at the next step.

Proof

Step 1 (Taylor expand around the current guess). Since ff is twice differentiable, Taylor's theorem with the Lagrange remainder gives f(r)=f(xn)+f′(xn)(r−xn)+12f′′(ξn)(r−xn)2f(r) = f(x_n) + f'(x_n)(r-x_n) + \tfrac12 f''(\xi_n)(r-x_n)^2 for some ξn\xi_n between xnx_n and rr. This is exact, not an approximation, because the remainder term carries the full second-order error.

Step 2 (substitute the root condition). Since f(r)=0f(r)=0, the left side vanishes, leaving 0=f(xn)+f′(xn)(r−xn)+12f′′(ξn)(r−xn)20 = f(x_n) + f'(x_n)(r-x_n) + \tfrac12 f''(\xi_n)(r-x_n)^2. Dividing through by f′(xn)f'(x_n) (nonzero near rr since f′(r)≠0f'(r) \ne 0 and f′f' is continuous) isolates r−xnr - x_n: 0=f(xn)f′(xn)+(r−xn)+f′′(ξn)2f′(xn)(r−xn)20 = \dfrac{f(x_n)}{f'(x_n)} + (r-x_n) + \dfrac{f''(\xi_n)}{2f'(x_n)}(r-x_n)^2.

Step 3 (recognize the Newton step). Rearranging, r−(xn−f(xn)f′(xn))=−f′′(ξn)2f′(xn)(r−xn)2r - \left(x_n - \dfrac{f(x_n)}{f'(x_n)}\right) = -\dfrac{f''(\xi_n)}{2f'(x_n)}(r-x_n)^2. The left-hand parenthesis is exactly the Newton update xn+1x_{n+1}, so with en=xn−re_n = x_n - r this reads r−xn+1=−f′′(ξn)2f′(xn) en2r - x_{n+1} = -\dfrac{f''(\xi_n)}{2f'(x_n)}\,e_n^2, i.e. en+1=−f′′(ξn)2f′(xn) en2e_{n+1} = -\dfrac{f''(\xi_n)}{2f'(x_n)}\,e_n^2.

Step 4 (bound the constant). Taking absolute values and bounding ∣f′′(ξn)∣|f''(\xi_n)| and 1/∣f′(xn)∣1/|f'(x_n)| by their extreme values max⁡∣f′′∣\max|f''| and 1/min⁡∣f′∣1/\min|f'| on the neighborhood gives ∣xn+1−r∣≤C ∣xn−r∣2|x_{n+1}-r| \le C\,|x_n-r|^2 with C=max⁡∣f′′∣2min⁡∣f′∣C=\dfrac{\max|f''|}{2\min|f'|}. Once C ∣x0−r∣<1C\,|x_0-r| < 1, this recursion forces ∣xn−r∣|x_n - r| to shrink to 00, proving convergence, and the squaring in ∣xn+1−r∣≤C ∣xn−r∣2|x_{n+1}-r| \le C\,|x_n-r|^2 is exactly the quadratic rate.

Let g:[a,b]→[a,b]g:[a,b]\to[a,b] be continuously differentiable with ∣g′(x)∣≤L<1|g'(x)| \le L < 1 for all x∈[a,b]x\in[a,b]. Then gg has a unique fixed point rr in [a,b][a,b], and for every starting point x0∈[a,b]x_0 \in [a,b] the iteration xn+1=g(xn)x_{n+1}=g(x_n) converges to rr with ∣xn−r∣≤Ln∣x0−r∣|x_n - r| \le L^n |x_0 - r|.

Why is it true?

A slope smaller than one in absolute value means every application of g squeezes points closer together, so no matter where you start, repeated squeezing must collapse the whole interval onto a single point.

Proof

Step 1 (existence via the intermediate value theorem). Let h(x)=g(x)−xh(x)=g(x)-x. Since g(a)∈[a,b]g(a)\in[a,b] we have g(a)≥ag(a)\ge a so h(a)≥0h(a)\ge0, and similarly g(b)≤bg(b)\le b gives h(b)≤0h(b)\le0. Since hh is continuous, the Intermediate Value Theorem gives some rr with h(r)=0h(r)=0, i.e. g(r)=rg(r)=r: a fixed point exists.

Step 2 (uniqueness via the mean value theorem). Suppose r1,r2∈[a,b]r_1,r_2\in[a,b] are both fixed points with r1≠r2r_1\ne r_2. The Mean Value Theorem gives some cc between them with g(r1)−g(r2)=g′(c)(r1−r2)g(r_1)-g(r_2) = g'(c)(r_1-r_2); since g(r1)=r1g(r_1)=r_1 and g(r2)=r2g(r_2)=r_2, this reads r1−r2=g′(c)(r1−r2)r_1-r_2 = g'(c)(r_1-r_2), so ∣r1−r2∣=∣g′(c)∣ ∣r1−r2∣≤L ∣r1−r2∣|r_1-r_2| = |g'(c)|\,|r_1-r_2| \le L\,|r_1-r_2|. Since L<1L<1 and ∣r1−r2∣>0|r_1-r_2|>0, this is a contradiction, so r1=r2r_1=r_2.

Step 3 (contraction at every step). For any xn∈[a,b]x_n\in[a,b], apply the Mean Value Theorem to g(xn)−g(r)g(x_n)-g(r): there is some cnc_n between xnx_n and rr with g(xn)−g(r)=g′(cn)(xn−r)g(x_n)-g(r) = g'(c_n)(x_n-r). Since g(r)=rg(r)=r and xn+1=g(xn)x_{n+1}=g(x_n), the left side is xn+1−rx_{n+1}-r, so ∣xn+1−r∣=∣g′(cn)∣ ∣xn−r∣≤L ∣xn−r∣|x_{n+1}-r| = |g'(c_n)|\,|x_n-r| \le L\,|x_n-r|.

Step 4 (iterate the contraction). Applying Step 3 repeatedly from n=0n=0 gives ∣x1−r∣≤L∣x0−r∣|x_1-r|\le L|x_0-r|, then ∣x2−r∣≤L∣x1−r∣≤L2∣x0−r∣|x_2-r|\le L|x_1-r|\le L^2|x_0-r|, and inductively ∣xn−r∣≤Ln∣x0−r∣|x_n - r| \le L^n |x_0 - r| for every nn. Since 0≤L<10\le L<1, the right side tends to 00 as n→∞n\to\infty, proving xn→rx_n\to r.

UndergraduateReal-World Applications and Worked Examples

Root-finding is the hidden engine behind countless calculations that have no closed-form answer. Engineers use Newton's method to solve nonlinear systems in structural and circuit design; finance uses it to back out an unknown interest rate from a bond price or an implied volatility from an option price; computer graphics uses it to intersect rays with implicit surfaces; and every scientific calculator computes 2\sqrt{2} or a cube root by running a few steps of Newton's method internally. Bisection, being foolproof, is the fallback used inside root-finding libraries whenever Newton's method risks diverging.

Example: Bisection for a cubic equation with no algebraic root formula

A mechanical system's equilibrium position satisfies x3−x−2=0x^3-x-2=0. Using the interval [1,2][1,2] (where f(1)=−2<0f(1)=-2<0 and f(2)=4>0f(2)=4>0), perform two bisection steps and report the resulting midpoint x2x_2.

Solution

Step 1: compute the first midpoint. x0=1+22=1.5x_0 = \dfrac{1+2}{2} = 1.5, and f(1.5)=1.53−1.5−2=−0.125<0f(1.5) = 1.5^3 - 1.5 - 2 = -0.125 < 0, so the root lies in [1.5,2][1.5, 2] since ff changes sign there (f(1.5)<0f(1.5)<0, f(2)>0f(2)>0).

Step 2: compute the second midpoint. x1=1.5+22=1.75x_1 = \dfrac{1.5+2}{2} = 1.75, and f(1.75)=1.753−1.75−2=1.609375>0f(1.75) = 1.75^3 - 1.75 - 2 = 1.609375 > 0, so the root lies in [1.5,1.75][1.5, 1.75].

Step 3: compute x2x_2. x2=1.5+1.752=1.625x_2 = \dfrac{1.5+1.75}{2} = 1.625.

Step 4: interpret. After only two steps the search interval has shrunk from width 11 to width 0.250.25, and x2=1.625x_2=1.625 is already within 0.1250.125 of the true root r≈1.5214r\approx1.5214, consistent with the error bound ∣x2−r∣≤2−123=0.125|x_2-r|\le \dfrac{2-1}{2^{3}}=0.125 from the bisection theorem.

Example: Newton's method computing a square root by hand

Before calculators, engineers computed square roots this way: to find 5\sqrt{5}, apply Newton's method to f(x)=x2−5f(x)=x^2-5 starting from x0=2x_0=2, and compute x1x_1 and x2x_2.

Solution

Step 1: set up the iteration. Here f(x)=x2−5f(x)=x^2-5 and f′(x)=2xf'(x)=2x, so the Newton update is xn+1=xn−xn2−52xnx_{n+1}=x_n-\dfrac{x_n^2-5}{2x_n}.

Step 2: compute x1x_1. With x0=2x_0=2: x1=2−22−52⋅2=2−−14=2.25x_1 = 2 - \dfrac{2^2-5}{2\cdot2} = 2 - \dfrac{-1}{4} = 2.25.

Step 3: compute x2x_2. With x1=2.25x_1=2.25: x2=2.25−2.252−52⋅2.25=2.25−0.06254.5≈2.236111x_2 = 2.25 - \dfrac{2.25^2-5}{2\cdot2.25} = 2.25 - \dfrac{0.0625}{4.5} \approx 2.236111.

Step 4: interpret. The true value is 5≈2.236068\sqrt{5}\approx2.236068, so x2x_2 is already correct to four decimal places after just two steps — the number of correct digits roughly doubled from x1x_1 to x2x_2, the signature of quadratic convergence proved above.

Starting bisection on [a,b]=[0,1][a,b]=[0,1] and performing n=5n=5 iterations, what is the guaranteed bound on ∣x5−r∣|x_5 - r|?

Which formula correctly gives one step of Newton's method?

A bond trader uses Newton's method to solve a nonlinear pricing equation P(y)=0P(y)=0 for the yield yy, starting from a guess y0y_0. Which situation is most likely to make the iteration fail to converge?

For the fixed-point iteration xn+1=g(xn)x_{n+1} = g(x_n) on [a,b][a,b] to be guaranteed to converge to a fixed point for any starting x0∈[a,b]x_0 \in [a,b], which condition is required?