Problem with tolerances in integral
显示 更早的评论
While evaluating an integral with expensive computation of the integrand, I tried the adaptive integration provided by the integral function. Unfortunately the function seems not to accept the desired (lower) tolerance argument, if the integral is not improper as in the example from the help file. Instead of taking the desired tolerance, integral seems to work with default tolerance in any case. I give a minimal example for illustration:
if true
% code
f = @(t) log(t);
I_true1 = -1;
I_true2 = 3*log(3)-2*log(2)-1;
for k = 2:2:12
epsi = 10^(-k);
I1 = integral(f,0,1,'RelTol',0,'AbsTol',epsi);
I2 = integral(f,2,3,'RelTol',0,'AbsTol',epsi);
fprintf('%1.1e %1.4e %1.4e\n', epsi, abs(I1-I_true1), abs(I2-I_true2))
end
end
producing the output
1.0e-02 1.7536e-07 1.1102e-16
1.0e-04 1.7536e-07 1.1102e-16
1.0e-06 1.0960e-08 1.1102e-16
1.0e-08 1.7124e-10 1.1102e-16
1.0e-10 6.6880e-13 1.1102e-16
1.0e-12 1.0214e-14 1.1102e-16
Has anyone an idea how to change this behaviour? Thanks in advance for your help!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!