Derivatives of conditionally defined functions I was asked in an exercise to show on what intervals of $\mathbb{R}$ a function $f(x)$ is solution to certain differential equations. The function is defined as:
$$f(x) = \left\{ \begin{array}{rl}
&e^{-1/x^2}&\;\; \text{if}\; x \neq 0\\&0&\;\; \text{if}\; x = 0\end{array}\right.$$
How can I get the first, second and third derivatives of $f(x)$? How do they behave when $x=0$? I assumed $f'(0) = {d0\over dx} = 0$, is that right? What is the rule to get $f'(0)$, $f''(0)$, etc? How to know if there exists the n-th derivative of a function such as $f(x)$ in the whole $\mathbb{R}$ domain?
 A: Notice that for $x \ge 0$, we have
$e^x \ge 1+x+ {1 \over 2!} x^2 + \cdots + {1 \over n!} x^n$.
For $x \neq 0$, we have $e^{-{1\over x^2}} = {1 \over e^{1 \over x^2}} \le {1 \over 1+{1 \over x^2}+ {1 \over 2!} {1 \over x^4} + \cdots + {1 \over m!} {1 \over x^{2m}}} \le m! x^{2m}$, hence $|f(x)| \le m! x^{2m}$ for all $x$. 
It is clear that $f$ is smooth for $x \neq 0$, so only $x=0$ is of concern.
I claim that for $x \neq 0$, $f^{(n)}(x) = p_n({1 \over x}) e^{-{1\over x^2}}$ for some polynomial $p_n$. It is clearly true for $n=0$, differentiating gives 
$f^{(n+1)}(x) = (-{1 \over x^2} p_n'({1 \over x})+ p_n({1 \over x})p_1({1 \over x}) ) e^{-{1\over x^2}}$, and so letting $p_{n+1}(t) = -t^2 p_n'(t)+ p_n(t)p_1(t)$ gives the desired result.
In particular, if $m$ in the estimate above satisfies $2m \ge \partial p_n + 2$ and $|x| \le 1$, then $|f^{(n)}(x) | \le K_n x^2$ for some constant $K_n$.
Choosing $m=1$ in the above estimate shows that  $f(0) = 0$ and   $\left| { f(x) -f(0) \over x } \right| \le |x|$, from which it follows that $f$ is differentiable at $x=0$ and $f'(0) = 0$.
Now suppose that $f^{(n)}$ is differentiable at $x=0$  and $f^{(n)}(0) = 0$.
Then $\left| { f^{(n)}(x) -f^{(n)}(0) \over x } \right| \le K_n |x|$ from which we see that $f^{(n)}$ is differentiable at $x=0$  and $f^{(n+1)}(0) = 0$.
