Why is this function smooth? Let $f: \mathbb{R}^n\rightarrow \mathbb{R}$ be the following function,
$$f(x)=\begin{cases}
\operatorname{e}^{-\tfrac{1}{1-\|x\|^2}} & \text{if }\|x\|<1,\\\\
0 & \text{otherwise}.
\end{cases}$$
How can I show that $f$ is smooth?
 A: Of course $x\longmapsto 1- \|x\|^2$ is smooth. By composition, it is enough to show that the real function defined by $h(t)=e^{-1/t}$ for $t>0$ and $h(0)=0$ for $t\leq 0$ is smooth. The only problem is at $0$. Prove by induction that for every $t>0$
$$
h^{(n)}(t)=\frac{p_n(t)}{t^{2n}}e^{-1/t}
$$
with $p_n$ a polynomial. It follows that for every $n\geq 0$
$$
\lim_{t\rightarrow 0^+}h^{(n)}(t)=0.
$$
So $h$ is infinitely many times differentiable at $0$, with $h^{(n)}(0)=0$ for every $n\geq 0$.
Note: the composition is $f(x)=h(1-\|x\|^2)$.
A: Define $g:\mathbb{R}^{\ge0}\mapsto\mathbb{R}$ by
$$
g(t)=\left\{\begin{array}{}
e^{\frac1{1-t^2}}&\text{for }0\le t\lt1\\
0&\text{for }t\ge1
\end{array}\right.
$$
At all points other than $t=1$, the function is a composition of smooth functions. So we only need to show that all the derivatives are $0$ when $t=1$. 
For $t\ge1$, $g$ is identically $0$, so there is no problem there.
For $0\le t\lt1$, induction gives us $\frac{\mathrm{d}^n}{\mathrm{d}t^n}g(t)=R_n(t)g(t)$ for some rational function $R_n$. Since $\lim\limits_{x\to\infty}P(x)e^{-x}=0$ for any polynomial $P$, we have that $\lim\limits_{t\to1^-}R_n(x)g(x)=0$.
Since all derivatives tend to $0$ as $t\to1$, the mean value theorem says that all the derivatives of $g(t)$ at $t=1$ are $0$.
Since $x\mapsto|x|$ is smooth away from $0$, we have that
$$
f(x)=g(|x|)=e^{\frac1{1-|x|^2}}
$$
is smooth away from $0$. Near $0$, $f$ is the composition of smooth functions. Thus, $f$ is smooth over all of $\mathbb{R}^n$.
