Cut-off function construction Let $f:I=[0,1]\cup[2,3]\to \mathbb{R}$, defined by 
$$f(x)= \begin{cases} 0 & \text{if } x\in [0,1] \\ 1 & \text{if } x\in [2,3] \end{cases} $$
How do I construct a $C^1$ function $\tilde{f}: \mathbb{R}\to \mathbb{R}$ such that $\tilde{f}(x)=f(x)$ for all $x\in I$. 
 A: I will show you how to fill in the gap $(1,2)$ and leave you to get the rest. The easiest method is to use a polynomial to fill in the gap. It will need to have a derivative of zero at $x=1$ and $x=2$, so the polynomial needs to be at least cubic, and its derivative has the form $$p'(x)=a(x-1)(x-2)=ax^2-3ax+2a,$$ where $a$ is a constant. The derivative has to be positive between $1$ and $2$, so $a$ is negative. By taking an antiderivative, we get $$p(x)=\frac{a}{3}x^3-\frac{3a}{2}x^2+2ax+c.$$ We should have $p(1)=0$ and $p(2)=1$. Therefore $$\frac{a}{3}-\frac{3a}{2}+2a+c=0,$$ $$\frac{8a}{3}-6a+4a+c=0.$$ Now solve this system of equations to find what $a$ and $c$ should be.
A: Hint
Try to use $$x\longmapsto e^{-\frac{1}{x^2}}\quad \text{and}\quad x\longmapsto e^{-x^2}$$
that you can compose with translation and homethetie. 
A: The function $$g(x)=\begin{cases}0&x\le 0\\x^2&x\ge 0\end{cases}$$
is $C^1$, and non-negative, and is zero exactly on the non-positives.
Therefore, for all $x\in\Bbb R$ at least one of $g(x-1)$ and $g(2-x)$ is nonzero, i.e., their sum is always positive. Thus if $h_1$, $h_2$ are any $C^1$ functions, then also
$$\tilde f(x)=\frac{h_1(x)g(x-1)+h_2(x)g(2-x)}{g(x-1)+g(2-x)} $$
is $C^1$. We verify that $\tilde f(x) = h_1(x)$ for $x\ge 2$ and $\tilde f(x)=h_2(x)$ for $x\le 1$. The problem at hand is therefore solved by picking $h_1(x)=1$, $h_2(x)=0$.
A: Lemma. For any $\epsilon>0$, there exists $f_\epsilon \in C^{\infty}\left(\left[0,1\right]\right)$,
a bijection from $\left[0,1\right]$ onto itself, such that
\begin{align*}
f_\epsilon (0) & =0,\\
f_\epsilon (1) & =1,\\
\forall k\in\mathbb{N},k\geq1,f_\epsilon ^{(k)}\left(0\right)=f_\epsilon^{(k)}\left(1\right) & =0,\\
\sup_{\left[0,1\right]}\left|f_\epsilon^{\prime}\left(x\right)\right| & <1+\epsilon.
\end{align*}
Choose any $\epsilon>0$, then a suitable function for your purpose is
$$
f:x\to\begin{cases} 
0 & \textrm{ if }x \leq1\\ 
f_{\epsilon}(x-1) & \textrm{ if } x\in (1,2) \\
1 & \textrm{ otherwise.  }
 \end{cases}
