# When can a sum and integral be interchanged?

Let’s say I have $$∫∞0∑∞n=0fn(x)dx\int_{0}^{\infty}\sum_{n = 0}^{\infty} f_{n}(x)\, dx$$ with $$fn(x)f_{n}(x)$$ being continuous functions. When can we interchange the integral and summation? Is $$fn(x)≥0f_{n}(x) \geq 0$$ for all $$xx$$ and for all $$nn$$ sufficient? How about when $$∑fn(x)\sum f_{n}(x)$$ converges absolutely? If so why?

I like to remember this as a special case of the Fubini/Tonelli theorems, where the measures are counting measure on $$N\mathbb{N}$$ and Lebesgue measure on $$R\mathbb{R}$$ (or $$[0,∞)[0,\infty)$$ as you’ve written it here). In particular, Tonelli’s theorem says if $$fn(x)≥0f_n(x) \ge 0$$ for all $$n,xn,x$$, then $$∑∫fn(x)dx=∫∑fn(x)dx\sum \int f_n(x) \,dx = \int \sum f_n(x) \,dx$$ without any further conditions needed. (You can also prove this with the monotone convergence theorem.)

Then Fubini’s theorem says that for general $$fnf_n$$, if $$∫∑|fn|<∞\int \sum |f_n| < \infty$$ or $$∑∫|fn|<∞\sum \int |f_n| < \infty$$ (by Tonelli the two conditions are equivalent), then $$∫∑fn=∑∫fn\int \sum f_n = \sum \int f_n$$. (You can also prove this with the dominated convergence theorem.)

There may be weaker conditions that would also suffice, but these tend to work in 99% of cases.

Elaborating on request: the usual statement of Fubini's theorem goes something like this:

Let $$(X,F,μ),(Y,G,ν)(X,\mathcal{F}, \mu),(Y,\mathcal{G}, \nu)$$ be $$σ\sigma$$-finite measure spaces, and let $$g:X×Y→Rg : X \times Y \to \mathbb{R}$$ be measurable with respect to the product $$σ\sigma$$-algebra $$F⊗G\mathcal{F} \otimes \mathcal{G}$$. Suppose that $$∫X∫Y|g(x,y)|ν(dy)μ(dx)\int_X \int_Y |g(x,y)| \nu(dy) \mu(dx)$$ is finite. (Note: By Tonelli's theorem, this happens if and only if $$∫Y∫X|g(x,y)|μ(dx)ν(dy)\int_Y \int_X |g(x,y)|\mu(dx)\nu(dy)$$ is finite, since both iterated integrals are equal.) Then $$∫X∫Yg(x,y)ν(dy)μ(dx)=∫Y∫Xg(x,y)μ(dx)ν(dy).\int_X \int_Y g(x,y) \nu(dy)\mu(dx) = \int_Y \int_X g(x,y) \mu(dx) \nu(dy).$$

Let $$X=RX = \mathbb{R}$$, $$F\mathcal{F}$$ the Borel $$σ\sigma$$-algebra, and $$μ\mu$$ Lebesgue measure. Let $$Y=NY = \mathbb{N}$$, $$G=2N\mathcal{G} = 2^{\mathbb{N}}$$ the discrete $$σ\sigma$$-algebra, and $$ν\nu$$ counting measure. Define $$g(x,n)=fn(x)g(x,n) = f_n(x)$$. Exercise: since each $$fnf_n$$ is measurable, verify that $$gg$$ is measurable with respect to $$F⊗G\mathcal{F} \otimes \mathcal{G}$$. Exercise: verify that integration with respect to counting measure is the same as summation, where the integral exists and is finite iff the sum converges absolutely. (That is, given a sequence of real numbers $$ana_n$$, define a function $$b:N→Rb : \mathbb{N} \to \mathbb{R}$$ by $$b(n)=anb(n) = a_n$$. Then $$∫Nbdν=∑∞n=1an\int_{\mathbb{N}} b\,d\nu = \sum_{n=1}^\infty a_n$$.)

As such, the conclusion of Fubini's theorem reduces to the statement that was to be proved.