MAM1043H_Tutorial7_Solns

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

U NIVERSITY OF C APE T OWN

MAM1043H Modelling and Applied Computing PDL 2022


T UTORIAL 7 PARTIAL S OLUTIONS – A DDITIONAL TAYLOR
S ERIES AND ROOT F INDING I

Exercises
For the following exercises, also try and find the roots using Binary Search, Fixed Point Iteration,
Newton’s Method and the Secant Method – don’t only stick to the method that’s required for the
particular question. First do all problems by hand, and find all roots correct to four decimal places.

1. Find the Taylor series up to the term in x4 for ln x about the point x = 3. What is the coeffi-
f (3) (3)
cient of the term in x3 ? Hint: the term in x3 not only given by (x − 3)3 .
3!
1 1 1 1
A NSWER : Here, ln x ≈ ln 3 + (x − 3) − (x − 3)2 + (x − 3)3 − (x − 3)4 .
3 18 81 324
An x3 -term is contained in both the (x − 3)4 and (x − 3)3 brackets, so these need to be
multiplied out. Simplification of the above polynomial gives
25 4 1 4 1 4
ln 3 − + x − x2 + x3 − x .
12 3 3 81 324
The coefficient needed follows trivially.
2. If we use T2 for ln x about the point x = 3 to approximate ln 5, what is the bound on the error
in the approximation?
1 1
A NSWER : From the above, we know that T2 (x) = ln 3 + (x − 3) − (x − 3)2 , and so
3 18
by Taylor’s Theorem,
f (x) = ln x = T2 (x) + R2 (x),
where
f (3) (c)
R2 = (x − 3)3 , c ∈ (3, x).
3!
We’re trying to approximate f (5) with T2 (5), so we have x = 5 and a = 3.
By Taylor’s Theorem, we know that
M
|R2 (5)| ≤ |5 − 3|3 ,
3!
where we’ll choose M to be the maximum value of | f (3) (z)| on the interval z ∈ (3, 5) (note
here that z is simply a dummy variable – we could call it anything else. We don’t want to use
x again as it’s already been used before!).

1
2 2
Differentiating, we find that f (3) (x) = 3
, so clearly | f (3) (x)| = 3 . Now we evaluate
x x
(3) (3)
| f (3)| and | f (5)| (these are the only two values we must check because we know that
2/x3 is a decreasing function for x > 0).
Clearly, | f (3) (3)| is the bigger of the two, so we’ll set

2
M = | f (3) (3)| = .
27
Thus,
1 2 8
|R2 (5)| ≤ · (2)3 = .
3! 27 81
8
⇒ |R2 (5)| ≤ .
81
This is the required error bound.

3. Find the root of the equation x4 + x3 − 22x2 − 2x + 41 = 0 in the interval [1, 2] correct to six
decimal places.

A NSWER : x ≈ 1.435476.

4. Explain why Newton’s Method does not work for finding the roots of the equation x3 − 3x +
6 = 0 if the initial approximation is chosen to be x0 = 1. Will the Secant Method work if we
start with x0 = 0 and x1 = 1?

A NSWER : Here, we identify f (x) = x3 − 3x + 6, so f 0 (x) = 3x2 − 3, which is zero at x = 1.


Because of this, Newton’s Method won’t work for x0 = 1, as f 0 (x) is zero at the initial guess.

5. Calculate 5 12 correct to five decimal places using Newton’s Method and the Secant Method.
Take your starting interval as [1, 2] for Binary Search and the Secant Method.

5
A NSWER : Here, you want x = 12 ⇒ x5 − 12 = 0 is the non-linear equation you’ll want to
solve. Of course, x ≈ 1.64375.

3
6. Show that Newton’s Method fails when applied to find the root of f (x) = x with any initial
approximation x0 6= 0. Will Binary Search work here to find the root?
√ 1
A NSWER : We’re given f (x) = 3 x and we then have that f 0 (x) = x−2/3 . Substitute this
3
into the Newton’s Method formula and simplify to get:

xn+1 = −2xn .

Remember that the division by xn is done under the assumption that xn 6= 0. Now, regardless
of the choice of x0 we make, this iteration will always produce a divergent sequence. So,
we’re actually forced to make the choice that x0 = 0, even though we’ve originally assumed

2
that this would never be the case. So this is a problem function, and serves to illustrate when
Newton’s Method can fail.
One reason for Newton’s Method failing here is because f 0 (x) = 13 x−2/3 , which does not exist
at x = 0 at all ( f has a vertical tangent there). Roots at vertical tangents will cause problems
with Newton’s Method in general. So it’s best to use something else like the Secant Method
or Binary Search.
The Desmos applet at https://www.desmos.com/calculator/kgwfrkiyh8 can help with
visualisation of this particular problem. Note that this is a non-zero-rated link!
1
7. Apply Newton’s Method to the equation − a = 0 to derive the following “reciprocal”
x
algorithm:
xn+1 = 2xn − axn 2 ,
which is what your calculator does to find reciprocals without actually dividing. Now use
your answer above to compute 1/1.6984 correct to six decimal places.

