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$. 

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$.
