Applications of Switching Sums and Integrals Under some nice conditions, we can perform the following 'trick' of switching sums and integrals: $$\sum \int f_n(x) dx = \int \sum f_n(x) dx.$$
(We will ignore issues of convergence.) This trick can be used to prove a lot of interesting limits such as 
$$\sum_{n = 1}^{\infty} \frac{1}{\binom{2n}n} = \frac{1}3 + \frac{2\sqrt{3} \pi}{27}$$ or 
$$\sum_{n = 0}^{\infty} \frac{1}{C_n} = 1 + \frac{4 \pi}{9 \sqrt{3}}$$ where $C_n$ is the $n$th Catalan numbers. 
Are there any other interesting or surprising examples that this community is aware of? 
 A: 
Another example is
  \begin{align*}
\int_{0}^1\frac{dx}{x^x}=\sum_{n=1}^\infty \frac{1}{n^n}
\end{align*}
We obtain
  \begin{align*}
\int_{0}^1\frac{dx}{x^x}&=\int_{0}^1e^{-x\log x}dx\\
&=\int_{0}^1\sum_{n=0}^\infty\frac{(-x \log x)^n}{n!}dx\tag{1}\\
&=\sum_{n=0}^\infty\int_{0}^1\frac{(-x \log x)^n}{n!}dx\tag{2}\\
&=\sum_{n=0}^\infty\frac{(-1)^n}{n!}\cdot\frac{(-1)^n n!}{(n+1)^{n+1}}\tag{3}\\
&=\sum_{n=1}^\infty \frac{1}{n^n}
\end{align*}
  and the claim follows.

Comment:


*

*In (1) we use the power series representation for $e^x$

*In (2) we use the fact that we integrate power series term by term

*In (3) we use the following identity for $k\geq 0, j>0$
\begin{align*}
\int_{0}^1x^j(\log x)^k\,dx=\frac{(-1)^k k!}{(j+1)^{k+1}}
\end{align*}
This can be shown for $j>0$ by induction on $k$. For $k=0$ it can be seen quite easily and for the inductive step, we use integration by parts
\begin{align*}
\int_{0}^1x^j(\log x)^k\,dx&=\frac{1}{j+1}\left.x^j(\log x)^k\right|_0^{1}-\frac{k}{j+1}\int_{0}^1x^j(\log x)^k\,dx\\
&=-\frac{k}{j+1}\int_{0}^1x^j(\log x)^k\,dx\tag{4}\\
&=\frac{-k}{j+1}\cdot\frac{(-1)^{k-1}(k-1)!}{(j+1)^k}\tag{5}\\
&=\frac{(-1)^k k!}{(j+1)^{k+1}}
\end{align*}

*In (4) we use
$
\lim_{x\rightarrow 0^+}x^j(\log x)^k=0
$
for $j>0$ and $k\geq 0$.

*In (5) we apply the inductive hypothesis

Hint: This example is stated as Gem 30 in Real Infinite Series by D.D. Bonar and M.J. Khoury. See also this  related answer.