A NSWER : Since 1/x = a ⇔ x = 1/a for a 6= 0, you’ll want x = 1/1.6984 ⇒ a = 1.6984


in the reciprocal algorithm. You should find that x ≈ 0.588789.

8. Consider the iteration


xn+1 = 2xn − axn 2 ,
in the context of a general fixed point iteration, xn+1 = g(xn ).

(a) Find its fixed points, x? .


1
A NSWER : The two fixed points are x? = 0 and x? = .
a
(b) Determine the stability of the fixed points by finding their multipliers.

A NSWER : Here, we have g(x) = 2x − ax2 , so g0 (x) = 2 − 2ax.


λ ≡ g0 (0) = 2, so x? = 0 is unstable since |λ| > 1.
1
For x? = , λ = 0, so this fixed point is stable since 0 ≤ |λ| < 1.
a
(c) Sketch a cobweb diagram to show these fixed points’ stabilities graphically.

A NSWER : See figure 1.

9. Use Fixed Point Iteration to solve the equation xe−x = 0.2.

(a) Use a graphing programme to sketch the curves of y = xe−x and y = 0.2 on the same
set of axes and determine how many roots there are to the equation above, and roughly
estimate their values.

A NSWER : 2 roots. Check using a graphing programme.

3
2

-2

-4

-6

-8

-10

-3 -2 -1 0 1 2
Figure 1: The cobweb diagram for xn+1 = 2xn − axn 2 , for a = 1. Fixed points are denoted by green
circles. Note that x? = 0 is unstable, while x? = 1 is stable.

(b) Rewrite the equation above in the form x = g(x), and hence, determine what the itera-
tion xn+1 = g(xn ) should be – there will be two!

A NSWER : Two possible iterations are xn+1 = 0.2exn and xn+1 = ln xn − ln 0.2.
(c) Use both iterations to determine the root(s) of the equation – which iteration works best
for which root(s)?

A NSWER : Playing around here with the Octave code will show you that the itera-
tion containing the exponential converges to the smaller root, x ≈ 0.259171, while the
one containing the logarithms converges to the larger root, x ≈ 2.54264. Note, however,
that for some choices of x0 , the latter iteration can also converge to the smaller root –
investigate this.

(d) Now, try the solution using Newton’s Method and Binary Search.

A NSWER : Try this one yourself!


10. Given the equation x4 − x = 10.
(a) Find its two roots (one positive and one negative) using the provided Newton’s Method

4
script. Set the tolerance to 10−6 .

A NSWER : Check this one yourself by using the provided script.


(b) Show that the two iterations
10
xn+1 = 3 −1
xn
and p
4
xn+1 = 10 + xn
can be derived from the above equation. Can you come up with another?

A NSWER : Two other possible iteration are

xn+1 = xn 4 − 10

and p
xn+1 = − 4 10 + xn .
(c) For the two given iterations above, what are their fixed points, approximately?

A NSWER : The fixed points will be the roots of the equation x4 − x = 10, but we need
to be careful here – not all of the fixed points will be valid for all of the iterations! They
are approximately at x? ≈ −1.697471880884864 and x? ≈ 1.855584561010884, which
could be found using Newton’s Method (for example).
The negative root, as a fixed point, isn’t valid for the second iteration at all (check this
graphically). If we wanted
√ to use this particular root as a fixed point, we’d have to use
the iteration xn+1 = − 4 10 + xn instead.
(d) Determine the stability of the fixed points in each of the iterations. Which iteration
would be useful for finding the roots of the original equation?

A NSWER : For the first iteration,

30x2
g0 (x) = − ,
(x3 − 1)2

so we get that λ ≈ −3.556675041335422 ⇒ |λ| > 1 for x? ≈ 1.855584561010884, so


this fixed point is unstable.
We also get λ ≈ −2.490758435568659 ⇒ |λ| > 1 for x? ≈ −1.697471880884864, so
this fixed point is also unstable.
So this iteration won’t work at all for finding the roots of the original equation! (This
is assuming we only knew this iteration and none of the roots beforehand.)
For the second iteration,
1
g0 (x) = p ,
4 (10 + x)3
4

5
so we get that λ ≈ 0.039128912630971 ⇒ |λ| < 1 for x? ≈ 1.855584561010884, so
this fixed point is stable.
We can only use this second iteration to find the positive root (assuming that we didn’t
know it beforehand), as x? ≈ 1.855584561010884 is the only fixed point here. Confirm
this graphically.
(e) Sketch the cobweb diagrams for each iteration, showing what happens to an arbitrary
initial guess, x0 .

A NSWER : Do this yourself.

You might also like