Homework Assignment #2

(due: April 22 in class)

Theory Part

Problem 1 (40%):
Show that Heun's method is of order 2 and not order 3.
(Hint: Proceed similar as in the derivation of the midpoint method; Write down T(3)(t,y) (Taylor Method of order 3), and compare to Taylor expansion (second order Taylor polynomial) of a1*f(t,y) + a2*f(t+alpha2, y +delta2*f(t,y)); Can you match all coefficients ? If yes, you have a third order method. If no, you have to decide which coefficients you can match. the remaining terms contribute to the truncation error.)

Problem 2 (10%):
Show that the following initial value problem is well posed:
dy/dt = 1 + y/t
1 <= t <= 2
y(1) = 2

Numerics Part

Problem 3 (50%):
Solve the initial value problem given in 2) numerically. The analytic solution to this problem is given by y(t) = t*ln(t) + 2*t.

a) Employ the midpoint method with h = 0.2, 0.1, 0.05. Discuss the behaviour of the solution as a function of h, and compare it to the analytic solution. Does the error (for the final value at t=2) scale with h as you would expect ? Estimate the order of the method from the error.
b) Which value of h do you need to choose (approximately) to achieve an accuracy of 0.0001 for the final value of y(t) ?
c) Obtain a numerical solution for this problem using Euler's method. Use the same values for h as in a). Again, estimate the order of the method from the error. Compare the errors obtained with the 2 different methods.
d) Which value of h do you need to choose (approximately) with Euler's method to achieve an accuracy of 0.0001 for the final value of y(t) ?
e) Compare the results of b) and d). Assume that the Midpoint method needs twice as much CPU time per timestep (since two evaluations of the derivative are needed). What does the comparison of the error tell us about the efficiency of the 2 methods (in terms of CPU time) ?


Hint: It is recommended that you write scripts where the derivative f(t,y) is called as a function. This will make it easier for you to "recycle" your scripts in future homework assignments.

You should turn in the following:
- plots of of y(t) as a function of t for parts a) and c).
- a short table when you discuss the errors of midpoint and Euler's method.
- a copy of the scripts you were using for Euler's and midpoint method.