Proving a combination of differentiability $f:\mathbb{R}\to \mathbb{R} $where$$f(x) = \begin{cases} \dfrac{P(x)}{x^n}e^{-1/x^2}& \text{if $x\ne 0$}, \\
 0 &\text{if $x = 0$}.\end{cases}$$
Where P(x) is a polynomial and $n\geq 0$ is an integer.
Prove that $f$ is differentiable everywhere and takes the form $$f'(x) = \begin{cases} \dfrac{Q(x)}{x^m}e^{-1/x^2}& \text{if $x\ne 0$}, \\
 0 &\text{if $x = 0$}.\end{cases}$$ where $m\geq 0$ is some integer
I have a note here from the question that I should consider cases with x = 0 and $x\not=0$ separately. I have a few thoughts about the question, we discussed it briefly with a tutor of mine (not the lecturer) and he suggested to just use the fact that all polynomials are differentiable, as is $e^{-1/x^2}$ and $x^n$ but that doesn't really consider both cases of x = 0 and $x\not=0$ so I thought I'd try it another way:
if $ x = 0$:
by definition $f'(0) = \lim_{h\to0} \dfrac{P(h)e^{-1/h^2}}{h} $ should exist
$= \lim_{h\to0} \dfrac{a_0 + a_1h + a_2h^2 + ... a_kh^k}{h^n}e^{-1/h^2} = \lim_{h\to0} \left( \frac{a_0}{h^n} + \frac{a_1}{h^{n-1}} + ... \right) e^{-1/h^2} $ but I don't know how to evaluate $\lim_{h\to0}e^{-1/h^2}$ also, would $\lim_{h\to0} \left( \frac{a_0}{h^n} + \frac{a_1}{h^{n-1}} + ... \right) e^{-1/h^2} = \left (a_1 + a_2 + a_3 + ... + a_k \right) \lim_{h\to0} e^{-1/h^2} $? If so, how would I get it in the form of $\dfrac{Q(x)}{x^m}e^{-1/x^2}$ ? I think I can use my tutors method when $x\not= 0$
any help, thank you
 A: If you can prove it for an integer power instead of polynomials, then you are done, since $Q(x)/x^m$ is a sum of powers of $x$.
Consider now the function 
$$ g(x) = \begin{cases} x^\alpha e^{-1/x^2} & x \neq 0 \\ 0 & x=0 \end{cases}$$
First look at the limit as $x$ goes to $0$ by changing $x$ to $1/x$: $$\lim_{x \to 0}x^\alpha e^{-1/x^2}=\lim_{x \to \infty} \frac{1}{x^\alpha e^{x^2}}=0$$
Now we split the study in two parts. For $x \neq 0$ $g(x)$ consists of compatible operations of differentiable functions, and therefore $g$ is differentiable. The derivative is
$$ g'(x)=\alpha x^{\alpha-1}e^{-1/x^2}+x^\alpha e^{-1/x^2}\frac{2}{x^3} $$
and the limit of this expression as $x$ goes to $0$ is zero, since it is the sum of expressions of the same type as $g$. 
If the derivative of a function $f$ is defined in a neighborhood of a point $x_0$ and $f'$ can be extended by continuity in that point, then $f$ is differentiable in $x_0$. 
This is the case here. The derivative of $g$ exists everywhere when $x \neq 0$ and it has a limit as $x$ goes to $0$. Thus the derivative of $g$ exists everywhere, and moreover, it has the form 
$$ g'(x) = \begin{cases} \frac{\alpha x^{\alpha-1}+2x^{\alpha}}{x^3} e^{-1/x^2} & x \neq 0 \\ 0 & x=0 \end{cases}$$

Let me detail a little this point:

If the derivative of a function $f$ is defined in a neighborhood of a point $x_0$ and $f'$ can be extended by continuity in that point, then $f$ is differentiable in $x_0$. 

This is a direct consequence of the mean value theorem: if $f:[a,b] \to \Bbb{R}$ is continuous on $[a,b]$ and differentiable on $(a,b)$ then there exists $c \in (a,b)$ such that $f(a)-f(b)=f'(c)(a-b)$.
We want to prove that the limit $\lim_{x \to x_0} \frac{f(x)-f(x_0)}{x-x_0}$ exists. For this, pick a sequence $x_n \to x_0$ (we can assume that $x_n>x_0$ because the other case can be treated in the same way).
Apply the mean value theorem in each interval $[x_0,x_n]$ to find $c_n\in (x_0,x_n)$ such that
$$ f'(c_n)= \frac{f(x_n)-f(x_0)}{x_n-x_0}$$
We know that the limit $\lim_{x \to x_0}f'(x)=L$ exists and is finite, so because $c_n \to x_0$ we obtain
$$ \lim_{n \to \infty} \frac{f(x_n)-f(x_0)}{x_n-x_0}=L$$
The sequence $(x_n)$ was chosen arbitrary, so the limit 
$$ \lim_{x \to x_0, x>x_0} \frac{f(x)-f(x_0)}{x-x_0}$$ exists and is finite. Do the same for the left limit and you find that $f$ is differentiable at $x_0$.
