TITLE: Switching order of integration on unbounded domain
QUESTION [2 upvotes]: Let's say ${f\left( {x,y} \right)}$ is a continuous function and assume that:
$\int\limits_{ - \infty }^\infty  {\left| {f\left( {x,y} \right)} \right|dx} $ converges for all $y  $
2) $\int\limits_{ - \infty }^\infty  {\left| {f\left( {x,y} \right)} \right|dy} $ converges for all $x $
Is the following statement correct?
$$\int\limits_{ - \infty }^\infty  {\int\limits_{ - \infty }^\infty  {f\left( {x,y} \right)dxdy} }  = \int\limits_{ - \infty }^\infty  {\int\limits_{ - \infty }^\infty  {f\left( {x,y} \right)dydx} } $$
This is supposed to be some version of Fubini's or Tonelli's theorem but I wasn't able to find the exact version for this case.

REPLY [0 votes]: There's something of a standard library of analysis counterexamples. Looking here... iterated integrals don't match, but the inner integrals are unconditional... OK, I've got it. Well, the version I have in memory is for sums: $\begin{bmatrix}1&0&0&0&\cdots\\-1&1&0&0&\cdots\\0&-1&1&0&\cdots\\0&0&-1&1&\cdots\\ \vdots&\vdots&\vdots&\vdots&\ddots\end{bmatrix}$
Sum along the rows first (inner) and we get $1$. Sum along the columns first and we get zero.
This can of course be converted into a version for the integral. Let
$$f(x,y)=\begin{cases}1& 0<x-y<1\\ -1&-1<x-y<0\\0&\text{otherwise}\end{cases}$$
for $x,y\ge 0$. Then 
\begin{align*}\int_0^{\infty}f(x,y)\,dx &= \begin{cases}1-y& 0\le y\le 1\\ 0&y>1\end{cases}\\
\int_0^{\infty}f(x,y)\,dy &= \begin{cases}x-1& 0\le x\le 1\\ 0&x>1\end{cases}\end{align*}
so $\int_0^{\infty}\int_0^{\infty}f(x,y)\,dx\,dy = \frac12$ and $\int_0^{\infty}\int_0^{\infty}f(x,y)\,dy\,dx = -\frac12$. The order of the integral cannot be interchanged in general.
Now, quibbles. That's not continuous! No problem; just smooth the jumps out when defining $f$ - say, one period of a sawtooth wave $f(x,y)=g(x-y)$ where $g(t)=\begin{cases}t&-\frac12\le t\le \frac12\\1-t&\frac12\le t\le 1\\-1-t&-1\le t\le -\frac12\\ 0&\text{otherwise}\end{cases}$. Calculating the integral is a little messier, but we'll still get something positive for $\int_0^{\infty} f(x,y)\,dx$ when $y\in (0,1)$ and something negative for $\int_0^{\infty} f(x,y)\,dy$ when $x\in (0,1)$.
That's an integral on $[0,\infty)^2$, not $\mathbb{R}^2$! Padding the function with zeros when either variable is negative would do the trick - except that it disrupts continuity again. So then, we need to tweak it so that it's zero on the axes. OK - multiply $f$ by $\min\{x,y,1\}$. Working this out for my sawtooth example, it's a lot of calculation for not much benefit, so I'll just give the answer:
$$\int_0^{\infty} f(x,y)\,dx=\begin{cases}0& y\ge 2\\ \frac{(2-y)^3}{6}& \frac32\le y\le 2\\ \frac{y(\frac32-y)^2}{6}+\frac{5-3y}{24}& 1\le y\le \frac32\\ \frac y4 - \frac{3y-1}{24} - \frac{(2-y)(y-\frac12)^2}{6} & \frac12 \le y\le 1\\ \frac y4-\frac{y^3}{6}&0\le y\le \frac12\\ 0&\text{otherwise}\end{cases}$$
All but one of those are clearly nonnegative; we simplify that third case to clear the last bit up:
\begin{align*}\frac y4 - \frac{3y-1}{24} - \frac{(2-y)(y-\frac12)^2}{6} &= \frac{4y-3y+1-4y^3+12y^2-9y+2}{24}\\
&= \frac{-4y^3 + 12y^2 - 8y + 1}{24}\\
&= \frac1{24}-\frac{y(1-y)(2-y)}{6}\\
\frac y4 - \frac{3y-1}{24} - \frac{(2-y)(y-\frac12)^2}{6} &\ge \frac1{24}-\frac{(1-y)(2-y)}{6}\ge 0\end{align*}
(The inequalities, of course, use that $\frac12 \le y\le 1$)
So then, $\int_0^{\infty} f(x,y)\,dx$ is always nonnegative. By the symmetry of $f$'s definition, $\int_0^{\infty} f(x,y)\,dy$ is always nonpositive, and the two iterated integrals are unequal.
This example runs on essentially the same principles as Rigel's already posted answer, but I find it a little clearer to work with the explicit piecewise definition than the fake infinite sum.
{"set_name": "stack_exchange", "score": 2, "question_id": 3050619}