How do I refine my integration?

1 view (last 30 days)
DM
DM on 27 Jan 2015
Commented: DM on 1 Feb 2015
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.
  1 Comment
Star Strider
Star Strider on 27 Jan 2015
What function are you numerically integrating?
What makes you skeptical about the results?

Sign in to comment.

Accepted Answer

Mike Hosea
Mike Hosea on 1 Feb 2015
Edited: Mike Hosea on 1 Feb 2015
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.
  1 Comment
DM
DM on 1 Feb 2015
Thank you Mike you are always helpful and clear for questions regarding integral. I was wondering if you give my other question a look:
I would appreciate it.

Sign in to comment.

More Answers (2)

John D'Errico
John D'Errico on 27 Jan 2015
Huh? You have given us NO information to help you, except that you are doing an integration. I find myself left with many questions, any or all of which point to entirely possible factors, including the last one I mention.
- What is the kernel?
- What did you try?
- Are you using the tools improperly?
- Do you just have the tolerances set improperly for the problem you are trying to solve?
- Have you set the limits too wide?
- Is this just a very difficult problem to integrate?
- Is your kernel highly nonlinear? Are there singularities?
- Do you just have no clue as to how to use a numerical integration tool?
I'm sorry, but I have no idea what your capabilities are, so the last is entirely plausible since you have given us no information at all.
So you could read the help for those tools, which would tell you how to use them in great detail, including how one would set tolerances. I know, real men don't need no steenkin help.

Youssef  Khmou
Youssef Khmou on 27 Jan 2015
Edited: Youssef Khmou on 27 Jan 2015
Accurate result is obtained if you use the same sampling rate,as the original function, in integral.

Community Treasure Hunt

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

Start Hunting!