Worksheet 04
Worksheet 04
You may also use scripts and use REPL to evaluate them. In that case, please keep all your files for a
particular worksheet in a folder and you may upload the compressed archive of that folder.
dy
=p
dt
dp
= −4π 2 y
dt
define simple harmonic motion with period 1.
(a) (8 points) Use Euler and Midpoint methods to solve the equations using h = 0.01 from tini = 0
to tfinal = 15. The given initial condition is y(0) = 1.0 and p(0) = 0.0. Plot the solutions along
with the exact solution.
(b) (2 points) Now choose h = 10.0n for n = −4 to n = −2 in steps of 0.2. For each h, keep
tfinal fixed and solve the above equations using the two methods. For each h, for each method,
estimate the error of the position value of the final point (absolute deviation from the exact
solution).
(c) (2 points) Plot and fit log10 h versus log10 of the error with a straight line to estimate the errors
of each of the method.
Page 1