【问题标题】:How to construct Taylor expansion of arbitrary function in Matlab?如何在Matlab中构造任意函数的泰勒展开?
【发布时间】: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


    【解决方案1】:

    查看符号工具箱中的泰勒函数http://www.mathworks.com/help/symbolic/taylor.html

    【讨论】:

      猜你喜欢
      • 2013-10-09
      • 2019-06-15
      • 2017-04-02
      • 2017-06-14
      • 2014-06-11
      • 2020-04-10
      • 2021-07-10
      • 2019-09-24
      • 2011-12-06
      相关资源
      最近更新 更多