You are on page 1of 2

Homework No.7, 550.386, Due April 15, 2016.

1. This problem concerns the general 2nd-order Runge-Kutta method discussed in


the course notes, with
F (x, y, h; f ) = 1 f (x, y) + 2 f (x + h, y + hf (x, y))
where 1 = 1 2 , = =

1
22

and 2 is a constant to be determined.

(a) Show that the coefficient


"
c2 (2 ) =

1 1
2 2
6 2

2


+

1
2
3

2


+

1 1
2 2
6 2

2 #1/2

which appears in the truncation error estimate achieves its minimum value c2 = 0
for 2 = 3/4. We call this the optimal 2nd-order
Runge-Kutta method. Show for

Heuns method with 2 = 1/2 that c2 = 6/12 instead.


(b) By modifying the MATLAB script heun.m, write a script mrk2.m to implement instead the optimal 2nd-order method with 2 = 3/4. Apply your code to the following
test problem:
y = 4y y 2 /5, y(0) = 1
with exact solution Y (t) = 20/(1 + 19e4t ) on the time-interval [0, 2], using a number
of steps N = 4, 8, 16, ..., 2048. By considering the ratio of successive errors in the final
value y(2) verify that this method is indeed asymptotically 2nd-order.
(c) For the same test problem as in part (b), plot the error over the time interval
[0,2] for the optimal 2nd-order Runge-Kutta method. Also plot the error for Heuns
method applied to the same problem. Are your results consistent with part (a)?
2. (a) Modify the MATLAB script heun.m to implement Heuns method improved
with local Richardson extrapolation at each timestep. That is, use the improved
update
y (tn+1 ; h) = y(tn + h; h) [y(tn + 2h; 2h) y(tn + 2h; h)]/6.
where y(tn + jh; h) for any positive integer j is the output of Heuns method started
at y (tn ; h) with j steps of size h.
(b) Apply your code to solve the initial-value problem
y = 4y y 2 /5, y(0) = 1
1

with exact solution Y (t) = 20/(1 + 19e4t ) on the time-interval [0, 1], using a number
of steps N = 4, 8, 16, ..., 2048. Use the results to estimate the order of convergence of
the method. Does your finding make sense from the derivation of the extrapolated
Heun method?
(b) For the same problem as in (b), compare the results of the extrapolated Heun
method with N = 256 steps and of the classical 4th-order Runge-Kutta method also
with N = 256 steps. Compare the two methods for running time. Compare also
for accuracy, by plotting the errors versus time for both methods with logarithmic
spacing for the errors (use semilogy in Matlab). Explain your observations.
3.(a) Using the Heun method, numerically solve the problem
y 0 = y + t0.1 [1.1 + t],

y(0) = 0

whose exact solution is Y (t) = t1.1 . Using a number of steps N = 50 2i , i = 1, ..., 7


increasing by factors of 2, solve the equation numerically for t [0, 5] and plot the
errors over that interval for each N . Also, calculate ratios by which errors in y(5)
decrease for successive approximations. How do your observations compare with the
usual theoretical rate of convergence of O(h2 )? Explain your results.
(b) Repeat part (a) using the classical 4th-order Runge-Kutta method.

You might also like