(Note: I am new to mathematica)
I am using this code Apoh.txt in combination with APO-48-10.txt
It has prints but i would like to know how i can plot this? I know there is a plot function inside the code but its not yielding a plot when i run it.
update: Instead of <<APO-48-10.txt; i use Get["c:...\APO-48-10.txt"];
However no input dialogs appears when i run the code :(
(*Using the new command of Mathematica 8.0.*)Pade := PadeApproximant;
(*input dimensionless results given by means of the HAM*)
<< APO-48-10.txt;
Print["--------------------------------------------------------------"\
];
Print["OrderTaylor = ", OrderTaylor];
Print["OrderHAM = ", OrderHAM];
Print["--------------------------------------------------------------"\
];
APOh[Order_] :=
Module[{temp, n, i, j, s}, Print[" OrderTaylor = ", OrderTaylor];
Print[" strike price = ?"];
temp[0] = Input[];
X = IntegerPart[temp[0]*10^10]/10^10;
Print[" risk-free interest rate = ?"];
temp[0] = Input[];
r = IntegerPart[temp[0]*10^10]/10^10;
Print[" volatility = ?"];
temp[0] = Input[];
sigma = IntegerPart[temp[0]*10^10]/10^10;
Print[" time to expiry (year) = ?"];
temp[0] = Input[];
T = IntegerPart[temp[0]*10^10]/10^10;
gamma = 2*r/sigma^2;
texp = sigma^2*T/2;
Bp = X*gamma/(1 + gamma);
Print["--------------------------------------------------------------"\
];
Print[" INPUT PARAMETERS: "];
Print[" Strike price (X) = ", X, " ($) "];
Print[" Risk-free interest rate (r) = ", r];
Print[" Volatility (sigma) = ", sigma];
Print[" Time to expiry (T) = ", T, " (year)"];
Print["--------------------------------------------------------------"\
];
Print[" CORRESPONDING PARAMETERS: "];
Print[" gamma = ", gamma];
Print[" dimensionless time to expiry (texp) = ", texp // N];
Print[" perpetual optimal exercise price (Bp) = ", Bp // N,
"($)"];
Print["--------------------------------------------------------------"\
];
Print[" CONTROL PARAMETERS: "];
Print[" OrderTaylor = ", OrderTaylor];
Print[" c0 = ", c0];
Print["--------------------------------------------------------------"\
];
For[n = 1, n <= Min[Order, OrderHAM], n++, Print[" n = ", n];
temp[0] = X*BB[n] /. t -> (sigma^2*t/2) // Expand;
B[n] = Collect[temp[0], t];
If[NumberQ[gamma], temp[0] = BB[n] /. t^i_. -> s^(2*i);
temp[1] = Pade[temp[0], {s, 0, OrderTaylor, OrderTaylor}];
BBpade[n] = temp[1] /. s^j_. -> t^(j/2);
Bpade[n] = X*BBpade[n] /. t -> (sigma^2*t/2);];
If[NumberQ[gamma] && NumberQ[sigma] && NumberQ[X],
Print[" Optimal exercise price at the time to expiration = ",
B[n] /. t -> T // N];
Print[" Modified result given by Pade technique = ",
Bpade[n] /. t -> T // N];];];
Print["Well done"];
If[NumberQ[gamma] && NumberQ[sigma] && NumberQ[X],
n = Min[Order, OrderHAM];
Plot[{Bp, B[n], Bpade[n]}, {t, 0, 1.25*T},
PlotRange -> {0.8*Bp, X},
PlotStyle -> {RGBColor[1, 0, 0], RGBColor[0, 1, 0],
RGBColor[0, 0, 1]}];
Print[" Order of homotopy-approximation : ", n];
Print[" Green line : optimal exercise boundary B in polynomial
Attachments: