proving differentiablty given the function $f\left(x\right)=\begin{cases}
\frac{1}{n+1} & \exists n\in\mathbb{N}:x=\frac{1}{n}\\
x & \text{else}
\end{cases}$
is f differentiable at $0$? if so what is the derivative at $0$?
 A: We have $f(0)=0$, and put $g(h):=\frac{f(h)-f(0)}h=\frac{f(h)}h$. We want to find the limit of this quantity when $h\to 0$ if this limit exists. Fix an integer $N$. If $|x|\leq \frac 1N$, either $x$ is of the form $x=\frac 1n$, $n\geq N$ or not. In the first case, $g(x)=\frac{n+1}n$ so $|g(x)-1|\leq\frac 1n\leq \frac 1N$ and in the second case $|g(x)-1|=0$. So for all $x$ such that $|x|\leq \frac 1N$, we have $|g(x)-1|\leq \frac 1N$. We conclude that $f$ is differentiable at $0$ and the derivative is $1$. 
A: If you go to de definition of derivate, you get :
f'(0)=lim(f(h)/h) when h goes to zero, since f(0)=0.
f(h)/h is equal to n/(n+1) if h=1/n, or 1 if h is not of taht form.
Is easy to prove that the limit" lim(f(h)/h) when h goes to zero" is 1'
then the derivate at zero is 1.
A: We need to evaluate
$$
\lim_{h\rightarrow 0} {f(0+h)-f(0)\over h}=
\lim_{h\rightarrow 0} {f( h) \over h}.
$$
If   this limits exists, it will follow that $f$ is differentiable at $0$ and that $f'(0)$ is the value of the limit.
Let's consider
$$\tag{1}
\lim_{h\rightarrow 0^+} {f( h) \over h}. 
$$
Note that the limit expression ${f( h) \over h}$ is equal to 1 unless $h$ is of the form $h=1/n$ for some positive integer $n$.  In this case, the limit expression is $${1/(n+1)\over 1/n}={n\over n+1}={1\over 1+h}&lt1.$$ We thus have 
$${1\over1+h}\le {f(h)\over h}\le 1,\quad\text{for all }\ h>0.$$ 
Now apply the Squeeze Theorem to show that $\lim\limits_{h\rightarrow 0^+} {f( h) \over h}=1$.
Since $\lim\limits_{h\rightarrow 0^-} {f( h) \over h}=1$, it follows that  $\lim\limits_{h\rightarrow 0 } {f( h) \over h}=1$; and thus  $f'(0)$ exists and is equal to $1$.
