[HELP] A Classical Numerical Computing Question
显示 更早的评论
f(x) = (exp(x)-1)/x; g(x) = (exp(x)-1)/log(exp(x))
Analytically, f(x) = g(x).
When x is approaching to 0, both f(x) and g(x) are approaching to 1. However, g(x) works better than f(x).
% Compute y against x
for k = 1:15
x(k) = 10^(-k);
f(k) =(exp(x(k))-1)/x(k);
De(k) = log(exp(x(k)));
g(k)= (exp(x(k))-1)/De(k);
end
% Plot y
plot(1:15,f,'r',1:15,g,'b');
f(x) actually diverges when x approaches to 0.But shouldn't them be the same??
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Code Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!