Lecture03 PDF
Lecture03 PDF
Instructor: Professor Amos Ron Scribes: Yunpeng Li, Mark Cowlishaw, Nathanael Fillmore
Our problem, to recall, is solving equations in one variable. We are given a function f , and
would like to find at least one solution to the equation f (x) = 0. Note that, a priori, we do not
put any restrictions on the function f ; we do need to be able to evaluate the function: otherwise,
we cannot even check that a given solution x = r is true, i.e., that f (r) = 0. In reality, the mere
ability to be able to evaluate the function does not suffice. We need to assume some kind of “good
behavior”. The more we assume, the more potential we have, on the one hand, to develop fast
algorithms for finding the root. At the same time, the more we assume, the fewer functions are
going to satisfy our assumptions! This is a fundamental paradigm in Numerical Analysis.
Recall from last week that we wanted to solve the equation:
x3 = sin x or
(1)
x3 − sin x = 0
We know that 0 is a trivial solution to the equation, but we would like to find a non-trivial
numeric solution r. In a previous lecture, we introduced an iterative process for finding roots of
quadratic equations. We will now generalize this process into an algorithm for solving equations
that is based on the so-called fixed point iterations, and therefore is referred to as fixed point
algorithm. In order to use fixed point iterations, we need the following information:
2. We need to know approximately where the solution is (i.e. an approximation to the solution).
2. Start with an initial guess x0 ≈ r, where r is the actual solution (root) of the equation.
1
Using this fact, we can prove our claim:
Thus, g(r) = r, and since the equation g(x) = x is equivalent to the original one f (x) = 0, we
conclude that f (r) = 0.
Note that, for proving this claim, we had to make some assumption on g (viz, g is a continuous
function). This follows the general pattern: the more restrictions we put on a function, the better
we can analyze the function numerically.
The real trick of fixed point iterations is in Step 1, finding a transformation of the original
equation f (x) = 0 to the form x = g(x) so that (xn )∞ 0 converges. Using our original example,
x3 = sin x, here are some possibilities:
sin x
1. x = x2
√
3
2. x = sin x
3. x = sin−1 (x3 )
sin x−1
4. x = x2 +x+1
+1
x3 −sin x
5. x = x − 3x2 −cos x
sin(x)
0.8
0.6
0.4
0.2
−0.2
−0.4
−0.6
−0.5 0 0.5 1 1.5
x
We can start with x0 = 1, since this is a pretty good approximation to the root, as shown in
Figure 1. To choose the best function g(x), we need to determine how fast (and if) xn converges to
a solution. This is key, because different transformations of a single f (x) = 0 to x = g(x) can result
in a sequence of xn that diverges, converges to the root slowly, or converges to the root quickly.
One good way to measure the speed of convergence is to use the ratio of the errors between
successive iterations. The error at iteration n can be defined as:
en := xn − r (2)
2
where r is the actual solution (an alternative definition, is en := |xn − r|.) To measure the rate of
convergence, we can take the ratio µn+1 between the error at iteration n + 1 and the error at the
previous iteration:
en+1 xn+1 − r
µn+1 := = (3)
en xn − r
However, as you may have noticed, we are using the actual solution r, which we do not know,
to calculate the error en and the ratio µn . For as long as we do not know r , we can approximate
the error en = xn − r ≈ xn − xn−1 , and thus we can calculate the error ratio as:
en+1 xn+1 − xn
µn+1 = ≈ (4)
en xn − xn−1
Note that the magnitude of the error ratio is what is important, so we can safely ignore the
sign.
for some fixed constant c < 1. We will study algorithms that converge much more quickly than
this, in fact, we have already seen an algorithm (the square root algorithm) that has quadratic
convergence.
3
It is important to note that equations 5, 6, and 7 provide lower bounds on the convergence rate.
It is possible that an algorithm with quadratic convergence will converge more quickly than the
bound indicates in certain circumstances, but it will never converge more slowly than the bound
indicates. Also note that these bounds are a better indicator of the performance of an algorithm
when the errors are small (en ≪ 1).
1 and 4, respectively), the algorithm does converge to 0.92862630873173 with the error ratio µn
far less than 1. However, when we choose g(x) = sin x2
x
, the error ratio is greater than 1 and the
3
iteration do not converge. For g(x) = x + sin x − x , the error ratio is very close to 1. It appears
that the algorithm does converge to the correct value, but very slowly.
Why is there such a disparity in the rate of convergence?
4
numerically. We previously assumed g to be continuous; now we raised the bar and assume it to
be differentiable.
We would like to see how g is behaving in the area around the solution, r. For this, we will use
the Taylor expansion with remainder. Remember that, for any differentiable function g, and for
any two values x, a, there exists c such that
We don’t know what the precise value of c is, but we know that it exists and is between a and
x.
en+1 = xn+1 − r
= g(xn ) − g(r)
(10)
= (xn − r) · g′ (cn ) cn between xn and r
= en · g′ (cn )
As xn approaches r, cn (which is between xn and r) is getting closer to r, and, therefore
g′ (cn )
≈ g′ (r). This means that if |g′ (r)| > 1, once xn gets close enough to r, the error will get
larger, and the sequence x0 , x1 , x2 , . . . will never converge.
This suggests a straightforward test to see if a particular function g is a poor choice for fixed
point iterations. Simply check the numerical values of g′ in some interval that is known the contain
the solution r. If |g′ (x)| > 1 on this interval, then the sequence of x0 , x1 , x2 , . . . will not converge
and g is a poor choice.
For example, if we look at g(x) = sin x
for x ∈ [.9, 1], we see that |g′ (x)| is greater than 1 over
√ x2
the interval. If we look at g(x) = 3 sin x on the same interval, its derivative√is around .23 there.
This explains why the choice g(x) = sin x2
x
failed in our experiment and g(x) = 3 sin x produced nice
results.
for some constant λ, then we will have convergence, as long as our values xi stay in the interval I.
We can quantify this with the following two claims:
Claim 2.1. If ∀c∈ I 1 > λ ≥ g′ (c) ≥ 0 then the sequence x0 , x1 , x2 , . . . stays in interval I, and will
converge to the root r.
5
Proof. Assume that x is our present approximation of r, and assume by induction that is lies in the
interval I. Our next approximation is g(x) and once we show that it also lies in the interval, our
inductive proof will go through (our initial x0 lies in I by assumption!). Now, our error analysis
shows that g(x) = g(r) + (x − r)g′ (c), for some c between x and r. Now, x ∈ I, by induction, and
r ∈ I by assumption, hence c ∈ I, hence 0 < g′ (c) < 1. Also, g(r) = r. Altogether,
so, g(x) is an average of r and x, with positive weights, hence lies between x and r hence lies in I.
The above induction proves that all the iterative values x0 , x1 , . . . lie in I. Our error analysis
then can be applied to show that we have convergence, since everywhere in I g′ < λ < 1.
g(x 0)
g(x)
r x 1 x0 x1 r x0
x0 − a x0 + a
x 0 − 2a x 0 − a x0 + a x 0 + 2a
Figure 2: Examples of Convergence for Functions g with Positive and Negative Slope
If the derivative of g is not positive on I, it is possible that the iterations do not stay inside I,
and hence the fact that g′ is small enough on I may not suffice. However, once we assume that r ∈ I
(as before), while g′ is small enough on a slightly larger interval, convergence can be guaranteed:
Claim 2.2. If r ∈ I as before, and, with I ′ := [x0 − 2δ, x0 + 2δ], ∀c ∈I ′ |g′ (c)| ≤ λ < 1, then
x0 , x1 , x2 , . . . converges to r.
Proof. We need to prove that the iterations x0 , x1 , . . . stay in I ′ : since g′ is small enough on I ′ , our
previous error analysis will show that the error decreases by at least a factor of λ per iteration.
Now, x0 surely lies in I ′ . Assume by induction that x0 , . . . , xn−1 all lie in I ′ . Then, the errors
e0 , e1 , . . . en decrease (in magnitude), hence |en | < |e0 | < δ. This means that xn lies in (r − δ, r + δ).
The latter interval may not be a subset of I, but is surely a subset of I ′ since r ∈ I. So, xn ∈ I ′ ,
hence |en+1 | < δ, and our induction continues successfully.
6
2.3 Testing for Convergence
First, a small aside. One might question the value of all this convergence analysis in practice. For
example, how can we test the derivative near the root when, by assumption - since this is what
we’re trying to find - we don’t know where the root is? The answer is that often even when we
don’t know the precise location of the root (say, to 10 decimal places), we can easily
√ get a rough
estimate
√ of where the root is. For example, we may not know an exact value for
√ 5, but we know
that 5 ∈ [2.2, 2.3] (well, those of us that do not know this, should know that 5 ∈ [2, 2.5]...) We
can use this estimate to check the derivative. For example, let our fixed point equation be
x2 + 5
x= = x/2 + 2.5/x,
2x
√
(whose solution is 5). Then
g′ (x) = 1/2 − 2.5/x2 .
Now, choose x0 := 2.25, and take δ = 1/8. Then I ′ = [2, ′ ′
√ 2.5], and if x ∈ I , then g (x) ∈ [−.125, .1].
Also, I = [2.125, 2.375]. So, it is enough to know that 5 ∈ I (indeed), to invoke our test theorem
above and to conclude that the iterations will converge (fast, since g′ is really small on I ′ ).
So the theory does have a practical value.
(x − a)2
g(x) = g(a) + g′ (a) · (x − a) + g′′ (c) (11)
2
Using our equation for error and substituting Equation 11 yields:
en+1 = xn+1 − r
= g(xn ) − g(r)
e
n
z }| {
′ ′′ (xn − r )2
= g (r)(xn − r) + g (cn ) 2 (some cn ∈ I)
′′ e2n
= g (cn ) 2 (since g′ (r) = 0)
1. An improved algorithm (fixed point iterations with a special function g with g′ (r) = 0).
These are two independent issues. Constructing a transformation of the original equation
f (x) = 0 to x = g(x) with g′ (r) = 0 is dependent only on our sophistication in transforming f , and
is under our control. However, the regularity of g is something that we have little control over. If
g is twice differentiable, it will, almost surely, imply that f has the same property. If f is a “bad”
7
function (i.e. not differentiable enough), only a miracle will produce a doubly differentiable g.
Without such a miracle, g will not be regular enough, and the error analysis which led to quadratic
convergence will no longer be valid. Moral: do not expect that good algorithms perform well on
bad functions. In particular, if f is not twice differentiable, do not waste your time to find g with
g′ (r) = 0, since you are not likely to get quadratic convergence.