In the meanwhile I found the answer: integral works initially with 150 evaluations of the integrand. In the example I found problematic, machine precision is reached already in this initial configuration.
Problem with tolerances in integral
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!