# Infinite Integrals Numerically

• daviddoria
In summary, you can approximate an infinite integral by changing the integration variable to a finite one.
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

daviddoria said:
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

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."

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 ?

daviddoria said:
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 ?

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.

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.

## What is an infinite integral?

An infinite integral is a mathematical concept that involves finding the area under a curve that extends infinitely in both directions. It is commonly used in calculus and involves a continuous sum of infinitely small sections of a function.

## Why are infinite integrals difficult to solve numerically?

Infinite integrals are difficult to solve numerically because they involve an infinite number of calculations, which is not possible for a computer to perform. Additionally, the accuracy of the numerical solution depends on the chosen method and the function being integrated.

## What are some methods for numerically solving infinite integrals?

Some common methods for numerically solving infinite integrals include the trapezoidal rule, Simpson's rule, and Monte Carlo integration. These methods involve approximating the integral by dividing the interval into smaller sections and using specific formulas to calculate the area under the curve.

## How do you know if the numerical solution of an infinite integral is accurate?

The accuracy of the numerical solution can be determined by comparing it to the exact solution, if known. Additionally, the error in the numerical solution can be calculated and compared to a desired level of accuracy. The smaller the error, the more accurate the solution.

## What are some real-world applications of infinite integrals?

Infinite integrals have numerous real-world applications, including calculating the area under a velocity-time graph to determine the distance traveled by an object, finding the probability of an event occurring in statistics, and determining the total energy of a system in physics.

• Calculus
Replies
1
Views
1K
• Calculus
Replies
6
Views
3K
• Calculus
Replies
2
Views
1K
• Calculus
Replies
16
Views
2K
• Calculus
Replies
2
Views
990
• Calculus
Replies
3
Views
1K
• Calculus
Replies
3
Views
1K
• Calculus
Replies
3
Views
1K
• Calculus
Replies
1
Views
1K
• Advanced Physics Homework Help
Replies
19
Views
703