Example 3

Let $n$ be positive integer and $x$ be real. Consider the following function: $$ f_n(x) \left\{ \begin{array}{ll} = 1 & \mbox{if} \quad n \le x < n+1 \\ = 0 & \mbox{otherwise} \end{array} \right. $$ Its easy to see that: $$ \int_{-\infty}^{+\infty} f_n(x) \, dx = 1 $$ And hence: $$ \lim_{n \rightarrow \infty} \left[ \int_{-\infty}^{+\infty} f_n(x) \, dx \right] = 1 $$ as well, while $$ \lim_{n \rightarrow \infty} f_n(x) = 0 $$ for every $x$, and so $$ \int_{-\infty}^{+\infty} \left[ \lim_{n \rightarrow \infty} f_n(x) \right] dx = 0 $$ Conclusion: the integral and the limit, apparently, do not commute.
Let's analyze this further, nevertheless. We shall first unravel the meaning of the infinities involved: $$ \int_{-\infty}^{+\infty} f_n(x) \, dx = \lim_{L\rightarrow \infty} \int_{-L}^{+L} f_n(x) \, dx $$ Therefore what's really going on is the following ($n$ natural, $L$ real): $$ \lim_{n \rightarrow \infty} \lim_{L \rightarrow \infty} \int_{-L}^{+L} f_n(x) \, dx \left( = \lim_{n \rightarrow \infty} 1 = 1 \right) $$ $$ \lim_{L \rightarrow \infty} \lim_{n \rightarrow \infty} \int_{-L}^{+L} f_n(x) \, dx \left( = \lim_{n \rightarrow \infty} 0 = 0 \right) $$ Where the answer between parentheses is the one that is most probably expected by a maths teacher. With other words: what we have is an iterated limit. Here comes an ASCII picture that is associated with this little problem:
                             ________
 ____________________________|      |______________________ f_n
                 L          n  L   n+1    L
Apart from the limits. As long as we are in the finitary domain, then it's obvious that there exist the following possibilities for $L$ and $n$: $$ L < n \quad \mbox{;} \quad L = n \quad \mbox{;} \quad n < L < n+1 \quad \mbox{;} \quad n+1 = L \quad \mbox{;} \quad n+1 < L $$ If we proceed by taking the limit for $L \rightarrow \infty$ first, then it seems as if $L > n+1$ is the final fact. This is often expressed as "keep $n$ fixed and let $L$ become infinite". If we act in this way, then the outcome is indeed $1$. Note, however, that it is assumed silently here that the limit with $L$ is in some sense completed. Therefore, no matter how we proceed next by taking the limit for $n \rightarrow \infty$, there is no way anymore to accomplish $n+1$ to become greater than $L$ eventually.
If we proceed by taking the limit for $n \rightarrow \infty$ first, then it seems as if $L < n$ is the final fact. This is often expressed as "keep $L$ fixed and let $n$ become infinite". If we act in this way, then the outcome is indeed $0$. Note, however, that it is assumed silently here that the limit with $n$ is in some sense completed. Therefore, no matter how we proceed next by taking the limit for $L \rightarrow \infty$, there is no way anymore to accomplish $L$ to become greater than $n$ eventually.
As far as the abovementioned utterings with "fixed" are concerned, I would rather say that a "fixed" real $L$ (or natural $n$) is an undefined concept. A real is just a real and there's nothing "fixed" or "variable" with it. But it could be that such is only a figure of speech and should not be taken too literally.
A more serious objection is provided by adhering to the Axiom that Completed infinity is not given. Because then, if we let $L$ go to infinity, then the end result is a finite, though possibly very large, number. Meaning that it is still possible for $n$ to become even larger. And if we let $n$ go to infinity, then the end result again is a finite, though possibly very large, number. Meaning that it is still possible for $L$ to become even larger. In short, if the Axiom is accepted, then we have to live with the fact that both $n$ and $L$ approach limiting values in whatever fashion. What is the proper way to express this idea? The following is our proposal: $$ \lim_{\min(n,L)\rightarrow\infty} \, \int_{-L}^{+L} f_n(x) \, dx $$ And now the answer is that this limit: does not exist. Or rather that it has any value between $0$ and $1$, not by coincidence the two extremes found by students who got an 'A' for their exam.
That's not the last word about it, though. Let's repeat. It's obvious that there exist the following possibilities for $L$ and $n$: $$ L \le n \quad \mbox{;} \quad n < L < n+1 \quad \mbox{;} \quad n+1 \le L $$ Now if we keep one of these conditions while taking the limit for $(n,L) \rightarrow (\infty,\infty)$, then the iterated limit does exist for two of the following three cases: $$ \lim_{(n,L)\rightarrow\infty} \, \int_{-L}^{+L} f_n(x) \, dx = \left\{ \begin{array}{ll} 0 & \mbox{for} \quad L \le n \\ \mbox{undefined} & \mbox{for} \quad n < L < n+1 \\ 1 & \mbox{for} \quad n+1 \le L \end{array} \right. $$ Where undefined, in this case, means that the limit has any value between $0$ and $1$.