# Infinite Integrals Numerically

1. Jan 21, 2009

### daviddoria

I want to integrate a function in c++ - so I dug out some numerical integration functions. However, they do not produce the correct results when the limits are infinite.

Simply using 1e6 or something instead of infinity seems like a very "hack" solution... and I also don't know the function ahead of time so I wouldn't know if 1e3 is good enough? or do I need 1e8, etc.

Of course you can find the analytic integral and just evaluate it, but not if the function doesn't have an analytic integral!

What do people usually do to numerically evaluate infinite integrals?

Thanks!

Dave

2. Jan 21, 2009

### Tac-Tics

Computation falls pretty far short when it comes to doing general mathematics. To know that an integral is infinite is to know that the limit of the Riemann sums doesn't converge, which in the general case, requires an explicit proof. The best you can do is approximate and treat "unreasonably large" results as infinity. If you're clever, though, you might be able to find some nice heuristics for determining what values constitute "unreasonably large."

3. Jan 21, 2009

### daviddoria

That's exactly the opposite problem! I know that these integrals converge, but I don't know how far I have to go until they come close enough to converging... is it 1000, or 100000, or 1000000 ?

4. Jan 21, 2009

### Tac-Tics

What kind of functions are you trying to integrate exactly? Perhaps there is a way to find or approximate an upper bound for some of them.

5. Jan 21, 2009

### George Jones

Staff Emeritus
The standard trick is to make a change of variable that turns the infinite range of integration in the old integration variable into a finite range of integration in the new integration variable.

For example, after using $t = e^{-x}$,

$$\int_{x=a}^{x=\infty}$$

becomes

$$\int_{t=0}^{t=e^{-a}}$$.

See 4.4. of Numerical Recipes,

http://www.nrbook.com/a/bookcpdf.php.