# Thomae's function variant

let $f:[0,1]\rightarrow \mathbb{R}$ be define as $f=\begin{cases}1, x=0 \\ x, x\in \mathbb{R}\setminus \mathbb{Q} \\ \frac{1}{q}, x=\frac{p}{q}, gcd(p,q)=1 \end{cases}$

$(1)$ I believe this function is continuous at the irrationals, but discontinuous at the rationals.

attempt:

to show it is discontinuous at the rationals, consider a sequence $(x_n)$ of irrationals converging to $0$ with $(x_n)=(\frac{\pi}{n})$, we have as $n \rightarrow \infty$, $x_n\rightarrow 0$, but $f(x_n)={x}$ since every term in the sequence is irrational, and $f(x_n)\rightarrow 0$, but at $x=0$ $f(0)=1$ so the function is not continuous there.

For other rational numbers, I switch to an $\epsilon$-$\delta$ argument:

assume that $f$ was continuous at $x=\frac{p}{q}$, then by definition of continuity, $|f(x)-f(y)|<\epsilon$ when $|x-y|<\delta$, now choose $\epsilon < \frac{1}{q}$, which now implies $|f(x)-\frac{1}{q}|<\frac{1}{q}$ whenever $|x-y|<\delta$, but since the irrationals are dense, we can find an irrational $y$ within a $\delta$-ball of $x$, i.e. $y\in (x-\delta,y+\delta)$, denote this as $y'$ and $f(y')=x$, so $|x-\frac{1}{q}|<\frac{1}{q}$

This is where I get stuck, I don't know where to take it from here. I am pretty sure I need to change my $\epsilon$ but I am not seeing what I should change it to to make the proof work.

$(2)$

To show $f$ is continuous at the irrationals, we can argue by the Archimedian property that $\exists n\in \mathbb{N}$ with $\frac{1}{\epsilon}<n$, and now we can fix a $\delta$ as follows define $\delta=min_{\{i=1,...,n\}}\delta_{i}$, clearly $\delta>0$, and if $x$ is irrational, we have $|f(x)-f(x)|=0$ so continuity at the irrationals is established.

This function is not continuous at the irrationals. Consider $x=\frac e3$ and the sequence $(x_n)_{n\in\mathbb N}$ with:
$$x_n=\sum_{k=0}^n\frac1{3k!}\overset{n\rightarrow\infty}\longrightarrow\frac e3.$$
Then, $f(\frac e3)=\frac e3$ since $e$ is transcendental, but $f(x_n)\leq\frac 1n\overset{n\rightarrow\infty}\longrightarrow0,$ because
$$\sum_{k=0}^n\frac1{3k!}=\frac1{3n!}\sum_{k=0}^n\frac{n!}{k!}$$
with the sum on the right-hand side being an integer that is not divisible by $n$ (all summands except the last are multiples of $n$, with the last one being $1$). This means the $n$ in the denominator will never cancel, while the numerator is replaced by $1$.