# A way of evaluating integrals without doing anything?

The user known as sos440 posted this: \begin{align*} \sum_{n=0}^\infty \frac{r^n}{n!} \int_0^\infty x^n e^{-x} \; dx & = \int_{0}^\infty \sum_{n=0}^\infty \frac{(rx)^n}{n!} e^{-x} \; dx = \int_0^\infty e^{-(1 - r)x} \; dx \\ & = \frac{1}{1 - r} = \sum_{n=0}^\infty r^n \end{align*} (citing Tonelli's theorem to justify interchanging the sum and the integral), and concluded that $$\frac{1}{n!}\int_0^\infty x^n e^{-x}\,dx=1.$$

Is this a very isolated thing or just an instance of something generally useful for some much broader class of integrals? (Obviously, what is seen below is generally true, but how generally is it useful?)

$$\sum_{n=0}^\infty r^n \int_A f_n(x)\,dx = \int_A \sum_{n=0}^\infty \big( r^nf_n(x) \big) \, dx = \int_A g(r,x) \, dx = h(r) = \sum_{n=0}^\infty c_n r^n$$ $$\therefore \int_A f_n(x)\,dx = c_n.$$

-
I guess this could seem like magic, but isn't this just computing the exponential generating function of the integrals? We've all seen how generating function methods can make hard tasks seem simple. –  Ragib Zaman Apr 13 '12 at 6:15
We could say $$\sum_{n=0}^\infty \frac{r^n}{n!} \mathcal{M} \{ f \}(n) = r \mathcal{L} \{ f \} (-r).$$ –  anon Apr 17 '12 at 7:19
The method is essentially the same as using the moment generating method of calculating the moments of an exponentially distributed random variable. The same idea applied to the normal distribution gives$$\int_{-\infty}^\infty x^{2n}e^{-x^2/2}dx =\sqrt{2\pi}\frac{(2n)!}{2^nn!}.$$Unfortunately, I can't think of many simple examples, as not that many continuous distributions have simple explicit forms for both the pdf and MGF. –  George Lowther Aug 12 '13 at 23:49
> how generally is it useful < Is this really an answerable question? It's useful for any integral of that form! –  Sharkos Aug 16 '13 at 17:29

Rather than try and address this question generally here we give another---hopefully sufficiently different---example of the use of this type of machinery.

Suppose we are interested in integrals of the form $$\begin{equation*} \int_0^{2\pi} x^n \sin x\, dx \quad\textrm{ or }\quad \int_0^{2\pi} x^n \cos x \, dx, \end{equation*}$$ where $n\in\mathbb{N}$. It is natural to consider the more general integral $$\begin{equation*} I_n = i\int_0^{2\pi} x^n e^{i x}\, dx. \end{equation*}$$ (A factor of $i$ has been introduced for convenience.) Then $$\begin{eqnarray*} I(r) &\equiv& \sum_{n=0}^\infty \frac{(i r)^n}{n!}I_n \\ &=& i\int_0^{2\pi} e^{i (r+1) x}dx \\ &=& \frac{e^{2\pi i r}-1}{1+r} \\ &=& \sum_{n=0}^\infty \left(\sum_{k=0}^{n-1}(-1)^{k}\frac{(2\pi i)^{n-k}}{(n-k)!}\right)r^n. \end{eqnarray*}$$ (The last series is the Cauchy product of the Taylor series for $1/(1+r)$ and the Taylor series for $e^{2\pi i r}-1$.) Therefore, $$\begin{equation*} \int_0^{2\pi} x^n e^{i x}\, dx = \frac{n!}{i^{n+1}}\sum_{k=0}^{n-1} (-1)^{k} \frac{(2\pi i)^{n-k}}{(n-k)!}.\tag{1} \end{equation*}$$ By taking the real and imaginary part of (1) we can find explicit formulas for the original integrals: $$\begin{eqnarray*} \int_0^{2\pi} x^n \cos x\, dx &=& n!\sum_{m=0}^{\lfloor\frac{n-2}{2}\rfloor} (-1)^m\frac{(2\pi)^{n-2m-1}}{(n-2m-1)!} \\ \int_0^{2\pi} x^n \sin x\, dx &=& n!\sum_{m=0}^{\lfloor\frac{n-1}{2}\rfloor} (-1)^{m+1}\frac{(2\pi)^{n-2m}}{(n-2m)!}. \end{eqnarray*}$$

-
Nice example indeed. I think calculating integrals in this way is a (new?) method. Someone who knows integral transformations and read this topic could say more. –  vesszabo Aug 20 '13 at 9:40
Thanks @vesszabo. I would say this is more of a "trick of the trade" than a new method. As Ragib Zaman mentions in the comments, with this method we are simply calculating the generating function of the integrals of interest. –  user26872 Aug 20 '13 at 12:25

Nothing magic :-) (if I understand the question correctly.) If $f(r)$ is an analytic function around $r_0=0$ then the Taylor expansion is unique. It yields, $$f(r)=\sum_{n=1}^{\infty}c_nr^n,$$ where $r\in(-a,a)$, $a>0$. So, if $$f(r)=\sum_{n=1}^{\infty}c_n d_n r^n$$ is another power series representation of $f$, then $c_n=c_n d_n$, i.e., $d_n=1$ if $c_n\neq 0$, anything is $d_n$ (integral or something else).

