# Test the Function for continuity using the Epsilon-Delta definition.

Problem: Test the following function for continuity. $$f(x)=\begin{cases} x^2 & x\text{ is rational, } \\ -x^2 & x\text{ is irrational. } \\ \end{cases}$$

My attempt: Pick $x_0\in \mathbb{R}$. Then for any $\varepsilon>0$ we have to find $\delta>0$ such that at $|x-x_0|<\delta$, the inequality $|f(x)-f(x_0)|<\varepsilon$ holds. I suspect that this function is discontinuous everywhere and in order to prove that one usually guesses a value for $\varepsilon$ such that inequality $|f(x)-f(x_0)|<\varepsilon$ never holds. What value should I pick for $\epsilon$ ?

Note that $f$ is continuous at $x_0=0$. Let $\varepsilon>0$. If $|x-x_0|=|x|<\delta:=\sqrt{\varepsilon}$ then $$|f(x)-f(x_0)|=|\pm x^2-0|=|x|^2<\delta^2=\varepsilon.$$
Moreover, we have that $f$ is not continuous at $x_0\not=0$:
i) If $x_0$ is rational choose a sequence $\{x_n\}_{n\geq 1}$ of irrationals which converges to $x_0$. For example take $x_n=x_0+\frac{1}{\sqrt{n^2+1}}$. Then, as $n\to +\infty$, $$f(x_n)-f(x_0)=-x_n^2-x_0^2\leq -x_0^2<0.$$ and therefore $f(x_n)-f(x_0)\not \to 0$.
ii) If $x_0$ is irrational choose a sequence $\{x_n\}_{n\geq 1}$ of rationals which converges to $x_0$. By density of $\mathbb{Q}$ in $\mathbb{R}$, for $n\geq 1$, there is $x_n\in (x_0,x_0+\frac{1}{n})$ then $$f(x_n)-f(x_0)=x_n^2+x_0^2\geq x_0^2>0$$ and therefore $f(x_n)-f(x_0)\not \to 0$.
• You mean the fact that $\lim_{x\to x_0} f(x)=L$ iff for all sequences such that $x_n\to x_0$ then $f(x_n)\to L$? – Robert Z Sep 14 '16 at 15:15