0
I am reading a book titled "Homotopy Analysis Method in Nonlinear Differential Equation" by Shijun Liao. In chapter 13 Application in Finance: American Put Option, there is appendix about mathematica code of the chapter. However, I do not have Mathematica butMatlab instead and I wish to rewrite the code in Matlab.
Here is the first part of the Mathematica code:
<<Calculus`Pade`;
<<Graphics`Graphics`;
(* Define approx[f] for Taylor expansion of f *)
approx[f_] := Module[{temp},
temp[0] = Series[f, {t, 0, OrderTaylor}]//Normal;
temp[1] = temp[0] /. t^(n_.)*Derivative[j_][DiracDelta][0] -> 0;
temp[2] = temp[1] /. t^(n_.)*DiracDelta[0] -> 0;
temp[3] = temp[2] /. DiracDelta[0] -> 0;
temp[4] = temp[3] /. Derivative[j_][DiracDelta][0] -> 0;
temp[5] = N[temp[4],60]//Expand;
If[KeyCutOff == 1, temp[5] = temp[5]//Chop];
temp[5]
];
I know from Wolfram Reference site that Series[f,{x,x0,n}] generates a power series expansion for f about the point x=x0 to order (x-x0)^n. Thus, I need to construct a power series of expansion for f. However, as far as I know, in matlab, we have to define the f first, for example f=cos(x), etc. So, my question is, How to constuct Taylor expansion of arbitrary function in Matlab?
Thanks in advance.
Try a matlab support forum, they have scientists and mathematicians. – barlop – 2016-06-19T23:28:49.803