-
This appears just as irrelevant tot he question as was the answer that was deleted some time ago. Quite possibly you were confused by someone else's edit to my question? –  Michael Hardy Aug 16 '13 at 16:26
@MichaelHardy Sorry, the situation is not clear for me, possibly I misunderstand something. I was attracted to this question, because " This question has an open bounty worth +50 reputation from Michael Hardy ending in 2 days. This question has not received enough attention." I think (if I don't misunderstand the question) that my answer is a one possible answer. I have not known about an earlier (and deleted) answer. Oh, I'm reading now your Later edit. All right. Please, try to clarify your problem, or if you want this, delete it. It's your decision. :-) –  vesszabo Aug 16 '13 at 16:49
OK, I hope the edits I just did clarify the question. –  Michael Hardy Aug 16 '13 at 17:13
@MichaelHardy To discover a new theorem (or method) is not easy. Try to find an other example. I begin to understand your question :-) I don't know how more generally could be described this method as you did in the last two lines of your question. It's too general. In a special case you could find something interesting, see e.g. the answer of anon. (These my ideas only, maybe help you.) –  vesszabo Aug 17 '13 at 18:53

$$\sum_{n=0}^\infty \frac{r^n}{n!} \int_0^\infty x^n e^{-x} \; dx = \sum_{n=0}^\infty \frac{r^n}{n!} \left(\int_0^\infty x^n e^{-x} \; dx\right) = \sum_{n=0}^\infty \frac{r^n}{n!} \Gamma(n+1) = \sum_{n=0}^\infty \frac{r^n}{n!} n! = \sum_{n=0}^\infty r^n$$

Where $\Gamma(n+1)$ is the Gamma function. I hope this is right!

-
This doesn't answer the question. –  Pedro Tamaroff Aug 19 '13 at 1:31
In other words, as far as I can see, this simplification works because you've got the Gamma function in there & it reduces to $n!$ leading to this simplification, & the reason a commenter noticed it relates to the moment-generating function method is because the gamma function is related to it also: en.wikipedia.org/wiki/… So I don't see anything general here. –  bolbteppa Aug 19 '13 at 1:32
I think it does the question, it's isolated by the fact the Gamma function is in there, though again it's part of a broad class of integrals involving the gamma function - such as the normal distribution... –  bolbteppa Aug 19 '13 at 1:33
My point is you haven't read what Michael is asking. –  Pedro Tamaroff Aug 19 '13 at 1:36
You didn't answer his question in any way. –  JLA Aug 19 '13 at 3:30