0
$\begingroup$

What methods are available to integrate a sharply peaked function (position of peak known) on a finite interval (the interval includes the peak)?

Currently I am getting underflows using some of GSL's adaptive algorithms. I suspect that GSL fails to find the position of the peak, and hence is thinks that the function is mostly zero. Is there a method in GSL so that I can tell where the peak is located? Or maybe I can use an alternative routine (it doesn't have to be GSL)?

$\endgroup$
  • 1
    $\begingroup$ What is the function? Can you plot its graph or do you know its closed form? $\endgroup$ – Bill Barth Apr 20 '15 at 13:18
  • $\begingroup$ I hope a general solution is possible in which the specific form of the function can be obviated. However, if you need the details, this is the sort of function I am trying to integrate: stats.stackexchange.com/q/147321/5536 $\endgroup$ – becko Apr 20 '15 at 14:45
  • $\begingroup$ @becko Can you tell us what "large $\alpha_i$, $\beta_i$" means? From your question at stats, the function is a polynomial, no? If you know the peak (and you know there is only one), why not use the adaptive GSL routine with integration end-points close to the peak? You could add some iteration by gradually increasing the integration interval and stop at convergence.... $\endgroup$ – GertVdE Apr 20 '15 at 17:27
  • $\begingroup$ @GertVdE It is not a polynomial, since $\alpha,\beta$ are not integers in general. I tried splitting the integration interval in two at the position of the peak, but it didn't help. Perhaps I am using the wrong GSL function (currently I am using gnu.org/software/gsl/manual/html_node/…). $\endgroup$ – becko Apr 21 '15 at 12:38
7
$\begingroup$

If you know where the peak is, then you can always split the interval. For example, if you know that the peak is at $a$ and has a "width" (however you want to define that) of $\sigma$ so that you can say that it is mostly confined within $[a-\sigma,a+\sigma]$, then split the integral as $$ \int_l^u f(x) \; dx = \int_l^{a-\sigma} f(x) \; dx + \int_{a-\sigma}^{a+\sigma} f(x) \; dx + \int_{a+\sigma}^u f(x) \; dx. $$ Each of these three integrals should now be relatively well-behaved on their own, and should be easy enough to integrate.

$\endgroup$
  • $\begingroup$ should "not" or should "now" be well-behaved? $\endgroup$ – André Apr 21 '15 at 9:29
  • $\begingroup$ This is the function I need to integrate: stats.stackexchange.com/q/147321/5536. Finding the position of the peak is straightforward because the derivative is a decreasing function and a bissection finds its zero easily. But how do I estimate the $\sigma$? $\endgroup$ – becko Apr 21 '15 at 12:40
  • $\begingroup$ @becko: Plot it? Or just sample at a few points $a+10, a+5, a+2.5, a+1.25, \ldots$, until the value starts to deviate significantly from the background value. $\endgroup$ – Wolfgang Bangerth Apr 21 '15 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.