## 0 Reputation

13 years, 332 days

## suggestion...

This is what I've done in this question:

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, sigma:=0.2

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. Note that the k here is different to the capital K above in the f[i,j] equation.

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 in the sense that maple recognises each statement and agrees with it.

This is the part where I am having trouble with,

I was to insert an if statement which I did using p:=(k,j)->`if`(k = 0, max(K-j*S, 0), g[k, j]);

which would give me back a value of the max(K-j*Delta S,0) if k=0 or else if k is not equal 0 then it would return a value for g[k,j]. So if i entered the values p(1,1) I should get a numerical value for g[1,1]. This is the problem because I am not getting numerical values for g[1.1]. The coding is wrong somewhere and I need somebody to help me fix it.

I have attacthed the maple file below if this helps

Explicit_Finite_Dif.mw

## suggestion...

This is what I've done in this question:

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, sigma:=0.2

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. Note that the k here is different to the capital K above in the f[i,j] equation.

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 in the sense that maple recognises each statement and agrees with it.

This is the part where I am having trouble with,

I was to insert an if statement which I did using p:=(k,j)->`if`(k = 0, max(K-j*S, 0), g[k, j]);

which would give me back a value of the max(K-j*Delta S,0) if k=0 or else if k is not equal 0 then it would return a value for g[k,j]. So if i entered the values p(1,1) I should get a numerical value for g[1,1]. This is the problem because I am not getting numerical values for g[1.1]. The coding is wrong somewhere and I need somebody to help me fix it.

I have attacthed the maple file below if this helps

Explicit_Finite_Dif.mw

## @acer  This is not the third posti...

This is not the third posting of this. The 2 other previous posts refer to the implicit finite difference method for option pricing.

This post referes to the explicit finite difference method for option pricing. A different method for pricing options and therefore it required a new post in which there are different things being asked.

 Page 1 of 1
﻿