Problem with tolerances in integral

1 visualización (últimos 30 días)
Mario
Mario el 15 de Ag. de 2018
Respondida: Mario el 17 de Ag. de 2018
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!

Respuesta aceptada

Mario
Mario el 17 de Ag. de 2018
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.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by