You are on page 1of 2

EP501 Numerical Methods Homework 4 Due Oct 25, 2013 11:59 pm

1 Finite Difference (25 points)


Combine the Taylor expansions of fi−2 , fi−1 , fi+1 , and fi+2 , to obtain a centered difference formula for the
second derivative f 00 that has a global truncation error (total error) of order h4 . Show all your work.

2 Integration (30 points + 10 extra credit)


a. Write two MATLAB functions for evaluating definite integrals of arbitrary functions. One uses the
composite trapezoidal rule and the other uses the composite Simpson’s 1/3 rule.
b. Use them to evaluate the integral Z π
sin x dx. (1)
0
Confirm the order of these methods by plotting the true absolute error vs. number of subintervals. That
is, evaluate it using 1, 2, 4, 8, · · · subintervals. You can use the built-in function to evaluate sin x as the
true value. Since the error should be proportional to some power of h, it is useful to use a log-log plot.
The slope is then the power of h.
c. (Extra credit) Evaluate the integral using the Romberg integration scheme. Calculate R44 for the integral.

3 Interpolation (15 points)


Let P3 (x) be the interpolating polynomial for the data (0, 0), (0.5, y), (1, 3), and (2, 2). The coefficient of x3
in P3 (x) is 6. Find y.

4 Round-off Error (30 points)


In class, we discussed the truncation errors of various numerical differentiation method. For example, the
first derivative can be approximated with the centered difference as ((13) in Lecture12)

f (xi + h) − f( xi − h) 1 (3)
f 0 (xi ) = + f (ξ)h2 . (2)
2h 6
In practice, we will also have round-off errors when evaluating function values f (xi +h) and f (xi −h). Assume
the round-off errors are e(xi + h) and e(xi − h), respectively, then the total error of the approximation is

e(xi + h) − e(xi − h) 1 (3)


Error = + f (ξ)h2 . (3)
2h 6
If we assume that the round-off error e(xi ± h) are bounded by ε > 0 and f (3) (ξ) is bounded by a number
M > 0, then
ε h2
Error ≤ + M. (4)
h 6
a. Find the optimal value of h that gives the smallest error, expressed in terms of ε and M .
b. Calculate the approximated value of f 0 (0.9), where f (x) = sin x, using (2). Compare the approximation
with the true value f 0 (0.9) = cos(0.9) for h ranging from 10−8 to 10−4 . You can generate a series of h
values using MATLAB statement

h=10.ˆ(-8:0.001:-4);

This way log(h) is linearly distributed.

1
EP501 Numerical Methods Homework 4 Due Oct 25, 2013 11:59 pm

c. Plot the absolute value of the error as a function of h, using loglog function. Describe what you observe,
and explain why.
d. Based on your answer to a, check if the result in d is consistent. You will need to find values of M and
ε first..
This phenomenon is called round-off error instability.

You might also like