TITLE: Infinitely differentiable function with compact support
QUESTION [5 upvotes]: I already know that the function
$$
f(x) = 
\begin{cases}
\exp(- \frac{1}{x^2}), \quad  x > 0 \\
0 , \quad x \leq 0

\end{cases}

$$
is infinitely differentiable throughout $\mathbb R$. The only real problem, of course, lies in showing that $f^{(k)} (0) = 0$ for any positive integer $k$. What I have not been able to deduce is that
$$
\phi(x) = 
\begin{cases}
\exp(- \frac{1}{1 - x^2}), \quad  |x| < 1 \\
0 , \quad |x| \geq 1

\end{cases}

$$
is also infinitely differentiable throughout $\mathbb R$, using the previous function. The problem now is finding out what happens at $x = 1,-1$. Does the substitution $\zeta ^2 = 1 - x^2$ work, or is there another way to prove this?
Thank you all!

REPLY [5 votes]: This is much easier if you first show that 
$g(x) = \begin{cases}
  e^{-\frac{1}{x}} & \text{for } x \gt 0 \\\\
  0                & \text{for } x \leq 0
\end{cases}$
is smooth. Then it's easy to see that $f(x) = g(x^2)$ and $\phi(x) = g(1-x^2)$, i.e. $f$ and $\phi$ are compositions of smooth functions.

REPLY [2 votes]: Hint 1: For every positive $c$ and every real $a$, the function $f_{a,c}$ defined by $f_{a,c}(x)=\exp(-c/(x-a))$ if $x>a$ and $f_{a,c}(x)=0$ if $x\le a$ is infinitely differentiable on the real line.
Hint 2: use $f_{a,c}$ to build a function infinitely differentiable on the real line, zero for $x\ge a$ and positive for $x<a$.
Hint 3 : use the decomposition of $1/(1-x^2)$ as a linear combination of $1/(1\pm x)$ to write $\phi$ as a product of two infinitely differentiable functions.