MATH2033 Introduction to Scientific Computation Coursework 2

Ace your studies with our custom writing services! We've got your back for top grades and timely submissions, so you can say goodbye to the stress. Trust us to get you there!


Order a Similar Paper Order a Different Paper

MATH2033
Introduction to Scientific Computation
Coursework 2
This coursework is due by 23:59 on Friday the 5th of June 2020
The folder containing this file also contains the files interpolant.m, population.m, differentiation.m,
integration.m, forwardEuler.m and errorEuler.m. To do this coursework, you should add to
these files but should not rename them and should not modify the lines that are already in them.
Via Moodle, you should submit a single compressed folder (in 7z, gz, tar, or zip format) whose name
is your student number and which contains your completed version of these 6 files. Each question is
worth 2.5% of your final mark in this module. However, a penalty may be applied to your mark in
this coursework for not following these instructions and the standard penalties for late submissions
will be applied.
This coursework should be your own individual work. However, it is acceptable for parts of
your codes to have been copied from the MATLAB files that are on the Introduction to Scientific
Computation (MATH2033 UNNC) (FCH1 19-20) Moodle page. It is also acceptable for you to ask
the MATH2033 lecturer questions about the coursework during class. If he decides to answer your
question then the answer will be given to all students in attendance. The lecturer will not answer
any questions about the coursework that are asked outside of class.
1. Add to the file interpolant.m to write an interpolant function that does what is described
in this paragraph. The arguments to the interpolant function are vectors a and b with at
least n+1 entries which are such that the first n+1 entries of a are distinct, a positive integer
n and a vector x. The interpolant function should return the vector p which has the same
number of entries as x and is such that, for all positive integers i which are less than or equal
to the number of entries in x, p(i) is the value at x(i) of the polynomial of degree at most
n which passes through the points (a(j),b(j)) for all positive integers j which are less than
or equal to n+1. The interpolant function should not display anything to the command
window if the line in which it is used ends with a semicolon.
2. The population of mainland China, according to the censuses conducted, in the years 1953,
1964, 1982, 1990, 2000 and 2010 is given in the table below.
year population of mainland China
1953 582603417
1964 694581759
1982 1008175288
1990 1133682501
2000 1265830000
2010 1339724852
Add to the file population.m to write a population script that uses the interpolant
function to plot:
• the linear polynomial that passes through the data points for the years 1953 and 1964;
• the quadratic polynomial that passes through the data points for the years 1953, 1964
and 1982;
• the cubic polynomial that passes through the data points for the years 1953, 1964, 1982,
1990;
• the quartic polynomial that passes through the data points for the years 1953, 1964,
1982, 1990 and 2000;
• the quintic polynomial that passes through the data points for the years 1953, 1964,
1982, 1990, 2000 and 2010.
on the same figure for the years from 1950 to 2020. You should use a different colour for each
polynomial and should not use black to plot the polynomials. On top of these polynomials
plot the data given in the table as six individual points that are circles whose boundary and
interior are black. Label the axes. Put a legend on the figure which does not cover up anything
that you have plotted. Your legend should identify each polynomial as “linear interpolant”,
“quadratic interpolant”, “cubic interpolant”, “quartic interpolant” or “quintic interpolant”.
The population script should not display anything to the command window. You should not
submit your plot.
3. Add to the file differentiation.m to write a differentiation function that does what is
described in this paragraph. The arguments to the differentiation function are a function
handle f of a function that implements an appropriate function f, a real number x, a positive
real number h and a number n which can be −1, 0 or 1. Using no more of the values of f than
f(x−h), f(x) and f(x+h), the differentiation function should return the approximation
a to f

(x) that is:
• the backward difference approximation to f

(x) if n= −1;
• the central difference approximation to f

(x) if n= 0;
• the forward difference approximation to f

(x) if n= 1.
The differentiation function should not display anything to the command window if the
line in which it is used ends with a semicolon.
4. Add to the file integration.m to write a integration function that does what is described
in this paragraph. The arguments to the integration function are a function handle f of a
function that implements an appropriate function f, real numbers a and b which are such that
a<b, a positive integer n and a number m which can be 0, 1 or 2. The integration function
should return the approximation A to Z
b
a
f(x) dx obtained using:
• the composite midpoint rule with n strips of equal width if m= 0;
• the composite trapezoidal rule with n strips of equal width if m= 1;
• the composite Simpson’s rule with n strips of equal width if m= 2.
The integration function should not evaluate f any more times than is necessary. The
integration function should not display anything to the command window if the line in
which it is used ends with a semicolon.
5. Let y be the solution to the initial value problem
y

(t) = f(t, y(t)), a ≤ t ≤ b,
y(a) = c.
Add to the file forwardEuler.m to write a forwardEuler function that does what is described
in this paragraph. The arguments to the forwardEuler function are a function handle f of a
function that implements an appropriate function f, real numbers a and b which are such that
a<b, a real number c and a positive integer N. The forwardEuler function should return the
approximation yN to y(b) obtained using the forward Euler method with a stepsize of b − a
N
.
The forwardEuler function should not display anything to the command window if the line
in which it is used ends with a semicolon.
6. Let y be the solution to the initial value problem
y

(t) = f(t, y(t)), a ≤ t ≤ b,
y(a) = c.
Add to the file errorEuler.m to write a errorEuler function that does what is described
in this paragraph. The arguments to the errorEuler function are a function handle f of a
function that implements an appropriate function f, a function handle y of a function that
implements y, real numbers a and b which are such that a<b, a real number c and a positive
integer N. The errorEuler function should use the forwardEuler function to plot a loglog
plot of the absolute value of the error in the approximation to y(b) obtained using the forward
Euler method with a stepsize of h =
b − a
2
0
,
b − a
2
1
, . . . ,
b − a
2
N
on an appropriately labelled
figure. The errorEuler function should not return anything. The errorEuler function
should not display anything to the command window. You should not submit your plot.

Writerbay.net

Looking for top-notch essay writing services? We've got you covered! Connect with our writing experts today. Placing your order is easy, taking less than 5 minutes. Click below to get started.


Order a Similar Paper Order a Different Paper