Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Infinite Integrals Numerically

  1. Jan 21, 2009 #1
    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?


  2. jcsd
  3. Jan 21, 2009 #2
    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."
  4. Jan 21, 2009 #3
    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 ?
  5. Jan 21, 2009 #4
    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.
  6. Jan 21, 2009 #5

    George Jones

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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 [itex]t = e^{-x}[/itex],




    See 4.4. of Numerical Recipes,

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook