Question: Finite Difference Method

Can anybody please help :

a_j := [-1/2 (r-q) j Delta t + 1/2 sigma^2 j^2 Delta t] / 1 + r Delta t

b_j := [1 - sigma^2 j^2 Delta t] / 1 + r Delta t

c_j := [1/2 (r-q) j Delta t + 1/2 sigma^2 j^2 Delta t] / 1 + r Delta t

 

with r:= 0.05, Delta t:= T/N , Delta S:=S/M, T:=0.4, q:=0, K:=1.1, S:=2, M=N:=10

 

Then I defined i:=N; such that f_{i,j}:=max(K - j*Delta S, 0);

And next I defined g_{k,j}:=f_{i,j} with k:=N-i because maple requires I work from 0 -> N not from n -> 0 which is what I need. So g_{k,j}:=a_j*g_{k-1,j-1} + b_j*g_{k-1,j} +c_j*g_{k-1,j+1} which all works fine.

 

Next was to insert the if statement which I did using p:=(k,j)->`if`(k = 0, max(k-j*S, 0), g[k, j]); which seemed to work as when I inserted p(0,1) I got 0.900 which is correct.

 

but when I inserted p(1,1) it gave me just g_{1,1} not the answer in digits is what I want.

 

All subscripts and superscripts are correct here

I am a complete novice at maple and I would like somebody with some knowledge of maple to help me where I've gone wrong.

The problem has to do with Finite Difference Explicit Option pricing method

 

Thanks

Please Wait...