When Does the Limit of a "Sequence" of Functions Equal the Limit? I've been playing with continuous approximations to the $\Pi(x)$ "rectangle function" defined as:
$$\Pi(x)=\begin{cases}0 & |x| > \frac{1}{2}\\ \frac{1}{2} & |x| = \frac{1}{2} \\ 1 & |x| < \frac{1}{2} \\ \end{cases}$$
The approximation I have been experimenting with is defined to be:
$$f_m(x) = \frac{1}{(2x)^{2m}+1}$$
This approximation improves as $m$ get larger in the sense that the following "error" is decreasing with increasing $m$:
$$\epsilon_m = \int_{-\infty}^{\infty} \left| \Pi(x) - f_m(x)\right| \,dx$$
I believe, but have not been able to prove, that:
$$\lim_{m\to\infty} \epsilon_m = 0$$
This would seem to indicate that, in the limit, this is a good approximation to the rectangle function.
However, the following seems to demonstrate this is not the case:
Consider the integral:
$$\int_{-\infty}^{\infty} \Pi(x) e^x \,dx = \int_{-1/2}^{1/2} e^x \,dx = e^{1/2}-e^{-1/2}$$
This is a finite number as the rectangle function only has support between -1/2 and 1/2.
Now, attempting to to the same with the prior approximation:
$$\int_{-\infty}^{\infty} f_m(x) e^x \,dx = \int_{-\infty}^{\infty} \frac{e^x}{(2x)^{2m}+1} \,dx$$
This integral will never be finite no matter how large $m$ is as the exponential function will always grow faster than the polynomial in the denominator.
My assumptions for what makes a good approximation must be incorrect.  What properties of the approximation am I missing to be able to justify the limit being a good approximation to the rectangle function?
 A: Studying the convergence of sequences of functions is a subtle business, and functional analysis studies many different kinds of convergence for many purposes. Often but not always this is done by specifying a norm. Studying the error $\epsilon_m$ corresponds to studying convergence with respect to what is called the $L^1$ norm.
Here's the good news: your sequence of functions $f_m$ does in fact converge to $\Pi(x)$ with respect to the $L^1$ norm. I will work with a modified form of both functions where $\Pi(x)$ is equal to $1$ for $|x| < 1$ and $f_m(x) = \frac{1}{x^{2m} + 1}$, which will save me some $2$s and $\frac{1}{2}$s. We have
$$\epsilon_m = 2 \int_0^1 \left( 1 - \frac{1}{x^{2m} + 1}  \right) \, dx + 2 \int_1^{\infty} \frac{1}{x^{2m} + 1} \, dx$$
where we've used left-right symmetry to reduce the integral to non-negative values of $x$. We can bound these integrals by breaking them up based on when $x^{2m}$ gets either large or small. For $m$ large we have
$$\left( 1 + \frac{y}{2m} \right)^{2m} \approx e^y$$
so $x^{2m}$ has intermediate values only for $x \approx 1 \pm \frac{1}{m}$; below these values it is small and beyond them it is large. So, let's break up the first integral from $0$ to $1$ into two chunks
$$\int_0^{1 - d_m} \left( 1 - \frac{1}{x^{2m} + 1} \right) \, dx + \int_{1 - d_m}^1 \left( 1 - \frac{1}{x^{2m} + 1} \right) \, dx$$
where $d_m$ will be chosen later in such a way that we can bound both chunks to show that they go to $0$. The second chunk is easier: since the integrand is non-negative and takes maximum value $1$, it is bounded by $d_m$, so to send it to $0$ we only need to ensure that $d_m \to 0$. To send the first chunk to $0$ we need to pick $d_m$ such that the condition that $0 \le x \le 1 - d_m$ makes $x^{2m}$ small; in light of the exponential approximation above we can pick $d_m = \frac{1}{\sqrt{m}}$, so that $0 \le x \le 1 - d_m$ gives
$$0 \le x^{2m} \le \left( 1 - \frac{1}{\sqrt{m}} \right)^{2m} \le e^{-2 \sqrt{m}}$$
where we've used the inequality $(1 + x)^r \le e^{rx}$ which is valid for $r > 0$ and all real $x$. This gives that the first chunk is bounded by $1 - \frac{1}{e^{-2 \sqrt{m}} + 1}$ which goes to $0$ as desired.
The second integral does not even need to be chunked; we just have
$$\int_1^{\infty} \frac{1}{x^{2m} + 1} \, dx \le \int_1^{\infty} \frac{1}{x^{2m}} \, dx = \frac{1}{2m-1}$$
which goes to $0$. So $\epsilon_m \to 0$ as desired.
The bad news is that, as you've seen, convergence in the $L^1$ norm does not imply convergence of the integral against a function like $e^x$. This means that the integral against $e^x$, even when it is defined, is discontinuous with respect to the $L^1$ norm. This doesn't mean the $L^1$ norm is bad! It just means the two don't go together.
A simple setting in which to discuss convergence of integrals against other functions is the Hilbert space $L^2$, where we instead consider $\| f - g\|_2 = \int_{-\infty}^{\infty} |f(x) - g(x)|^2 \, dx$, and where it is possible to prove the following: if $f_n \in L^2$ is a sequence of functions converging in the $L^2$ norm to a function $f$, meaning that $\| f_n - f \|_2 \to 0$, and if $g \in L^2$ is another function, then the sequence of integrals
$$\langle f_n, g \rangle = \int_{-\infty}^{\infty} f_n(x) g(x) \, dx$$
converges to $\langle f, g \rangle$. The bounds above readily adapt to showing that $f_m$ also converges to $\Pi(x)$ in $L^2$. And for a more general statement along these lines see Hölder's inequality, which implies that if $f_m \to f$ in $L^p$ then we can conclude that the integrals $\langle f_m, g \rangle$ converge to $\langle f, g \rangle$ for $g \in L^q$, where $\frac{1}{p} + \frac{1}{q} = 1$. The function $e^x$ does not belong to $L^q$ for any value of $q$ so this is one way to see why it's a bad function to integrate against here.
