Cohort: Summer 2024 Instructions: This is a Computational Finance mini project, comprising TWO (2) questions, to be completed using Python. C++ is also allowed, but Excel/VBA is not permitted.
nding and understanding the relevant lectures, Python labs and tutorials in module 3; as well as the Python labs, ability to experiment and demonstrate initiative in mathematical and numerical methods, willingness to work outside narrow instruction that are typical of maths based tests/exams. Queries to Zendesk
Tasks
- Outline: The model problem is
(1)
subject to the boundary conditions y (a) = ; and y (b) = :
Suppose a = x0 < x1 < x2 < < xn 1 < xn = b represents a regular partition of the interval
b a
[a;b]: This means xi = a + ih; where i = 0;1;2;:::;n and x = : The points n
x1 = a + x; x2 = a + 2x;:::;xn 1 = a + (n 1)x
are called interior mesh points of the interval [a;b]: We can approximate the derivative terms using a Taylor series expansion. Let
yi = y (xi); Pi = P (xi); Qi = Q(xi); fi = f (xi)
Using numerical approximations for each derivative term in (1) show that this can be expressed as
: (2)
We know the boundary conditions are
y0 = y (x0) = y (a) = (3) yn = y (xn) = y (b) = : (4)
Show that (2); (3) and (4) can be expressed as a matrix inversion problem Ax = b; and give the forms of A; x and b for an arbitrary value n:
Use the method you have developed above; and n = 10, to solve the following di⁄erential equation problem
:
The coe¢ cients in (2) must be generated inside your computer program using appropriate control structures. Use any Python linear systems function to solve the resulting linear system and output your results in two columns (xi;yi): Repeat the exercise for n = 50;100: What do you notice? Plot a graph for varying n. Also consider an error graph as you can obtain a closed form solution to this problem [40 Marks]
1
- This question is on Monte Carlo integration. Calculate the following i. ii.
Compare your computed solutions to the exact values and show graphically how the error in each case behaves as the random numbers increase. [60 Marks]
Your completed assignment should centre on a report to include, for each question:
Brief outline of the problem and numerical procedure used Results – appropriate tables and comparisons.
Any interesting observations and problems encountered.
Conclusion and references
For a Python Jupyter Notebook, a detailed notebook will become the complete report (writeup, code, results).
Score key
60-65 Pass
66-70 Good
71-79 Very Good
80-89 Excellent
90-95 Outstanding
96+ Exceptional
Note: An assessment of this form di⁄ers from mathematical exercises that can attract full marks. The key above is provided for this reason.
2




