# At which points is the function discontinuous?

Define the function $g(x)$ to take the value 0 at irrational values of $x$ and to take the value $1/q$ when $x=p/q$ is a rational number in lowest terms, $q>0$. At which points is $g$ continuous? At which points is the function discontinuous?

It seems like it would be discontinuous everywhere because between each irrational number there is a rational and between each rational there is an irrational which would imply alternating; however, we know that the irrationals are uncountable and the rationals are countable so it seems odd that the reals would alternate between rational and irrational numbers. So we are stuck on this...

• Evidently we're discontinuous on rationals. So if you're at an irrational $x$ and have an $\epsilon > 0$, then...
– AJY
Commented Nov 9, 2016 at 4:18
• Note: This $g(x)$ is known as Thomae's function. Commented Nov 12, 2016 at 22:47

## 1 Answer

$g$ is discontinuous at every $x\in \Bbb Q$, but is continuous at evey $y\in \Bbb Q^{c}$

Proof:

Let $x$ be rational and $x=p/q$, where $p$ and $q>0$ are relatively prime, then $g(x)=1/q>0$. Choose $\epsilon>0$ such that $1/q\ge \epsilon \gt 0$. Then for any $\delta >0$, we can find some irrational $x_0\in(x-\delta,x+\delta)$, with $|g(x_0)-g(x)|\ge \epsilon$.

Let $y$ be irrational. Suppose that $g$ is discontinuous at some $x_0\in \Bbb Q^{c}$.
Then there is some $\epsilon_0 >0$ such that for each $n\in \Bbb N$, there is $x_n \in (x_0-1/n,x_0+1/n)$ and $|g(x_n)|\ge\epsilon_0$. So $x_n$ must be rational, let $x_n=p_n/q_n$. Note $x_n$ converge to $x_0$.

Since $|g(x_n)|=g(x_n)=1/q_n\ge \epsilon_0$, so $0<q_n\le 1/\epsilon_0$, for all $n$. Note $q_n\in \Bbb N$, so $Q=\{q_n:n\in \Bbb N\}$ must be finite. Hence $X=\{p_n/q_n:n\in \Bbb N\}=\{x_n:n\in \Bbb N\}$ is also finite. But then contradiction arises because there must be some $p_N/q_N$ appears infinitely many times in $x_n$, which means that $x_n$ either converge to $p_N/q_N$, or diverge, and by assumption $x_n \to x_0$.
$\therefore$ $g$ must be continuous at all irrational $y$.

• Thank you very much. I appreciate the thoughtful response. Commented Nov 9, 2016 at 21:25
• I'm having trouble with one part of the proof, though... I can't get my head around why Q would need to be finite in the paragraph starting with "Since" because the natural numbers are an infinite set. They are countably infinite, but not finite...? Commented Nov 10, 2016 at 20:44
• Q is finite because it is bounded in the interval $(0,1/\epsilon_0]$, as $\epsilon_0$ is fixed, so the number of natural numbers in this interval is finite, as all $q_i$'s must be in this interval, so i conclude Q is finite @ryBear
– Nick
Commented Nov 11, 2016 at 5:05
• Thank you. How does this proof not assume there is a string of strictly irrational numbers without rationals? Because that isn't true right? I am having a hard time with that. Does this have to do with the denominators being in lowest terms? Commented Nov 12, 2016 at 23:11
• not sure what you are asking, but $p_n/q_n$ is the "lowest" expression
– Nick
Commented Nov 13, 2016 at 5:10