Showing that $f(x)=x^2$ for $x \in \mathbb{Q}$ and $f(x)=0$ for $x \not\in \mathbb{Q}$ is differentiable in $x=0$ I am supposed to show that $f(x) = x^2$ for $x$ in the rationals and $f(x) = 0$ for $x$ in the irrationals is differentiable at $x = 0$ and I am supposed to find the derivative of $f(x)$ at $x = 0$.
Is my proof correct or not?
My proof:
consider limit as $h\rightarrow0$ of $\frac{f(0 + h) - f(0)}h$ 
then we have limit as $h\rightarrow0$ of $\frac{h^2 - 0^2}h$
and then we get limit as $h\rightarrow0$ of $\frac{h^2}h
=$ limit as $h\rightarrow0$ of $h= 0 = $ the derivative of $f(x)$ at $0$
 A: You're pretty close, but you're missing the case when $x$ is irrational.
To find the derivative we have to evaluate $$f'(0)=\lim\limits_{x\rightarrow 0}\frac{f(x)-f(0)}{x-0}=\lim\limits_{x\rightarrow 0}\frac{f(x)}{x}$$ since $f(0)=0^2=0$. One way to evaluate this is to let $(x_n)\rightarrow 0$ be an arbitrary sequence converging to zero with $x_n\neq 0$ for all $n$. Then if $$\lim\limits_{n\rightarrow\infty}\frac{f(x_n)-f(0)}{x_n-0}=\lim\limits_{n\rightarrow\infty}\frac{f(x_n)}{x_n}=0$$ we're done. Let $\varepsilon>0$ be given. We're trying to find $N\in \mathbb{N}$ such that $\forall\ n\geq N$, $\frac{f(x_n)}{x_n}<\varepsilon$. Note that since $(x_n)\rightarrow 0$, $\exists\ N\in\mathbb{N}$ such that $\forall\ n\geq N, |x_n|<\varepsilon$. Now let $n\geq N$. Let's evaluate $\frac{f(x_n)}{x_n}$.
Case 1 $x_n\in\mathbb{Q}$. Then $$\frac{f(x_n)}{x_n}=\frac{(x_n)^2}{x_n}=x_n<\varepsilon\  \checkmark$$
Case 2 $x_n\notin\mathbb{Q}$. Then 
$$\frac{f(x_n)}{x_n}=\frac{0}{x_n}=0<\varepsilon\ \checkmark$$
Thus $f$ is differentiable at $0$ and $$f'(0)=\lim\limits_{x\rightarrow 0}\frac{f(x)-f(0)}{x-0}=0$$
A: Perhaps another way of looking at this is the following. As stated elsewhere, your goal is to compute
$$
\lim_{h\to 0} \frac{f(h) - f(0)}{h} = \lim_{h\to 0} \frac{f(h)}{h}
$$
and to show that this is equal to zero. The issue of course is that you must pay attention to the fact that your function is not defined by just one formula, but by cases depending on the rationality of $h$.
We can try deal with this case-wise, but in my opinion a simpler way to address this is to use inequalities!
Note that for all real numbers $h$, we have that $0 \leq f(h) \leq h^2$. If we divide by $h$, this reads $0 \leq f(h)/h \leq h$. Consequently, we have that
$$
0 = \lim_{h\to 0} 0 \leq \lim_{h \to 0} \frac{f(h)}{h} \leq \lim_{h\to 0} h = 0
$$
and so by the squeeze theorem, it follows that our desired limit is zero.
