Prove that a piecewise function $f$ is differentiable at $0$ $f(x)= e^{-\frac{1}{x}}$, $x>0$
$f(x)=-x^2$, $x\leq0$
This is a function that is defined for $x$ here above .
How can I prove that the derivative of $f$ exists at $x=0$.
 A: As you've tried to compute it by definition and failed, let me help you.
One has $$\lim \limits_{x\to 0^+}\left(\dfrac{f(x)-f(0)}{x-0}\right)=\lim \limits_{x\to 0^+}\left(\dfrac{e^{-1/x}}x\right)=0$$
You can justify the last equality by saying that the exponential crushes polynomials or by change of variables with $t=-\frac 1 x$.
On the other side one gets
$$\lim \limits_{x\to 0^-}\left(\dfrac{f(x)-f(0)}{x-0}\right)=\lim \limits_{x\to 0^-}\left(\dfrac{-x^2}{x}\right)=0.$$
A: Formally the derivative $f'(0)$ of the function $f$ in point $0$ is defined as $$f'(0)=\lim_{h\to 0}\frac{f(0+h)-f(0)}{h}=\lim_{h\to 0}\frac{f(h)}{h}$$ since $f(0)=-0^2=0.$ Now since $f$ changes it's type in zero, we have to take the limit for $h \to 0^-$ and $h \to 0^+$. It is $$\lim_{h\to 0^-}\frac{f(h)}{h}=\lim_{h\to 0^-}\frac{-h^2}{h}=\lim_{h\to 0^-}-h=0$$ and by the series expansion of $e^{-\frac1h}$ $$\begin{align*}\lim_{h\to 0^+}\frac{f(h)}{h}&=\lim_{h\to 0^+}\frac{e^{-\frac1h}}{h}=\lim_{h\to 0^+}\frac{1}{he^{\frac1h}}=\lim_{h\to 0^+}\frac{1}{h(1+(1/h)+\frac{(1/h)^2}{2!}+\ldots)}=\\&=\lim_{h\to 0^+}\frac{1}{h+1+\frac{(1/h)}{2!}+\ldots}=\frac{1}{0+1+\infty+\ldots}=\\&=0\end{align*}$$ Thus, $$\lim_{h\to 0^-}\frac{f(h)}{h}=\lim_{h\to 0^+}\frac{f(h)}{h}=0$$ and therefore $$f'(0)=0$$
A: First check that $f$ is continuous at $0$. Then you can try to compute
$$
\frac{d}{dx}e^{-\frac{1}{x}} = \frac{1}{x^2} e^{-\frac{1}{x}}
$$
and
$$
\frac{d}{dx}(-x^2) = -2x.
$$
Since both derivatives converge to zero as $x \to 0^{\pm}$, you can conclude that $f'(0)=0$.
