Is it possible to find a smooth function $p$ such that
$$p(x)=0 \text{ if } x\le -1$$ $$p(x)=0 \text{ if } x> 0$$ $$0\le p(x) \le 1 \text{ if } -1<x<1$$ $$p(x) = 1 \text{ if } -\frac{1}{2}\le x \le \frac{1}{2}$$ Hint: The following function has continuous derivatives of all orders $$f(x) = 0 \text{ if } x\le 0$$ $$f(x) = e^{-\frac{1}{x^2}} \text{ if } x>0$$
My thought: Considering the left-half of the function $p$, I tried something like $e^{-\frac{1}{\tan^2(x\pi)}}$. The shape looks good but I am not sure about the smoothness at $-1$ and $-\frac{1}{2}$. For $x=-1$, since $\tan$ is infinitely differentiable so we have smoothness there. But for $x=-\frac{1}{2}$, I am not sure about the smoothness after "gluing" with $y=1$.