Professional Documents
Culture Documents
Ass 1
Ass 1
(e) Use the dialog box to choose a Matlab file that you want to submit and then click the ’Upload this file’
button.
(f) Repeat Step (e) until all the files you want to submit have been uploaded.
Don’t forget to upload all the functions that are used by your scripts.
Your Matlab files will be run by the markers so make sure all the necessary files are uploaded.
1. Write a Matlab script to solve the initial value problem
on the interval [0, π] using the Runge-Kutta-Felberg method with adaptive step–length control. The
step–length should be constrained to lie inside [hmin , hmax ] = [1/100, 1/4] and your program should
try to keep the estimated local truncation error smaller in magnitude than δ = 10−7 if that is possible.
Your program should
(a) use the value h = hmin as a starting step-length,
(b) plot the numerical solution it has computed,
(c) record and plot the history of step-lengths used,
(d) record the history of the local truncation relative error estimates, |ej /uj | and plot the vector z where
zj = − log10 (|ej /uj |),
(e) plot the vector w of values of true generalized relative error (the exact solution is y = e−x sin x) of the
numerical solution,
(f) display kzk∞ and kwk∞ .
The exact solution is:
Solution to y(x)’’’+p(x)y’’(x)+q(x)y’(x)+r(x)y(x)=s(x)
0.35
0.3
0.25
0.2
y→
0.15
0.1
0.05
−0.05
0 0.5 1 1.5 2 2.5 3 3.5
x→
2. Let a = 2, b = 4 and β = 1.75. Write and run a Matlab script which uses an explicit finite difference
scheme given in lectures to numerically solve the wave equation
and
(a) the boundary conditions
Use a grid that has 30 steps in the space direction and 120 steps in the time direction.
Your submission should include the derivation of your scheme, with particular attention to the boundary
conditions, and the plots of the solutions.
[Hint: think carefully before proceeding - it’s not quite as simple as it might look]