尝试使用Olver的方法,我的代码正在运行但是我想尝试将3个函数组合成使用diff()的多输出函数但是我努力操纵投入不会危及产出。
% Defining the function in the equation f(x)=0
function y = f(x)
y = x-exp(1/x);
end
% Defining the derivative of the function in the equation f(x)=0
function y = fd(x)
y = 1+exp(1/x)/(x^2);
end
% Defining the second derivative of the function in the equation f(x)=0
function y = fdd(x)
y = exp(1/x)*(2*x+1)/(x^4);
end
答案 0 :(得分:0)
目前还不是很清楚,但将所有这些作为单一功能(使用符号工具箱)可以按如下方式进行:
function [y1, y2, y3] = getDerivatives(a)
syms f(x)
f(x) = x-exp(1/x);
fd = diff(f,x);
fdd = diff(f,x,2);
y1 = double(f(a));
y2 = double(fd(a));
y3 = double(fdd(a));
end
您可以按如下方式运行它:
[y1, y2, y3] = getDerivatives(1)
y1 =
-1.7183
y2 =
3.7183
y3 =
-8.1548