Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

SCHOOL OF COMPUTER SCIENCE

7077 System Modelling and Simulation Assignment 1


Due at the lecture May 3rd.
The answers to the assignments for this course come in two components
• a hand–written part with the mathematics, explanations and commentary for what you have done and
• text files of the Matlab scripts and functions you have written.
To submit the assignment you will have to
• give the lecturer the hand–written documents at the lecture on the due date and
• submit your Matlab files through a system called Moodle before 10pm on the due date.
Both the hand–written work and the Matlab file(s) MUST have your name and student ID as the first
line. There also MUST be a comment in each file you submit saying which question of which assignment this
file is for. Your hand–written submission MUST also have the names of all the files you have uploaded through
Moodle.
Here are the instructions for uploading your Matlab .m files to Moodle for this assignment.
(a) Go to the web page at http://forums.cs.adelaide.edu.au/course/view.php?id=349
(b) Enter your university username (e.g. a1234567) and password.
(c) You will, if you have not already done so, be invited to enrol (on Moodle) for this course. Go ahead
and enrol.
(d) After you have enrolled you will see a ’Weekly Outline’ page which shows Assignment 1 in the week of
2 May – 8 May. Click on the Assignment 1 link and you will see the following dialog box.

(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

y 000 − e−x y 00 − 2y 0 + y = e−x (2e−x cos x + 5 sin x),


y(0) = 0, y 0 (0) = 1, y 00 (0) = −2

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

(2.1) utt = β 2 uxx

over the interval [0, a] with the initial conditions

(2.2) u(x, 0) = x(2 − x), ut (x, 0) = 1, ∀x ∈ [0, a]

and
(a) the boundary conditions

(2.3) u(0, t) = t/2, u(a, t) = 0

(b) and then again with the boundary conditions

(2.4) u(0, t) = t/2, u(a, t) = − sin(4t/π).

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]

You might also like