0
我試圖通過修改,使E要進行以下工作代碼^ -x會的工作,基本上我試圖修改它,使E 1 -x爲1/E^x的 我真的不是知道怎麼做that..Here是我的代碼..Matlab泰勒級數e^x變換爲1/e^x?
function [result] = eTaylor(x, n)
% approximate e^x
% using first n non-zero terms of the Taylor series
% e^x = 1 + x + x^2/(2!) + x^3/(3!) + x^4/(4!) + ...
% Input arguments:
% x = real argument to function e^x
% n = number of non-zero terms of Taylor series
result = 0.0; term = 1.0;
for i = 1:1:n
result = result + term;
term = term*x/i;
end
您是否正在使用泰勒展開,因爲您正在研究序列和序列,或爲了速度? – 2014-09-30 14:49:49