The differentiability of the function $f(x)=\pm x^2$ depending on $x$ being rational Define $$f(x) =
\begin{cases}
x^2  & \text{if $x\in\Bbb Q\cap\Bbb R^+$  } \\
-x^2 & \text{if $x\in \Bbb I\cap (\Bbb R^-\cup \{0\})$ }
\end{cases}$$
Is $f$ differentiable at $x=0$? Is $f$ differentiable in $\Bbb R$?
Any hints? Here $\mathbb{I}$ is the set of irrational numbers.

The function is differentiable at $x=0$ but not differentiable otherwise.
At$x=0$, consider the definition of the derivative, i.e. it exists if
$$
\lim_{\delta\rightarrow 0}\frac{f(x+\delta)-f(x)}{\delta} 
$$
exists. At $x=0$, we need to look at 
$$
\lim_{\delta\rightarrow 0}\frac{f(\delta)}{\delta} 
$$
From the definition of limits, we would need to consider all sequences $\{\delta_n\}$ converging to $0$. For any such sequence, we have $f(\delta_n)$ is equal to either $\delta_n^2$ or $-\delta_n^2$ meaning that the above expression is equal to either $\delta_n$ or $-\delta_n$ for all the terms of the sequence. Since $\delta_n\rightarrow 0$, regardless of how $\delta_n$ is chosen, we have
$$
\lim_{\delta\rightarrow 0}\frac{f(\delta)}{\delta} \rightarrow 0. 
$$
On the other hand, if $x\neq 0$ and $x\in \mathbb{Q}$, then if we choose a sequence $\delta_n\rightarrow 0$ such that $\delta_n \in \mathbb{Q}$ for each $n$, we would have 
$$
\lim_{n\rightarrow \infty}\frac{f(x+\delta_n)-f(x)}{\delta_n}= \frac{dx^2}{x} = 2x.
$$
If we choose a sequence $\delta_n\in \mathbb{I}$ for each $n$, then the above limit diverges to $-\infty$. Hence, the aforementioned limit does not exist.
Similar steps would show that the function is not differentiable for $x\in \mathbb{I}$.
