Help! How to numerically integrate a function which has a singularity and a very sharp peak?

Hi all,

Here is a description to the gamma density function:

http://en.wikipedia.org/wiki/Gamma_distribution

Basically, I am studying how to numerically integrate against the
gamma density function for kappa < 1.

As you can see, the key difficulty for the kappa < 1 case is that in
the integrand there is a term

x^(kappa-1)

and we have to integrate starting from x=0 all the way to x= +
infinity...

There is a very sharp peak at x=0, which leads to a lot of difficulty
for my Simpson's rule numerical integration scheme.

For some reason, I have to integrate by calculating the nodes and
weights myself. This is actually good - it helps me understand the
numerical integration better.

I want to learn the tricks in numerical integration field about how
experts handle such case...

Please shed some light on me...

Thanks a lot for your help!

Robert Israel's picture

Numerical integration with a singularity

There are three standard tricks:

(1) break up the interval of integration into pieces, one near the singularity (x=0 in this case), one near infinity, and one where everything behaves nicely.

(2) transform an improper integral to a nice smooth one on a finite interval

(3) subtract off the singular part and integrate that exactly.

For example, to integrate x^(kappa-1)*f(x) for x from 0 to 1, where f(x) is an analytic function in a neighbourhood of this interval and 0 < kappa < 1, you can use the Taylor series f(x) = sum(c[i]*x^i, i=0..4) + g(x), where g(x) = O(x^5) as x -> 0.  Thus x^(kappa-1)*g(x) should be sufficiently nice (with 4 continuous derivatives) to behave well with Simpson's Rule, while int(x^(kappa-1+i), x=0..1) = 1/(kappa+i).
 

 

<p>Thanks

<p>Thanks Robert...</p>
<p>What if we don't know f(x) in closed-form, though f(x) is known to be nice, smooth, and bounded... We have to evaluate f(x) numerically and it consumes a lot of computational resouces in obtaining f(x)...</p>
<p>Any more thoughts?</p>

Robert Israel's picture

f(x)

In  that case it may be better to use the transformation method, which does not require derivatives of f.  The change of variables

t = x^(1/kappa)

takes

int(f(x)*x^(kappa-1),x=0..1)

to

1/kappa*int(f(t^(1/kappa)),t=0..1)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}