A: First example
For $|a|<1$
$$\int^{2\pi}_0 \frac{1- a \cos(x)}{1+a^2-2a \cos(x)}dx = \sum_{k=0}^{\infty} a^{k} \int^{2\pi}_0 \cos(kx)\,dx = 2\pi   $$
Where we used that 
$$\sum_{k=0}^{\infty} a^{k} \cos(kx) = \frac{1- a \cos x}{1-2a \cos x + a^{2}} , \ \ |a|<1$$
Second example
$$ \int_{0}^{\infty}\frac{e^{-t}\cosh(a\sqrt{t})}{\sqrt{t}}dt$$
We know that we can expand $\cosh$ using power series 
$$\cosh(a\sqrt{t}) = \sum_{n=0}^{\infty}\frac{a^{2n}\cdot t^n}{(2n)!}$$
Substituting  back in the integral we have 
$$\int_{0}^{\infty}e^{-t}\sum_{n=0}^{\infty}\frac{a^{2n}\cdot t^n}{(2n)!\, \sqrt{t}}dt$$
Now since the series is always positive we can swap the integral and the series 
$$\sum_{n=0}^{\infty}\frac{a^{2n}}{(2n)!}\left[ \int_{0}^{\infty}e^{-t} t^{n-\frac{1}{2}}dt\right] $$
Hence we have by using the gamma function
$$\sum^{\infty}_{n=0} \frac{a^{2n}\,\Gamma\left(\frac{1}{2}+n\right)}{(2n!)}$$
Using LDF (Legendre Duplication Formula) we get
$$\sum^{\infty}_{n=0}\frac{a^{2n}}{(2n!)}\left({(2n)! \over 4^n n!} \sqrt{\pi}\right)$$
By further simplification
$$\sqrt{\pi}\,\sum^{\infty}_{n=0} \frac{a^{2n} }{4^n\,n!}$$
Using the expansion of the exponential we get 
$$\int_{0}^{\infty}\frac{e^{-t}\cosh(a\sqrt{t})}{\sqrt{t}}dt\,=\,\sqrt{\pi}e^{{a^2 \over 4}}$$
A: Here is a neat identity that appeared in this year's Putnam competition that also employs this trick.

Show that $$\sum_{k=1}^{\infty} \frac{(-1)^{k-1}}k \sum_{n = 0}^{\infty} \frac{1}{k2^n+1} = 1.$$

The sum is absolutely convergent by comparing it to $\sum_{n=1}^{\infty} \frac{1}{n^2}.$  Thus, we have $$\begin{align*}
\sum_{k=1}^{\infty} \frac{(-1)^{k-1}}k \sum_{n = 0}^{\infty} \frac{1}{k2^n+1} &= \sum_{k=1}^{\infty} \frac{(-1)^{k-1}}k \sum_{n=0}^{\infty}\int_0^1 x^{k2^n} \ dx \\
&= \sum_{n=0}^{\infty} \int_0^1 \sum_{k=1}^{\infty} \frac{(-1)^{k-1}x^{k2^n}}{k} \ dx \\
&= \sum_{n=0}^{\infty}  \int_0^1 \log(1 + x^{2^n}) \ dx \\
&= \int_0^1 \sum_{n=0}^{\infty} \log(1+x^{2^n}) \ dx \\
&= \int_0^1 \log\left( \sum_{n=0}^{\infty} x^n \right) \ dx \\
&= - \int_0^1 \log(1-x) \ dx \\
&= 1.
\end{align*}$$
The fifth equality follows from the fact that every positive integer has a unique binary representation. 
A: The standard integral representation of the Riemann zeta function,

$$
\zeta(s+1)=\frac1{\Gamma(s+1)}\int_0^\infty\frac{x^s}{e^x-1}\:dx, \qquad s>0, \tag1
$$

is obtained this way, using a uniform convergence, one has
$$
\begin{align}
\int_0^\infty\frac{x^s}{e^x-1}\:dx&=\int_0^\infty x^s \cdot \frac{e^{-x}}{1-e^{-x}}\:dx
\\\\&=\int_0^\infty x^s\cdot\sum_{n=0}^\infty e^{-(n+1)x}\:dx
\\\\&=\sum_{n=0}^\infty\int_0^\infty x^s e^{-(n+1)x}\:dx
\\\\&=\sum_{n=0}^\infty\frac1{(n+1)^{s+1}}\int_0^\infty u^s e^{-u}\:du
\\\\&=\sum_{n=1}^\infty\frac1{n^{s+1}}\cdot\Gamma(s+1)
\\\\&=\Gamma(s+1)\cdot \zeta(s+1).
\end{align}
$$ This integral representation yields many consequences concerning the Riemann zeta function, one of them being the functional equation
$$
\zeta(s) = 2^s\pi^{s-1}\ \sin\left(\frac{\pi s}{2}\right)\ \Gamma(1-s)\ \zeta(1-s), \qquad s \in \mathbb{C}, \,s \neq 1. \tag2
$$
