0% found this document useful (0 votes)
274 views3 pages

MTH 600: Assignment 2: Due March. 19 (Thursday), in Lab

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 3

MTH 600: Assignment 2

Winter 2020

Instructor: Wei Xu Office: VIC 709 e-mail: [email protected]


Office Hours: Wei Xu, Mondays 2:00-4:00pm, VIC 709

Due March. 19 (Thursday), in lab

IMPORTANT: A detailed report that contains all relevant parts of the solutions (explanations,
graphs, etc.) and includes documented MATLAB scripts (within the document). Most of the marks
for programming questions are allocated for explanations of algorithms and discussions of results.
If all you hand in is the listing of the “Raw Code” or “Raw Output” by itself, you will get poor
marks. All coding should be done in Matlab (nicely commented). The TA will take off marks
for poor documentation. Penalty for late submission is 10 marks per day (i.e., you will receive
maximum 90 if you submit your assignment on March 19).

Assignment Questions

1. (80 marks) Finite Difference: European Case, constant timesteps


a). Develop Matlab code for pricing European options under a Black Scholes model
dSt
= rdt + σdZt
St
using a finite difference method as discussed in class. Use forward/backward/central differ-
encing as appropriate to ensure a positive coefficient discretization. The code should be able
to use fully implicit, and Crank-Nicolson method.
You will have to solve a tridiagonal linear system. DO NOT use the full matrix objects in
Matlab. Use the Matlab sparse matrix function spdiags to set up a sparse diagonal matrix
of the correct size and use lu Matlab function to solve linear systems. Avoid unnecessary LU
factorization computation.
b). Solve for a European put option, using the data given in the Table 1 , (with fully implicit,
and Crank-Nicolson method ) and compare with the exact solution using blsprice in Matlab.
Use constant timestep sizes.
c). Show a convergence table, with a series of grids. Show the option value at t = 0, S = 100.
Begin with a timestep of ∆τ = T /25, and the grid

S = [0:0.1*K:0.4*K,...
0.45*K:0.05*K:0.8*K,...
0.82*K:0.02*K:0.9*K,...
0.91*K:0.01*K:1.1*K,...
1.12*K:0.02*K:1.2*K,...
1.25*K:.05*K:1.6*K,...
1.7*K:0.1*K:2*K,...
2.2*K, 2.4*K, 2.8*K,...
3.6*K, 5*K, 7.5*K, 10*K];

1
Table 1: Data for Put Example

σ .4
r .02
Time to expiry (T ) 1.0 years
Strike Price $100
Initial asset price S 0 $100

where K is the strike, and we are interested in the solution near S = K.


Note: to carry out a convergence study, you should solve the pricing problem on a sequence of
grids. Each grid has twice as many intervals as the previous grid (new nodes inserted halfway
between the coarse grid nodes) and the timestep size is halved.
Assume that
Error = O((∆t)2 , (∆S)2 ) ; ∆S = max(Si+1 − Si ) (1)
i

Let
h = C1 · ∆S
h = C2 · ∆t
Suppose we label each computation in the above sequence by a set of h values. Then the
solution on each grid (at a given point) has the form
V (h) = Vexact + A · h2
V (h/2) = Vexact + A · (h/2)2
V (h/4) = Vexact + A · (h/4)2 (2)
where we have assumed that the mesh size and timestep are small enough that the coefficient
A in equation (2) is approximately constant. Now, equation (2) implies that
V (h) − V (h/2)
'4 (3)
V (h/2) − V (h/4)
Check the theory by examining the rate of convergence of your pricer.
Carry out the above tests using fully implicit, and Crank Nicolson method. Show a conver-
gence table for each test.
d). Show plots of the option value for the range S = [50, 150], for your solution on the finest
grid for CN method.
Submit your matlab code.
2. (20 marks) Heat Deduction Equation
Consider the following PDE from the heat deduction problem
ut = uxx ,
u(t, 0) = 0, u(t, 1) = 0,
2
u(0, x) = −x + x.

2
a). Provide the algorithm (in pseudo-code) for solving the PDE by the Crank-Niclson method.
b). Implement the algorithm into Matlab code and plot u(t, x) on the grid of (t = [0, 1] ×
[0, 1] = x) with M = N = 50 in constant steps.
Submit your Matlab Code.

You might also like