$$
That function is $C^\infty$, and the norm of its derivative is as close to one as possible. It must be at least one, by the intermediate value theorem applied between $x=1$ and $x=2$.
Proof of the Lemma.
It is well known that the function for any $s>0$, $f_{n}:t\to\begin{cases}
e^{-t^{-\frac{1}{s}}} & t>0\\
0 & t=0
\end{cases},$ is such that $f_{n}\in C^{\infty}\left(\left[0,1\right]\right),$
and for all $k,$
$$
f_{s}^{\left(k\right)}\left(0\right)=\lim_{t\to0}f_{s}^{\left(k\right)}\left(t\right)=0.
$$
Indeed, if
$$
f_{s}^{\left(k\right)}\left(t\right)=\frac{P_{k}\left(t^{\frac{1}{s}}\right)}{t^{k\frac{s+1}{s}}}f_{s}\left(t\right),
$$
where $P_{k}$ is a polynomial, then
\begin{align*}
f_{s}^{\left(k+1\right)}\left(t\right) & =\left(\frac{\frac{1}{s}P_{k}^{\prime}\left(t^{\frac{1}{s}}\right)t^{\frac{1}{s}}-\left(k+\frac{k}{s}\right)P_{k}\left(t^{\frac{1}{s}}\right)}{t^{k+1+\frac{k}{s}}}+\frac{1}{n}\frac{P_{k}\left(t^{\frac{1}{s}}\right)}{t^{\frac{1}{s}+1}t^{k+\frac{k}{s}}}\right)f_{s}\left(t\right)\\
 & =\frac{\left(\frac{1}{s}P_{k}^{\prime}\left(t^{\frac{1}{s}}\right)t^{\frac{1}{s}}-\left(k+\frac{k}{s}\right)P_{k}\left(t^{\frac{1}{s}}\right)\right)t^{\frac{1}{s}}+\frac{1}{s}P_{k}\left(t^{\frac{1}{s}}\right)}{t^{k+1+\frac{k+1}{n}}}f_{s}\left(t\right).
\end{align*}
So setting $P_0=1$ and $$P_{k+1}(X) = \frac{1}{s}P_{k}^{\prime}\left(X\right)X-\left(k+\frac{k}{s}\right)P_{k}\left(X\right)X+\frac{1}{s}P_{k}\left(X\right), $$
we have our formula by induction. Notice that
$$
\partial_{s}f_{s}=\frac{t^{-\frac{1}{s}}}{s^{2}}\ln\frac{1}{t}f_{s}>0\text{ on } {\left(0,1\right)},
$$
that is, $f_s$ is monotone increasing.
Now let
$$
g_{n}:x\to\frac{1}{C_{n}}\int_{0}^{x}f_{n}\left(t\right)f_{n}\left(1-t\right)\text{d}t, 
$$
with
$$
C_{n}=\int_{0}^{1}f_{n}\left(t\right)f_{n}\left(1-t\right)\text{d}t.
$$
Then $g_n$ is monotone increasing, $$
g_{n}\left(0\right)=0,g_{n}\left(1\right)=1,
$$
and
$$
g_{n}^{\prime}\left(x\right)=\frac{1}{C_{n}}f_{n}\left(x\right)f_{n}\left(1-x\right),$$
which satisfies
$$
g_{n}^{\prime}\left(0\right)=g_{n}^{\prime}\left(1\right)=0,
$$
as well as all subsequent derivatives. We note that
\begin{align*}
g_{n}^{\prime\prime}\left(x\right) & =\frac{1}{C_{n}}\left(f_{n}^{\prime}\left(x\right)f_{n}\left(1-x\right)-f_{n}\left(x\right)f_{n}^{\prime}\left(1-x\right)\right)\\
 & =g_{n}^{\prime}\left(x\right)\frac{1}{n}\left(\frac{1}{x^{\frac{n+1}{n}}}-\frac{1}{\left(1-x\right)^{\frac{n+1}{n}}}\right).
\end{align*}
Thus the maximum of $g_{n}^{\prime}$ is attained at $\frac{1}{2},$and
is
$$
g_{n}^{\prime}\left(\frac{1}{2}\right)=\frac{1}{C_{n}}\exp\left(-2^{\frac{2}{n}}\right).
$$
Since $f_{n}\left(t\right)f_{n}\left(1-t\right)$ grows with $n$
towards $1$ at each $t$, we have by dominated convergence,
$$
\lim_{n\to\infty}C_{n}=\int_{0}^{1}1\text{d}t=1.
$$
So $\max_{[0,1]}\left|g_{n}^{\prime}\right|$ is a decreasing sequence,
such that
$$
\lim_{n\to\infty}\max_{[0,1]}\left|g_{n}^{\prime}\right|=1.
$$
For any $\epsilon>0$, choose the appropriate $n$ to conclude the proof.
