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$$.

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.

• I didn't learn about sequences, so I try to contradicts this using the definition of limits. So for $x\in\Bbb Q$:$|x+3−L| \lt \epsilon$ and for $x\notin\Bbb Q$:$|−L| \lt \epsilon$, but I can't find an ϵ that will contradicts this. Commented Jan 12, 2020 at 18:15
• I rephrased my answer using the definition of the limit (then you see the argument is essentialy the same as the argument given by Julián). In any case, I think it is good to be able to work both with the definition of the limit and the characterisation using sequences. In this case, I think that the argument using sequences is a little neater. Commented Jan 13, 2020 at 11:53

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}.$$

• You can't choose a specific number for x, you can only choose whether $x \in \Bbb Q$ or not. Commented Jan 13, 2020 at 6:15
• Yes, you can. In fact, you have to choose an adequate one in order to prove that the limit doesn't exist. Commented Jan 13, 2020 at 6:24
• But how do you show, for example, that $x=1$ does satisfy $|1-3| \lt \delta$? Commented Jan 13, 2020 at 7:00
• Your choosing must satisfy first the inequality $|x \mp 3|<\delta$. In general x=1 does not satisfy that inequality. If you prefer, take $x_1<-3$ when proving the limit does not exist for -3 and take $x_1>3$ in the other case. Commented Jan 13, 2020 at 7:31
• What I’m saying is that I don’t know whether that satisfies that inequality since I don’t know the value of $\delta$. How do you know x=1 doesn’t satisfy it? Commented Jan 13, 2020 at 8:01