I started decoding the code by part. It seems the way I started generating table d2 is problem. So I thinking about using alternative way. Can you pl help in finding efficient way to replace part of matrix? i want to replace 1st row of the matrix fd below using logic fd [0, nts-1] = (1- intratedt2) fd [ 0, nts] . The elements in the 1st row to be replaced backward using intrate and dt2. I am getting error
optionprice[strike1, nas1, expn1, vol1, int_] :=
Module[{ds, s, dt, dt1, t, nts, fd},
ds = 2*strike1/nas1;
dt = 0.9/(vol1vol1nas1* nas1) ;
nts = IntegerPart [expn1 /dt] + 1;
dt1 = expn1/nts;
s = Table[i*ds, {i, 0, nas1 + 1}];
t = Table [j*dt1, {j, 0, nts}];
fd = ConstantArray[1, {nas1 + 1, nts}];
fd = ReplacePart[fd, {i_, nts} :> Max[(s[[i]] - strike1), 0]];
fd = Do [
ReplacePart[fd, {1, j} :> (1 - intdt1)fd[[1, j + 1]]], {j,
nts - 1, 1, -1}];
Grid[fd]
]