Non-differentiability of a function I was given this function:
$$
f(x)=
\begin{cases}
x^2, & x\in\Bbb Q\\
9, & x\notin \Bbb Q
\end{cases}
$$
Is it non-differentiable at every $x \in \mathbb R$?
I think so and I wrote it as $f(x) = D(x)(x^2-9)+9$, where $D(x)$ is Dirichlet function and I know it is non-differentiable at every $x \in \mathbb R$, but in this example I can't say that for sure when $x = 3$ and $x = -3$.
 A: You will have to check the points $x=3$ and $x=-3$ separately. In fact,  by symmetry, it is sufficient to check one of these, say $x=3$. So we will have to see if $\lim_{x \to 3}\frac{f(x)-f(3)}{x-3}$ exists.
This limit does not exist. Indeed, take some sequence $(a_n)$ in $\mathbb R \setminus \mathbb Q$ that converges to $3$. Then $\lim_{n \to \infty} \frac{f(a_n)-f(3)}{a_n-3}= \lim_{n \to \infty} \frac{9-9}{a_n-3} = 0$. However, if we take some sequence $(q_n)$ in $\mathbb Q$ converging to $3$, then we have $\lim_{n \to \infty} \frac{f(q_n)-f(3)}{q_n-3} = \lim_{n \to \infty} \frac{q_n^2-9}{q_n-3}= 6$.
I will rephrase the argument not using sequences. Suppose that the limit exists. Since for any $\delta>0$, there exists a irrational number $a$ in the interval $]3-\delta,3+\delta[$ for which $\frac{f(a)-f(3)}{a-3}=0$, we have that the limit must be zero. But this interval also contains an rational number $q$, which we can pick such that $|q-3|<1$. Then $\frac{f(q)-f(3)}{q-3}=q+3$. Thus $\frac{f(q)-f(3)}{q-3}=q+3 > 2$ so the limit cannot be zero. This is a contradiction.
A: We say that $\lim_{x\rightarrow x_0} f(x)$ converges in $\mathbb{R}$ if $$\exists!L\in\mathbb{R}(\forall\epsilon>0\ \exists\delta>0\ \text{such that } \forall x \text{ satisfying } |x-x_0|<\delta \text{ there must happen that } |f(x)-L|<\epsilon).$$
The negation of this statement (to say that the limit doesn't exist) is as following
$$\forall L\in\mathbb{R} \ \exists\epsilon>0\ \forall \delta>0 \  \exists x \text{ such that }|x-x_0|<\delta \text{ and } |f(x)-L|\geq\epsilon.$$
Therefore, to show that the limit
$$\lim_{x\rightarrow \pm3} \frac{f(x)-9}{x\mp3}$$
doesn't exist (where $f(x)$ is your function), for all $L\in\mathbb{R}^*$ ($\mathbb{R}^*=\mathbb{R}-\{0\}$), take $\epsilon=|L|$. For all $\delta>0$, the interval $[\pm 3-\delta, \pm 3+\delta]$ always contains an irrational number, lets say $x_0$. In that case, $|\frac{f(x_0)-9}{x_0\mp3}-L|=|L|\geq \epsilon.$
Now, if $L=0$, take $\epsilon =2$, and $\forall\delta>0$ choose a rational number $x_1$ in the interval $[\pm 3-\delta, \pm 3+\delta]$ (if $x=3$, take $x_1>3$, and if $x=-3$, take $x_1<-3$). In this case, $|\frac{f(x_1)-9}{x_1\mp3}-L|=|x_1\pm 3|\geq\epsilon$.
Thereby, as the limit of interest doesn't exist for $x=\pm3$, your function is non-differentiable at every $x\in\mathbb{R}.$
