【发布时间】:2016-04-18 12:09:25
【问题描述】:
我正在看廖世军的《非线性微分方程中的同伦分析方法》一书。在第13章金融应用:美式看跌期权中,有关于该章mathematica代码的附录。但是,我没有 Mathematica 而是 Matlab,我希望在 Matlab 中重写代码。
这是 Mathematica 代码的第一部分:
<<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]
];
我从 Wolfram 参考网站知道 Series[f,{x,x0,n}] 为 f 生成一个关于点 x=x0 的幂级数展开,以排序 (x-x0)^n。因此,我需要为 f 构造一个幂级数展开。但是,据我所知,在matlab中,我们必须先定义f,例如f=cos(x)等。所以,我的问题是,如何在Matlab中构造任意函数的泰勒展开?
提前致谢。
【问题讨论】:
标签: matlab wolfram-mathematica