Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Matlab中构造任意函数的泰勒展开式?_Matlab_Wolfram Mathematica - Fatal编程技术网

如何在Matlab中构造任意函数的泰勒展开式?

如何在Matlab中构造任意函数的泰勒展开式?,matlab,wolfram-mathematica,Matlab,Wolfram Mathematica,我正在读廖世军的《非线性微分方程中的同伦分析方法》一书。在第13章金融应用:美式看跌期权中,有本章关于mathematica代码的附录。但是,我没有Mathematica,而是Matlab,我希望用Matlab重写代码 以下是Mathematica代码的第一部分: <<Calculus`Pade`; <<Graphics`Graphics`; (* Define approx[f] for Taylor expansion of f *) approx[f_] := M

我正在读廖世军的《非线性微分方程中的同伦分析方法》一书。在第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]
];
0;
temp[5]=N[temp[4],60]//展开;
如果[KeyCutOff==1,temp[5]=temp[5]//Chop];
温度[5]
];
我从Wolfram的参考站点知道,级数[f,{x,x0,n}]在点x=x0到阶数(x-x0)^n处生成f的幂级数展开式。因此,我需要为f构造一个幂级数展开式。然而,据我所知,在matlab中,我们必须首先定义f,例如f=cos(x),等等。因此,我的问题是,如何在matlab中构造任意函数的泰勒展开


提前感谢。

查看符号工具箱中的泰勒函数