Closed dandanua closed 4 years ago
In general, numerical integration methods like this work best for smooth functions, and the error estimation may not be accurate for non-smooth functions like your fmax
function.
You will get much more accurate results in many fewer function evaluations if you partition your integration domain into pieces where the integrand is smooth.
Closing this since I don't know of any way to improve the error estimation for non-smooth integrands.
I must say that the error estimation is not very trustful. The following code
outputs
The results differ in 8th digit, while the estimated error is 3e-14