I am working on a problem that requires precision. I am using integral and hoping I can get enough precision at a reasonable speed by adjusting reltol and abstol.
Anyways, it's made me generally curious about integral with sensitive problems. Say I have something of the form
integral(@(x) f_1(x),a,b) + integral(@(x) f_2(x),c,d)
where (a,b) and (c,d) are different. In general, for better accuracy, is it better to write it like above or use Heaviside step functions inside the integrand to write that as one integral?
I ask because the algorithm for say, abstol, tries to minimize abs(q-Q). By the triangle inequality, abs((q_1+q_2)-(Q_1+Q_2)) <= abs(q_1-Q_1) + abs(q_2-Q_2) so you would think it's better to combine for better accuracy. I realize that run time is a whole other issue. I'm mostly wondering if my hypothesis is true that accuracy is improved by combining integrands into one integral call.
Thank you.
Best Answer