# Proving $v$ can be approximated arbitrarily well in $L_2$-norm by $C^0$-functions

Let $\Omega=(-1,1)$ and let $v:\Omega\to\mathbb{R}$ be define by $v(x)=1$ if $x\in(-1,0)$ and $v(x)=0$ if $x\in(0,1)$. Prove that $v\in L_2(\Omega)$ and that $v$ can be approximated arbitrarily well in $L_2$-norm by $C^0$-functions.

So far I did

\begin{align*} ||v||_{L_2}&=\int_\Omega\,|v(x)|^2\,dx\\ &=\int_{-1}^1\,|v(x)|^2\,dx\\ &=\int_{-1}^0\,|v(x)|^2\,dx+\int_{0}^1\,|v(x)|^2\,dx\\ &=\int_{-1}^0\,|1|^2\,dx+\int_{0}^1\,|0|^2\,dx\\ &=\int_{-1}^0\,\,dx\\ &=1 \end{align*}

Since $||v||_{L_2}=1<\infty$, therefore $v\in L_2(\Omega)$.

I couldn't find a way to solve the approximation part. Any help would be highly appreciated. Thanks in advance.

$$v_n(x) = \begin{cases} 1 & -1 < x \leq 0, \\ 1 - nx &0 \leq x \leq \frac{1}{n}, \\ 0 & \frac{1}{n} \leq x < 1. \end{cases}$$
The functions $v_n$ are piecewise linear and agree with $v$ outside the interval $(0,\frac{1}{n})$ (draw them!). Hence,
$$\| v_n - v \|_{L^2}^2 = \int_0^{\frac{1}{n}} |v_n(x) - v(x)|^2 \, dx = \int_0^{\frac{1}{n}} v_n(x)^2 \, dx = \int_0^{\frac{1}{n}} (1 - nx)^2 \, dx = \\ \int_0^{\frac{1}{n}} 1 - 2nx + n^2 x^2 \, dx = \left[x - nx^2 + \frac{n^2 x^3}{3} \right]_{x=0}^{x=\frac{1}{n}} = \frac{1}{3n} \to 0.$$
• you have a typo in your second-to-last line: the antiderivative is $x-nx^2+\frac{n^2x^3}|3}$ - you have a factor $2$ in front of $nx^2$ :) – haemi Apr 18 '17 at 14:51