TITLE: Approximating a piecewise continuous function with a function in $\mathcal{C}^{\infty}_{0}(\mathbb{R})$
QUESTION [6 upvotes]: Let $\eta \in \mathcal{C}^{\infty}_{0}(\mathbb{R})$, where $\mathcal{C}^{\infty}_{0}(\mathbb{R})$ is the set of compactly supported infinitely differentiable function, be a function which is

non-negative, non-vanishing and constant in a neighborhood of $x=0$,
symmetric about $x=0$,
supported in $[-1,1]$,
bounded between $0$ and $\eta(0)$, and
normalized so that $\int \eta d\mu =1$.

Let $\varphi$ be a compactly supported absolutely continuous function with a piecewise continuous derivative $\varphi'$. I have been told (by a user of MSE whom I thank very much again) the following, which I think to be interesting enough to be the object of a specifical question:

Then one defines$$\eta_{n}(x) = n\eta(x/n)$$so that
  $\int_{\mathbb{R}}\eta_{n}\,d\mu =1$ for all $n$. For any compactly
  supported absolutely continuous function $\varphi$,
  define$$\varphi_{n}=\int_{\mathbb{R}}\eta_{n}(x-y)\varphi(y)\,d\mu(y).$$The function
  $\varphi_{n}$ is in $\mathcal{C}^{\infty}_{0}(\mathbb{R})$. Because
  $\eta_{n}$ is supported in $[-1/n,1/n]$, and $\varphi$ is continuous,
  then $\varphi_{n}$ converges uniformly to $\varphi$ as
  $n\rightarrow\infty$. And, because $\varphi$ is absolutely continuous,
  then$$\varphi_{n}'=\int_{\mathbb{R}}\eta_{n}'(x-y)\varphi(y)\,d\mu(y)=-\int_{\mathbb{R}}\eta_{n}(x-y)\varphi'(y)\,d\mu(y).$$
  For my case $\varphi'$ is piecewise continuous, and the right
  side then converges pointwise everywhere to mean of the left- and
  right-hand limits of $\varphi'$, and it remains uniformly bounded by
  any bound for $\varphi'$.

I must say that I have no knowledge of the theory of mollification until now.
I would like to understand why 

the fact that $\eta_{n}$ is supported in $[-1/n,1/n]$, and $\varphi$ is continuous, implies that $\varphi_{n}$ converges uniformly to $\varphi$ as $n\rightarrow\infty$;
the absolute continuity of $\varphi$ implies $\varphi_{n}'=\int_{\mathbb{R}}\eta_{n}'(x-y)\varphi(y)\,d\mu(y)=-\int_{\mathbb{R}}\eta_{n}(x-y)\varphi'(y)\,d\mu(y)$;
the piecewise continuity of $\varphi'$ implies the facts that $-\int_{\mathbb{R}}\eta_{n}(x-y)\varphi'(y)\,d\mu(y)$ converges to $(\lim_{t\to x^+}\varphi'(t)+\lim_{t\to x^-}\varphi'(t))/2$ and $|\int_{\mathbb{R}}\eta_{n}(x-y)\varphi'(y)\,d\mu(y)|\le |\varphi'(x)|$.

I heartily thank both who told me these interesting facts and whoever will help me to understand the reason of the quoted facts.

REPLY [3 votes]: In the following, I will assume that you use the version
$$
\eta_n (x) = n \cdot \eta(nx).
$$
This ensures that ${\rm supp}(\eta_n) \subset [-1/n, 1/n]$ and that $\int \eta_n \, dx = 1$ for all $n$.
I will also assume that $\mu$ denotes the usual Lebesgue measure on $\Bbb{R}$.

