MATLAB: How to refine the integration

integrationnumerical integration

I am using integral and integral2 functions to numerically integrate, I am however very skeptical about the results. I was wondering how would one make the results more accurate? Any options that can make the answere more accutare.

Best Answer

I don't disagree with John at all, but here are some things that come to mind that you might do to either lend credence to, or to discredit the results you are getting, as the case may be.
if the region is finite and you are using the 'auto' method, then you can specify the 'iterated' method to perform an independent calculation using a different method.
integral2(f,a,b,c,d,'method','iterated')
Unfortunately, if any of the limits are infinite, it automatically chooses the iterated method, so of course specifying the iterated method won't change anything in that case.
Secondly, you can manipulate the tolerances. E.g.
integral2(f,a,b,c,d,'AbsTol',1e-12,'RelTol',1e-12)
Obviously this is intended to increase the accuracy of the output, but it assumes that the output is already accurate to approximately the degree implied by the default tolerances. If that is not the case, then you should not expect that this will necessarily have any effect. However, it might help the integrator to catch some variability in the integrand that it previously glossed over. This is more of a negative test in the sense that if you tighten the tolerances and they answer changes wildly, then you have problems, but if you tighten the tolerances and nothing changes, it doesn't mean anything.
Third, you can subdivide the region yourself into smaller pieces and add up the integrals over the smaller pieces. Especially try to put any interesting behavior on the boundary of a sub-integral. Getting consistent results no matter how you subdivide the region is a good sign.
Fourth, there are 3rd-party integrators written for MATLAB that can be downloaded from the file exchange. Some of them could provide independently computed results that would either lend credence to the results MATLAB is returning or cast doubt on them. If you have a smooth integrand, some of them can use quite high orders.
Related Question