I'm trying to construct a $C^{\infty}$ function $f:\mathbb R \to \mathbb R$ such that $f=1$ on an interval $[a,b]$ and $f=0$ outside of some open interval $(a-\varepsilon,b+\varepsilon)$, for arbitrary $\varepsilon$. In other words, a $C^{\infty}$ approximation of $\chi _{[a,b]}$.
I've seen that there's a guided exercises on “Calculus on Manifolds”, however I've made some progress and I would like to know if it's possible to complete my work.
So, my starting point is this function: $$\varphi(x)=e^{-1/x^2}.$$ This can be extended to a $C^{\infty}$ function on $\mathbb R$ such that $\varphi^{(k)}(0)=0$ (this can be seen by calculating $$\lim _{h\to 0} k!\frac{\varphi(h)}{h^k},$$ that, if all $k-1$ derivatives are zero, is equal to the $k$-th derivative, and is zero). Now define: $$\varphi _t (x)=e^{-1/(x-t)^2}\qquad \text {and} \qquad \psi _t(x)=1-e^{-1/(x-t)^2}.$$ Extending by continuity we get two $C^{\infty}$ functions. Now I'm having some trouble.
I'm trying to construct a $C^{\infty}$ function $h_{s,t}$ ($s<t$) such that $$h_{s,t}(s)=0=\varphi _{s}(s), \quad h_{s,t}(t)=1=\psi _t(t),\quad h^{(k)}(s)=h^{(k)}(t)=0 \quad \forall k$$If I'm able to do this, I can then define $f$ as $f=h_{a-\varepsilon,a}$ in $[a-\varepsilon,a]$, $f=g_{b,b+\varepsilon}$ (for a similarly defined $g$) and $f=1$ inside and zero outside.
How can I make (if possible) such a function $h$? I've already observed that I can multiply $\varphi$ and $\psi$ functions to get other $C^{\infty}$ functions, but I don't know how to use this fact, if it can help.
Since $\varphi$ has zero derivatives of all orders at $0$, it follows that the product $\Phi =\varphi \chi_{\{x>0\}}$ is $C^\infty$ smooth on $\mathbb R$. As $x\to+\infty$, $\Phi(x)$ tends to $1$, hence it exceeds $1/2$ starting from some point $x_0$. The composition $$\Phi\left(\frac12-\Phi(x)\right) \tag{1}$$ is equal to $\Phi(1/2)=e^{-4}$ for negative $x$, and to $0$ for $x>x_0$, where $\Phi(x_0)=1/2$. The rest is cleanup: apply a linear transformation to (1) to turn $e^{-4}$ and $0$ into $0$ and $1$, and also a linear change of variables to send $0$ and $x_0$ to $s$ and $t$.