Here, we only need the fact that $\varphi$ is uniformly continuous (because it is continuous and of compact support). Let $\varepsilon > 0$ be arbitrary. By uniform continuity of $\varphi$, there is some $\delta > 0$ with $|\varphi(x) - \varphi(y)| < \varepsilon$ for $|x-y|<\delta$. For $n > 1/\delta$, the fact that $\int \eta_n (x-y) \, dy = \int \eta_n \, dy =1 $ yields
\begin{eqnarray*}
|\varphi(x) - \varphi_n (x)| &=& \bigg| \int \eta_n (x-y) \cdot [\varphi(x) - \varphi(y)] \, dy\bigg| \\
&\leq & \int \eta_n (x-y) \cdot |\varphi(x) - \varphi(y)| \, dy \\
&\leq& \int \eta_n (x-y) \cdot \varepsilon \, dy = \varepsilon.
\end{eqnarray*}
Here, the second line used the triangle inequality as well as $\eta_n \geq 0$. The last line used the fact that $\eta_n (x-y) \neq 0$ implies $x-y \in {\rm supp}(\eta_n) \subset [-1/n, 1/n]$ and hence $|x-y| \leq 1/n < \delta$, which yields $|\varphi(x) - \varphi(y)| < \varepsilon$ by choice of $\delta$.
By a standard argument using differentiation under the integral sign (see e.g. Differentiating an integral using dominated convergence), we see that $\varphi_n$ is (infinitely often) differentiable with derivative
$$
\varphi_n ' (x) = \int \eta_n ' (x-y) \cdot \varphi(y) \, dy.
$$
Now we observe that
$$
\frac{d}{dy} \eta_n (x-y) = - \eta_n '(x-y).
$$
Furthermore, if $f,g : \Bbb{R} \to \Bbb{R}$ are absolutely continuous and integrable, we have the following rule of partial integration (if this is not clear, I can elaborate. This is essentially a consequence of the fact that $f\cdot g$ is also absolutely continuous with derivative $(f\cdot g)' = f' \cdot g + f \cdot g'$):
$$
\int f\cdot g' \, dx = - \int f' \cdot g \, dx .
$$
Hence, we get
\begin{eqnarray*}
\varphi_n ' (x) &=& \int \eta_n ' (x-y) \cdot \varphi(y) \, dy \\
& = & - \int \varphi(y) \cdot \frac{d}{dy} \eta_n (x-y)\, dy \\
& = & \int \varphi'(y) \cdot \eta_n (x-y) \,dy.
\end{eqnarray*}
Let us first note that the estimate $|\varphi_n '(x)| = |\int \eta_n (x-y) \varphi'(y) \, dy| \leq |\varphi' (x)|$ is in general false. To see this, consider e.g. (you can probably think of a better (less trivial) example once you understand the idea)
$$
\varphi'(x)=\begin{cases}
1, & x>0,\\
0, & x\leq0.
\end{cases}
$$
Then but what we will show below,
$$
\varphi_n '(0) \to \lim_{x\downarrow 0} \varphi'(x) + \lim_{x \uparrow 0}\varphi'(x) = \frac{1}{2},
$$
which would not be possible if $|\varphi_n '(0)| \leq |\varphi'(0)| = 0$ would hold.
But what is correct is that if $|\varphi'(y)| \leq M$ holds for all $|y-x| < \delta$ for some $\delta > 0$, then $|\varphi_n '(x)| \leq M$ holds for $n > 1/\delta$, because of
$$
|\varphi_n '(x)| \leq \int \eta_n (x-y) \cdot |\varphi'(y)| \, dy \leq M \cdot \in \eta_n (x-y) \, dy = M,
$$
where we used that $\varphi_n (x-y) \neq 0$ implies (as above) $|x-y| \leq 1/n < \delta$.
In particular, if $|\varphi'(y)| \leq M$ holds for all $y$, then $|\varphi_n '(x)| \leq M$ holds for all $x$. In this sense, any bound for $\varphi'$ is also valid for $\varphi_n'$.
Finally, let us show the claimed pointwise convergence. Let $x_0 \in \Bbb{R}$ and set $y_1 := \lim_{x \downarrow x_0} \varphi'(x)$ and $y_2 := \lim_{x \uparrow x_0} \varphi'(x)$. Note that these limits exist by piecewise continuity of $\varphi'$.
Let $\varepsilon > 0$. Then there is $\delta > 0$ with $|\varphi(x) - y_1| < \varepsilon$ for $x \in (x_0, x_0 + \delta)$ and $|\varphi(x) - y_2| < \varepsilon$ for $x \in (x_0 - \delta, x_0)$. We now use the fact that $\eta$ is symmetric around $0$. This implies that
$$
1 = \int_{\Bbb{R}} \eta(x) \, dx = 2 \int_{\Bbb{R}_+} \eta(x) \, dx = 2 \int_{\Bbb{R}_-} \eta(x) \, dx. \qquad (\dagger)
$$
This is actually the only thing we will use now, symmetry is not really relevant as long as the above equation $(\dagger)$ is true.
We have
\begin{eqnarray*}
\varphi_{n}'\left(x_0\right) & = & \int\eta_{n}\left(x-y\right)\cdot\varphi'\left(y\right)\,{\rm d}y\\
 & \overset{z=x_0-y}{=} & \int\eta_{n}\left(z\right)\cdot\varphi'\left(x_0-z\right)\,{\rm d}z
\end{eqnarray*}
Together with $(\dagger)$, we derive
\begin{eqnarray*}
\bigg|\frac{y_1}{2} + \frac{y_2}{2} - \varphi_n '(x_0)\bigg| &=& \bigg|\int_{\Bbb{R}_+} \eta_n (z) \cdot [y_2 - \varphi '(x_0-z)] \, dz + \int_{\Bbb{R}_-} \eta_n (z) \cdot [y_1 - \varphi' (x_0-z) \, dz\bigg| \\
& \leq & \int_{\Bbb{R}_+} \eta_n (z) \cdot |y_2 - \varphi '(x_0-z)| \, dz + \int_{\Bbb{R}_-} \eta_n (z) \cdot | y_1 - \varphi' (x_0-z)| \, dz \\
& \leq & \int_{\Bbb{R}_+} \eta_n (z) \cdot \varepsilon \, dz + \int_{\Bbb{R}_-} \eta_n (z) \cdot \varepsilon \, dz = \varepsilon.
\end{eqnarray*}
Here, the first and very last step used $(\dagger)$. The estimate in the last line holds for $n > 1/\delta$, because (as always) if $\eta_n (z) \neq 0$ and $z \in \Bbb{R}_+ = (0,\infty)$, then $|z| \leq 1/n < \delta$ and hence $x_0 - z \in (x_0 - \delta, x_0)$, so that $|\varphi'(x_0 -z) - y_2| < \varepsilon$ by choice of $\delta$. This takes care of the first integral and the second one is handled analogously.