[Back to main course page]

MTH 451/551
Lecture 4

Prof. W. Pazner

1 Solving Equations and Root Finding

[Textbook reference: §2.1]

We are interested in finding the solution to the system f⁢(x)=0 for some function f⁢(x), i.e. the roots of f. Depending on the specific form of the function f⁢(x), we may, through some complicated algebraic manipulations, be able to find a closed-form expression for the roots. However, this is a laborious process, and we are not always guaranteed to succeed. For example, as mentioned at the beginning of the course, there is no general closed-form expression (written in terms of radicals) for the roots of polynomials of degree 5 or higher. Therefore, it is of great utility to develop algorithms that approximate the roots, using only evaluations of f (and perhaps its derivatives), without symbolic or algebraic manipulations.

1.1 Root Bracketing Methods

Two of the oldest and most basic methods for root finding are the bisection and regula falsi methods, which are both root bracketing methods. This means that if there is a root r of f in the interval (a,b) (we say that a and b bracket the root, since they lie on either side of it), then we generate a nested sequence of intervals (an,bn), each of which contain the root r. Within each interval, we will obtain an approximate root xn that converges to r as n→∞.

1.1.1 The Bisection Method

[Note: we differ slightly from the textbook here by using closed intervals and non-strict inequalities.]

We consider a continuous function f∈C⁢[a,b], such that f⁢(a)⁢f⁢(b)≤0. This means that either f⁢(a) and f⁢(b) have opposite signs, or at least one of them is zero. By the intermediate value theorem, this implies that there exists a root of f in the interval [a,b]. The bisection method generates a sequence xn that converges to a root r∈[a,b].

  1. 1.

    Initialize [a0,b0]=[a,b], x0=(a0+b0)/2.

  2. 2.

    Iterate [an+1,bn+1]={[an,xn]if f⁢(an)⁢f⁢(xn)≤0,[xn,bn]otherwise..

To turn this into a practical algorithm, we need to set some termination criteria. The sequence xn→r, and we need to decide when to stop iterating, and accept the current value of xn as a good enough approximation to r (very rarely we may find xn such that f⁢(xn)=0 exactly, but this does not happen usually). Typically, we set both a tolerance and maximum number of iterations. In the version of the algorithm presented below, we provide two tolerances and a maximum number of iterations. We terminate if either |f⁢(xn)|≤ftol or if |xn−r|≤xtol. Even though we don’t know the exact value of r (if we did, we wouldn’t need an algorithm to approximate it), we can bound |xn−r| since r is guaranteed to lie in every interval we generate.

Pseudocode version of the bisection algorithm: return an approximation xn of a root r∈[a,b] of f⁢(x), given that f⁢(a)⁢f⁢(b)≤0.

1:function Bisection(f,a,b,ftol,xtol,maxit)
2:     x←(a+b)/2
3:     for n=1,2,…,maxit do
4:         if f⁢(a)⁢f⁢(x)≤0 then
5:              b←x
6:         else
7:              a←x
8:         end if
9:         x←(a+b)/2
10:         return x if |f⁢(x)|≤ftol or (b−a)/2≤xtol
11:     end for
12:     Bisection did not converge in maximum number of iterations.
13:end function

The following theorem guarantees that the bisection method always converges to a root, and gives an a priori bound on the error at each iteration.

Theorem 1 (Convergence of the bisection method; Textbook Theorem 2.2).

Suppose that f∈C⁢[a,b] with f⁢(a)⁢f⁢(b)≤0. If {an,xn,bn} is generated by the bisection method, then xn→r∈[a,b], where f⁢(r)=0. Furthermore, we have the error bound

|xn−r|≤2−(n+1)⁢(b−a)for all n.
Proof.

First, we show by induction that f⁢(an)⁢f⁢(bn)≤0 for all n. This holds for n=0 by assumption. Suppose it holds for some n. If f⁢(an)⁢f⁢(xn)≤0, then [an+1,bn+1]=[an,xn], and so f⁢(an+1)⁢f⁢(bn+1)=f⁢(an)⁢f⁢(xn)≤0. Otherwise, f⁢(an)⁢f⁢(xn)>0, so f⁢(an) and f⁢(xn) are nonzero and have the same sign. Since f⁢(an)⁢f⁢(bn)≤0, it follows that f⁢(xn)⁢f⁢(bn)≤0, and so f⁢(an+1)⁢f⁢(bn+1)=f⁢(xn)⁢f⁢(bn)≤0.

By construction, an≤xn≤bn, and the intervals are nested, so

a≤an≤an+1≤bn+1≤bn≤b

for all n. The sequence {an} is nondecreasing and bounded above by b, and the sequence {bn} is nonincreasing and bounded below by a. By the Monotone Convergence Theorem, there exist a¯,b¯∈[a,b] such that an→a¯ and bn→b¯. Furthermore, since each step halves the length of the interval, bn+1−an+1=(bn−an)/2, we see that

bn−an=2−n⁢(b−a)

for all n. Taking the limit as n→∞, we find b¯−a¯=0, and so a¯=b¯. We take r to be this common value.

Since f is continuous at r, we have f⁢(an)⁢f⁢(bn)→[f⁢(r)]2. Since f⁢(an)⁢f⁢(bn)≤0 for all n, the limit must also satisfy [f⁢(r)]2≤0. But clearly [f⁢(r)]2≥0, so we must have f⁢(r)=0.

Finally, since xn is the midpoint of [an,bn] and r∈[an,bn], the distance from xn to r is at most half the length of the interval,

|xn−r|≤bn−an2=2−(n+1)⁢(b−a).

The right-hand side tends to zero as n→∞, and so xn→r. ∎

1.1.2 Regula Falsi

The regula falsi method (latin for false position) is a simple variation on the bisection method. Like bisection, it is a root bracketing method. The “false positions” in this case are the two endpoints, which are generally not roots themselves, but are used to help find the roots. Bisection proceeded by always choosing the midpoint of the interval, leading to a halving of the error bound at every step. This had no dependence on the function f whatsoever. Regula falsi, on the other hand, chooses xn to be the zero of the secant line connecting (an,f⁢(an)) and (bn,f⁢(bn)). This uses more information about the function f, and can often converge much faster than bisection, but lacks the same guaranteed error reduction rate.

The setup is the same as in bisection, except here we require that f⁢(a)⁢f⁢(b)<0 strictly in order for the secant line to have nonzero slope. The method is summarized as follows:

  1. 1.

    Initialize [a0,b0]=[a,b], x0=a0⁢f⁢(b0)−b0⁢f⁢(a0)f⁢(b0)−f⁢(a0).

  2. 2.

    Iterate [an+1,bn+1]={[an,xn]if f⁢(an)⁢f⁢(xn)<0,[xn,bn]otherwise,  xn+1=an+1⁢f⁢(bn+1)−bn+1⁢f⁢(an+1)f⁢(bn+1)−f⁢(an+1).

The formula for xn is the zero of the secant line through (an,f⁢(an)) and (bn,f⁢(bn)). It can equivalently be written as

xn=an−bn−anf⁢(bn)−f⁢(an)⁢f⁢(an)=bn−bn−anf⁢(bn)−f⁢(an)⁢f⁢(bn).

The termination criteria are the same as for bisection, with one important difference. Since r and xn both lie in [an,bn], we can still bound the error by |xn−r|≤max⁡(xn−an,bn−xn). However, unlike in bisection, the length of the interval [an,bn] does not necessarily go to zero. Often, one of the endpoints will stay fixed for all iterations. In that case, this error bound will never drop below xtol, and the iteration will be terminated by ftol (or maxit) instead.

Pseudocode version of the regula falsi algorithm: return an approximation xn of a root r∈(a,b) of f⁢(x), given that f⁢(a)⁢f⁢(b)<0.

1:function RegulaFalsi(f,a,b,ftol,xtol,maxit)
2:     x←(a⁢f⁢(b)−b⁢f⁢(a))/(f⁢(b)−f⁢(a))
3:     for n=1,2,…,maxit do
4:         if f⁢(a)⁢f⁢(x)<0 then
5:              b←x
6:         else
7:              a←x
8:         end if
9:         x←(a⁢f⁢(b)−b⁢f⁢(a))/(f⁢(b)−f⁢(a))
10:         return x if |f⁢(x)|≤ftol or max⁡(x−a,b−x)≤xtol
11:     end for
12:     Regula falsi did not converge in maximum number of iterations.
13:end function

The following theorem guarantees that the regula falsi method always converges to a root. In contrast to the bisection method, there is no a priori bound on the error.

Theorem 2 (Convergence of the regula falsi method; Textbook Theorem 2.7).

Suppose that f∈C⁢[a,b] with f⁢(a)⁢f⁢(b)<0. If {an,xn,bn} is generated by the regula falsi method, then xn→r∈(a,b), where f⁢(r)=0.

Proof.

We only consider the non-trivial case, where f⁢(xn)≠0 for all n. We lose no generality by assuming that f⁢(a)<0 and f⁢(b)>0, which guarantees that f⁢(an)<0 and f⁢(bn)>0 for all n. In particular, xn is well-defined, and since the secant line changes sign between an and bn, we have an<xn<bn.

As in the proof for bisection, {an} is nondecreasing and {bn} is nonincreasing, so an→a∗ and bn→b∗ for some a∗≤b∗. By continuity, f⁢(a∗)≤0≤f⁢(b∗). If a∗=b∗, then we take r to be this common value, and f⁢(r)=0 and xn→r by the same argument as for bisection.

Suppose instead that a∗<b∗. Since xn is either an+1≤a∗ or bn+1≥b∗, no xn lies in the interval (a∗,b∗). If f⁢(a∗)≠f⁢(b∗), then by continuity,

xn→x∗=a∗⁢f⁢(b∗)−b∗⁢f⁢(a∗)f⁢(b∗)−f⁢(a∗).

If f⁢(a∗)=0, then x∗=a∗, and we take r=a∗. Similarly, if f⁢(b∗)=0, then x∗=b∗, and we take r=b∗. If both f⁢(a∗)<0 and f⁢(b∗)>0, then x∗ lies strictly between a∗ and b∗, which is impossible, since no xn lies in (a∗,b∗). The only remaining possibility is f⁢(a∗)=f⁢(b∗)=0 with a∗<b∗. This is clearly impossible if f has only one root in (a,b); the general case is more involved (see textbook §2.1, Exercise 13). ∎