I have the following problem and would like to know if the following solution is right:
I have to find for every $\varepsilon\in\mathbb{R}_{>0}$ a function $f_{\varepsilon}\in C_{c}((0,1))$, such that $f_{\varepsilon}\to \chi_{(a,b)}$ in $L_{p}((0,1))$ for $\varepsilon\to 0$, where $\chi_{(a,b)}$ denotes the characteristic function, e.g. $\chi_{(a,b)}(x)=1$, if $x\in (a,b)$ and 0 otherwise.
After some tries I have constructed the following sequence of functions:
$$f_{\varepsilon}(x):=\begin{cases}\exp\bigg\{-\frac{\varepsilon}{1-\big(\frac{2}{b-a}\big(x-\frac{b+a}{2}\big )\big)^{2}}+\varepsilon\bigg\}&\text{if $x\in (a,b)$}\\0, &\text{otherwise}\end{cases}$$
These functions are continous, since we have that $$\lim_{x\to a}\exp\bigg\{-\frac{\varepsilon}{1-\big(\frac{2}{b-a}\big(x-\frac{b+a}{2}\big )\big)^{2}}+\varepsilon\bigg\}=0=\lim_{x\to b}\exp\bigg\{-\frac{\varepsilon}{1-\big(\frac{2}{b-a}\big(x-\frac{b+a}{2}\big )\big)^{2}}+\varepsilon\bigg\}$$
Furhtermore, they are compactly supported in $(0,1)$, since we have that
$$\mathrm{supp}(f_{\varepsilon})=\overline{(a,b)}=[a,b].$$
If I draw this functions with smaller and smaller $\varepsilon$ they also indeed seem to approach the rectangle $[a,b]\times [0,1]$.
So we have now to show that $\lim_{\varepsilon\to 0}\Vert f_{\varepsilon} - \chi_{(a,b)}\Vert_{p}=0$
This can be done with help of the dominant convergence theorem:
$$\lim_{\varepsilon\to 0}\Vert f_{\varepsilon} - \chi_{(a,b)}\Vert_{p}^{p}=\lim_{\varepsilon\to 0}\int_{(0,1)}\vert f_{\varepsilon}(x) - \chi_{(a,b)}(x)\vert_{p}^{p}dx=\int_{(0,1)}\lim_{\varepsilon\to 0}\vert f_{\varepsilon}(x) - \chi_{(a,b)}(x)\vert_{p}^{p}dx=\int_{(a,b)}(1-1)dx=0$$
You have proclaimed, but have not effectively demonstrated, that $$\lim_{\varepsilon\to 0}\vert f_{\varepsilon}(x) - \chi_{(a,b)}(x)\vert_{p}^{p} = 1 - 1$$ for $x \in (a,b)$.
It might be true, but "I've graphed it for several $\varepsilon$ and it appears to head that direction" isn't enough of an argument.
You could probably come up with one, but let me point out something easier: $f_\epsilon$ doesn't have to be pieced together only at $a$ and $b$. For example, if $$g(x) = \begin{cases}0,& x \in (0,1]\\x-1,& x\in [1,2]\\1,& x\in [2,3]\\4-x,& x\in [3,4]\\0,& x \in [4,5)\end{cases}$$ then $g \in C_c((0,5))$.
If you were wanting smooth functions, then playing around with $e^{-1/|x|}$ or similar functions would be the way to go (but again, piecing them only at $a, b$ is not necessary, and will only cause you extra woes). But there is nothing here that calls for smoothness.