Finding a smooth and differentiable sequence of functions that converges to a Characteristic Function I am trying to find a smooth and differentiable sequence of functions, which converges to the characteristic function $\mathbf{1}_{[a,b]}$. Is there an easy idea how to realise that?
I suppose it should look like this
$$ f_n(x)= \left\{
\begin{array}{ll}
1 & x \in [a,b] \\
1-n(x-b) & \, x\in [b,(1/n)+b] \\
n(a-x) & \, x\in [a-(1/n),a]\\
0 & \, \text{else}
\end{array}
\right.$$
But of course I would not need a linear function connecting parts that are $1$ and $0$. I thought I might need a exponential function? But how would that look like?
Thank you for any help!
 A: If you want your intermediate functions to be 0 outside of some interval, the goal of smoothness combined with compact support is the defining goal of a bump function, one appropriate for your situation might be:$$b(x)=\begin{cases}\exp\left({-1\over x-x^2}\right),&0 < \textit{x} < 1,\\0,&\text{otherwise}.\end{cases}$$
The goal of converging to one on this interval can be done with any smooth function which has $f(0
)=0, ~f(1)=1$ as fixed points and converges values in the middle closer to one. Probably the algebraically easiest such function is $\sqrt{x}$, suggesting for example,
$$
f_n(x) = [b(x)]^{1/n}.
$$
There are also ways to do this without bump functions I suppose, keeping the whole real line as the proper domain. So for example the Fermi-Dirac distribution $u(x)={1\over1+e^{-\beta x}}$ pushes negative values to 0 and positive ones to 1, getting sharper with higher inverse-temperature $\beta$. Combine this with a function which is positive on $(0,1)$ like $y(x) = x-x^2$, and tweak up the inverse temperature factor for higher $n$, to get $$
f_n(x) = \frac1{1+e^{-n~(x-x^2)}}.
$$
There's doubtless many ways to do this, for instance using arctangent rather than the hyperbolic tangent implied by Fermi-Dirac, or using the Fourier series or so.
