In this example, we relax exactly one of the hypotheses of Fubini’s Theorem, namely the continuity of \(f\text{,}\) and construct an example in which both of the integrals in Fubini’s Theorem exist, but are not equal. In fact, we choose \(\cR=\Set{(x,y)}{0\le x\le 1,\ 0\le y\le 1}\) and we use a function \(f(x,y)\) that is continuous on \(\cR\text{,}\) except at exactly one point — the origin.
First, let \(\de_1,\de_2,\de_3,\ \cdots\) be any sequence of real numbers obeying
\begin{equation*}
1=\de_1 \gt \de_2 \gt \de_3\gt\ \cdots\ \gt\de_n\rightarrow 0
\end{equation*}
For example \(\de_n=\frac{1}{n}\) or \(\de_n=\frac{1}{2^{n-1}}\) are both acceptable. For each positive integer \(n\text{,}\) let \(I_n=(\de_{n+1},\de_n]=\Set{t}{\de_{n+1} \lt t\le \de_n}\) and let \(g_n(t)\) be any nonnegative continuous function obeying
There are many such functions. For example
\begin{equation*}
g_n(t)=\left(\frac{2}{\de_n-\de_{n+1}}\right)^2\begin{cases}
\de_n-t& \text{if } \half(\de_{n+1}+\de_n)\le t\le \de_n\\
t-\de_{n+1}& \text{if }\de_{n+1}\le t\le \half(\de_{n+1}+\de_n)\\
0& \text{otherwise}
\end{cases}
\end{equation*}
Here is a summary of what we have done so far.
We subdivided the interval \(0 \lt x\le 1\) into infinitely many subintervals \(I_n\text{.}\) As \(n\) increases, the subinterval \(I_n\) gets smaller and smaller and also gets closer and closer to zero.
We defined, for each \(n\text{,}\) a nonnegative continuous function \(g_n\) that is zero everywhere outside of \(I_n\) and whose integral over \(I_n\) is one.
Now we define the integrand \(f(x,y)\) in terms of these subintervals \(I_n\) and functions \(g_n\text{.}\)
\begin{equation*}
f(x,y)=\begin{cases}
0& \text{if } x=0 \\
0& \text{if } y=0 \\
g_m(x)g_n(y)& \text{if } x\in I_m,\ y\in I_n \text{ with } m=n\\
-g_m(x)g_n(y)& \text{if } x\in I_m,\ y\in I_n \text{ with } m=n+1\\
0& \text{otherwise}
\end{cases}
\end{equation*}
You should think of \((0,1]\times(0,1]\) as a union of a bunch of small rectangles \(I_m\times I_n\text{,}\) as in the figure below. On most of these rectangles, \(f(x,y)\) is just zero. The exceptions are the darkly shaded rectangles \(I_n\times I_n\) on the “diagonal” of the figure and the lightly shaded rectangles \(I_{n+1}\times I_n\) just to the left of the “diagonal”.
On each darkly shaded rectangle, \(f(x,y)\ge 0\) and the graph of \(f(x,y)\) is the graph of \(g_n(x)g_n(y)\) which looks like a pyramid. On each lightly shaded rectangle, \(f(x,y)\le 0\) and the graph of \(f(x,y)\) is the graph of \(-g_{n+1}(x)g_n(y)\) which looks like a pyramidal hole in the ground.
Now fix any \(0\le y\le 1\) and let’s compute \(\int_0^1 f(x,y)\ \dee{x}\text{.}\) That is, we are integrating \(f\) along a line that is parallel to the \(x\)-axis. If \(y=0\text{,}\) then \(f(x,y)=0\) for all \(x\text{,}\) so \(\int_0^1 f(x,y)\,\dee{x} = 0\text{.}\) If \(0 \lt y\le 1\text{,}\) then there is exactly one positive integer \(n\) with \(y\in I_n\) and \(f(x,y)\) is zero, except for \(x\) in \(I_n\) or \(I_{n+1}\text{.}\) So for \(y\in I_n\)
\begin{align*}
\int_0^1 f(x,y)\,\dee{x}&=\sum_{m=n,n+1}\int_{I_m} f(x,y)\,\dee{x}\\
&=\int_{I_n} g_n(x)g_n(y)\,\dee{x}-\int_{I_{n+1}} g_{n+1}(x)g_n(y)\,\dee{x}\\
&=g_n(y)\int_{I_n} g_n(x)\,\dee{x}-g_n(y)\int_{I_{n+1}} g_{n+1}(x)\,\dee{x}\\
&=g_n(y)-g_n(y)=0
\end{align*}
Here we have twice used that \(\int_{I_m}g(t)\,dt=1\) for all \(m\text{.}\) Thus \(\int_0^1 f(x,y)\,\dee{x}=0\) for all \(y\) and hence \(\int_0^1\dee{y}\Big[\int_0^1
\dee{x}\ f(x,y)\Big]=0\text{.}\)
Finally, fix any \(0\le x\le 1\) and let’s compute \(\int_0^1 f(x,y)\ \dee{y}\text{.}\) That is, we are integrating \(f\) along a line that is parallel to the \(y\)-axis. If \(x=0\text{,}\) then \(f(x,y)=0\) for all \(y\text{,}\) so \(\int_0^1 f(x,y)\,\dee{y} = 0\text{.}\) If \(0 \lt x\le 1\text{,}\) then there is exactly one positive integer \(m\) with \(x\in I_m\text{.}\) If \(m\ge 2\text{,}\) then \(f(x,y)\) is zero, except for \(y\) in \(I_m\) and \(I_{m-1}\text{.}\) But, if \(m=1\text{,}\) then \(f(x,y)\) is zero, except for \(y\) in \(I_1\text{.}\) (Take another look at the figure above.) So for \(x\in I_m\text{,}\) with \(m\ge 2\text{,}\)
\begin{align*}
\int_0^1 f(x,y)\,\dee{y}&=\sum_{n=m,m-1}\int_{I_n} f(x,y)\,\dee{y}\\
&=\int_{I_m} g_m(x)g_m(y)\,\dee{y}-\int_{I_{m-1}} g_{m}(x)g_{m-1}(y)\,\dee{y}\\
&=g_m(x)\int_{I_m} g_m(y)\,\dee{y}-g_m(x)\int_{I_{m-1}} g_{m-1}(y)\,\dee{y}\\
&=g_m(x)-g_m(x)=0
\end{align*}
But for \(x\in I_1\text{,}\)
\begin{align*}
\int_0^1 f(x,y)\,\dee{y}&=\int_{I_1} f(x,y)\,\dee{y}
=\int_{I_1} g_1(x)g_1(y)\,\dee{y}
=g_1(x)\int_{I_1} g_1(y)\,\dee{y}\\
&=g_1(x)
\end{align*}
Thus
\begin{equation*}
\int_0^1 f(x,y)\,\dee{y}=\begin{cases}
0&\text{if } x\le \de_2 \\
g_1(x)&\text{if } x\in I_1
\end{cases}
\end{equation*}
and hence
\begin{equation*}
\int_0^1\dee{x}\bigg[\int_0^1 \dee{y}\ f(x,y)\bigg]
=\int_{I_1}g_1(x)\,\dee{x}=1
\end{equation*}
The conclusion is that for the \(f(x,y)\) above, which is defined for all \(0\le x\le 1\text{,}\) \(0\le y\le 1\) and is continuous except at \((0,0)\text{,}\)
\begin{equation*}
\int_0^1\dee{y}\bigg[\int_0^1 \dee{x}\ f(x,y)\bigg]=0
\qquad
\int_0^1\dee{x}\bigg[\int_0^1 \dee{y}\ f(x,y)\bigg]=1
\end{equation*}