Is there a way to approximate an infinite integral? I know that a Riemann sum can give me integral for finite integrals, but I want infinite integrals too.
0∫∞ f(x)
Printable View
Is there a way to approximate an infinite integral? I know that a Riemann sum can give me integral for finite integrals, but I want infinite integrals too.
0∫∞ f(x)
I don't understand your notation. You mean over the whole real line? That's not too hard but I want to make sure that thats what you want before I explain it.
EDIT: Oh wait. you mean approximate. as in without finding the antiderivative. fuck man, im no good at that numerical shit. If it's for a general class of function though, i might be able to help anyway.
Yes, the entire length of the line. Yes, approximate, not the real thing. I can do the real thing easily, but I need to make this in C++.
OK. Here's a paper that I found. It's based on changing coordinates from x to x=1/t dx=t^-2dt which lets you integrate x over the real line by integrating t over [0, 1].
It's simple. take the integral from 0 to t of f(x), and then evaluate the limit as t -> inf.
EDIT: sorry, didn't realize you wanted to approximate. I suppose the first thing you need to do is determine if it converges or diverges. After that, if and only if it converges, you can cut off your riemann sum after you hit the right kind of precision. Note that for converging integrals (where f(x) -> 0 as x -> inf, pretty much), the higher order terms will always tend to zero, so you can be pretty consistent with your precision.