Part 2
Part 2
Theorem 1.1.1. Suppose f (x) is continuous on [a, b] and f (a)f (b) ≤ 0. Then after n steps the
computed root will insure a maximum possible error of (b − a)/2n+1 .
Note that the theorem implies that at the very worst case the bisection method converges to the
root at the same rate as the sequence {2−n } converges to zero. Depending on the given problem the
method may converge even faster.
The bisection method will work under most circumstances but its convergence rate may be slow.
As a result when programming the method, and any other method which you might program for
that matter, you should allow a maximum number of iterates after which the code should terminate
anyway even though the required tolerance has not been reached yet. This will prevent the algorithm
from getting into infinite loops as well.
Let us now provide a quick overview of advantages and possible disadvantages of the bisection
method. Note that the list below and other similar lists thoughout the text are not intended to be
complete and in some cases may require further arguing.
Advantages:
• Always converges to the root (this is not the case for some other methods which we will
encounter)!
Disadvantages:
• It may converge slowly to the root (especially if we use complicated functions or large starting
intervals).
• An early iteration which is actually quite close to the root may be easily discarded.
Let us start by presenting one of the ways that we can actually obtain such a numerical root
finding scheme. We start by writing the Taylor polynomial for f (x) of first order for x near x∗ :
0 (x − x∗ )2 00
f (x) = f (x∗ ) + (x − x∗ )f (x∗ ) + f (ξ(x))
2
where as usual ξ(x) lies between x and x∗ . Let us denote the root we are trying to find by r. Thus
f (r) = 0. Therefore,
0 (r − x∗ )2 00
0 = f (x∗ ) + (r − x∗ )f (x∗ ) + f (ξ(r)) (1.2)
2
Assuming now that we take x∗ close enough to the true root r then the term (r − x∗ ) is very small
and further (r − x∗ )2 is almost zero! Thus we can disregard the last term in (1.2). As a result, under
this assumption, we obtain the following scheme,
0
0 = f (x∗ ) + (r − x∗ )f (x∗ ).
Therefore rewriting the above and solving for the root r we obtain the famous Newton-Raphson
method,
f (x∗ )
r = x∗ − 0 ∗
f (x )
This gives the idea of how we can iterate an initial guess in order to obtain the root of f :
f (xn−1 )
xn = xn−1 −
f 0 (xn−1 )
The following theorem, without proof, gives a little bit more insight on the conditions under which
we expect the method to converge to the root of the function f (x).
0
Theorem 1.2.1. Suppose f ∈ C 2 ([a, b]). If the root r is in [a, b] and f (r) ≤ 0 then there exists
δ > 0 such that the Newton-Raphson method produces a sequence of iterates {xn }∞
n=1 which converges
to r for any initial approximation x0 which is near the root [r − δ, r + δ].
That is if we choose the initial guess x0 close enough to the root of the function f (x) we are
essentially guaranteed that we will find the true root!
In short the method is implemented as follows:
0
1. Obtain a starting guess x0 and find a formula for the derivative f of f .
f (xn−1 )
xn = xn−1 −
f 0 (xn−1 )
3. Stop if any of the following occurs: required tolerance is reached, maximum iterates exceeded,
0
f (xn−1 ) = 0.
Advantages:
• Fast convergence!
FMN050–Spring 2014. Claus Führer and Alexandros Sopasakis page 6
Disadvantages:
0
• Calculating the required derivative itself f (xn−1 ) for every iteration may be a costly task for
some functions f .
• May not produce a root unless the starting value x0 is close to the actual root of the function.
0
• May not produce a root if for instance the iterations get to a point xn−1 such that f (xn−1 ) = 0.
Then the method fails!
• Bisection method x2 = 6,
As you can see regula falsi got a lot closer to the true solution in just one iteration.
Let’s us then describe in detail how the method is implemented. In essence the algorithm which
we provide below is the same as the bisection method except for the main formula. The pseudo-code
follows:
(xj − xi )
xk = xi − f (xi )
f (xj ) − f (xi )
Although this method is more clever than the bisection method it also have its drawbacks. In fact
it converges very slowly for certain functions which display high curvature. Therefore there exists a
modification which allows a small speed up for such type of functions. We will present this method
in the next section.
Advantages:
Disadvantages:
where TOL denotes a given predefined tolerance. This is the typical way to measure absolute error.
Similarly we might instead wish to measure whether the iterates themselves are converging suffi-
ciently. This is another form of absolute error,
Another possibility is to have a bit more impartial way of measuring differences by using something
called the relative error
|xn − xn−1 |
≤ TOL
xn
Thus, in this later formulation, we try to disengage the size of the values of the iterates by “normal-
izing” them. In essence therefore the above fraction should be less than one when the iteration is
converging.
In all cases, as also mentioned before, we should not simply rely on the tolerance computation
provided above in order to terminate an iteration. We should always include a secondary mechanism
in our iterations which terminates the method once a maximum number of iterations has been
performed.
FMN050–Spring 2014. Claus Führer and Alexandros Sopasakis page 8
(xj − xi )
xk = xi − f (xi )
f (xj ) − f (xi )
and let fi = f (xi ), fj = f (xj ) and fk = f (xk ). Let us also denotes the previous iterate at xk−1
as fk−1 .
5. (Divide fi in half):
Let xj = xk and fj = fk .
If fk−1 · fk > 0 then xk−1 = xk , fk−1 = fk and fi = fi /2. Go to step 2.
6. (Divide fj in half):
Let xi = xk and fi = fk .
If fk−1 · fk > 0 then xk−1 = xk , fk−1 = fk and fj = fj /2. Go to step 2.
Let us now give an example of how the usual and the modified regula falsi method fairs in prac-
tice:
Example:
Suppose f (x) = x2 − 6 and we wish to obtain the root of the function in the interval [2, 3] with an
error not to exceed 10−5 .
Solution:
We start as usual by setting x0 = 2 and x1 = 3. We first implement, for comparison purposes the
usual Regula Falsi method:
Regula Falsi
Now we present the implementation of the modified version of the above for the exact same
problem:
Modified Regula Falsi
Disadvantages:
• Not many, but Newton-Raphson may be still faster if we can apply it.
3. If required tolerance has been reached or maximum number of iterates exceeded then stop with
appropriate message.
As we also showed earlier we expect that in general the convergence of the secant method will be
good but probably not as good as Newton’s method is. In general the Secant method is used in
conjunction with some other method (Bisection) in order to refine the solution and the convergence.
In other words we start our code with the Bisection scheme and then once a certain first tolerance
has been satisfied we pass the result to the Secant (or some other method) for fast and more accurate
resolution of the root.
Example:
Find the root of the function f (x) = x2 − 6 (as usual) in the interval [2, 10] with an accuracy of 10−6 .
Solution:
Lets suppose that we take x0 = 2 and x1 = 10 so that we can compare with results from previous
examples (for that reason we denote a = x0 = 2 and b = x1 = 10).
Disadvantages:
Theorem 1.7.1. If g ∈ C[a, b] and g(x) ∈ [a, b] for all x ∈ [a, b] then g has a fixed point in [a, b].
0
Furthermore assuming g (x) exists on (a, b) and that there exists a positive constant c < 1 such that,
0
|g (x)| ≤ c < 1 for all x ∈ (a, b)
Proof: Lets start by first showing that a fixed point does exist for g as specified in the theorem.
Naturally if g(a) = a or g(b) = b then we are done. Then by contradiction we suppose this is not the
case: i.e. instead we must have that g(a) > a and g(b) < b. Let us now define
h(x) = g(x) − x.
Note that since g(x) and x are both continuous functions then h(x) must also be continuous on [a, b]
and the following must hold:
Therefore by the intermediate value theorem there must exist a r ∈ (a, b) such that h(r) = 0. Thus,
g(r) − r = 0 or g(r) = r in (a, b). That shows existence.
For uniqueness we assume again by contradiction that there exist two different fixed points, say
p and q in [a, b] such that g(p) = p and g(q) = q but p 6= q. Then by the mean value theorem there
must exist a number ξ ∈ (p, q) such that
0 g(p) − g(q)
g (ξ) = (1.3)
p−q
The left hand side of the above however is also equal to |p − q|. Therefore we showed that |p − q| <
|p − q|! Not possible and therefore by contradiction we showed there must exists a single fixed point
for g.
It is very important before you go on solving any problem to first check that a fixed point exists
by applying the theorem above or some other type of logical argument. Now to find such a fixed point
numerically we only need to take a single initial guess x0 and generate iterations by substituting it
into the function g(x) itself. After several such iterations the solution (or an approximation to the
solution) should emerge. The following simple algorithm makes this clear:
xn = g(xn−1 )
3. If required tolerance has been reached or maximum number of iterates exceeded then stop with
appropriate message. Otherwise continue from step 2 above.
How is it possible that this simple scheme works? Isn’t it surprising that you just plug in the previous
iterate into the function and there comes the next iterate which is closer to the true solution?
Let us give an example to further shed light into the idea. In order to make it easier to compare
we will take our usual example f (x) = x2 − 6 = 0 in the interval [2, 10] which we know has a unique
root and arrange it appropriately in order to become a fixed point problem. That is quite easy simply
(but not optimaly) done by adding x on both sides
x2 − 6 + x = x
So now we have a fixed point problem to solve for which we are guaranteed (why?) to have a solution
in the interval [2, 10]:
Example:
Find the fixed point of the following function g(x) = x2 − 6 + x in the interval [2, 10].
Solution:
The solution can now be easily found by applying our pseudocode from above:
n 0 1 2 3 4 ... 11
xn 2 0 −6 24 594 ... ∞
Error 0 −6 24 594 353424 . . . ∞
What happened? We were supposed to obtain a solution to our fixed point problem near 2.4 not ∞!
The problem is the derivative of g. The fixed point iteration method we outlined above failed in this
case. Why? Because in this problem
0
|g (x)| > 1 in the interval [2, 10].
The next theorem gives some guidelines for convergence or divergence of the fixed point iteration
scheme.
FMN050–Spring 2014. Claus Führer and Alexandros Sopasakis page 13
Theorem 1.7.2. Let, as usual, g ∈ C[a, b] and suppose that g(x) ∈ [a, b] for all x ∈ [a, b]. Further
suppose that the derivative exist on (a, b) and
0
g (x) ≤ c < 1 for all x ∈ (a, b)
If we take any initial value x0 ∈ (a, b) then the sequence arising from
xn = g(xn−1 )
Proof: We already know that there must exist a unique fixed point in [a, b] from our previous
theorem. Note now that from the assumption that g(x) ∈ [a, b] for all x ∈ [a, b] we must also have
that all the xn ’s are also in [a, b]. Using (1.3) and the mean value theorem we then must have,
0
|xn − r| = |g(xn−1 ) − g(r)| = |g (ξ)||xn−1 − r| ≤ c|xn−1 − r|
for some ξ ∈ (a, b). We now keep reapplying this inequality on the above and obtain,
Corollary 1.7.3. Suppose g as in Theorem (1.7.2) above. Then the error of our approximating the
fixed point r of g can be estimated by either of the following two formulas:
Proof: Since r is in [a, b] the first formula (1.6) is clear from inequality (1.5).
To prove the second formula (1.7) we need some more work. Note that, as in Theorem (1.7.2),
the following is true,
Therefore for any m > n ≥ 1 by adding and subtracting similar terms the following must be true,