# Prove $\lim f_n(x) = f(x)$, where $f(x)=0$ for $x$ irrational and $f(x)=1/q$ if $x =p/q$ is irreducible.

Let $r_1,\ldots ,r_n, \ldots$ a enumeration of rational numbers such that $r_n=p_n/q_n$ is given in irreducible form. For each $n\in \mathbb{N}$, consider a continuous function $f_n:\mathbb{R}\rightarrow \mathbb{R}$ such that, on the intervals that its not zero, it has a graph formed up by $n$ isosceles triangles whose vertices are $(r_1,1/q_1),\ldots,(r_n,1/q_n)$ and all basis of length $1/n$ (in such a way that no triangle do overlap) setted in the $x$-axis. Show that for all $x\in \mathbb{R}$ it is $\lim f_n(x)=f(x),$ where $f(x)=0$ for $x$ irrational and $f(x)=1/q$ if $x=p/q$ is irreducible. Futhermore, show that at no interval on the real line it is $f_n\rightarrow f$ uniformly.

I have been doing some draws to visualize what is happening. It seems pretty intuitive that the sequence of $f_n$ must converge to $1/q$ if $x=p/q$ is irreducible. But i'm really struggling when it comes to write down what i can visualize. I think that the most difficult aspect is to work with an arbitrary enumeration of rationals.

Any help?

• Does $r_i$ cover all the rational numbers? Otherwise, $f(x) = 0$ for some rational not appearing in the countable family. – астон вілла олоф мэллбэрг Oct 21 '17 at 0:25
• @астонвіллаолофмэллбэрг i can't say for sure, because i have just copied the exercise as it is sateted in my book. But i think that the answer is yes. – math.h Oct 21 '17 at 0:58
• @астонвіллаолофмэллбэрг go ahead, please. It will be much appreciated – math.h Oct 21 '17 at 1:10
• Another small query : it may be possible that the triangles overlap, right? But in that case, how is the graph of $f$ defined at the overlapping points? – астон вілла олоф мэллбэрг Oct 21 '17 at 1:16
• can you explain more why those triangles may overlap? – math.h Oct 21 '17 at 1:27

Suppose $x \in \mathbb{Q}$. Then $x=r_n$ for some $n \in \mathbb{N}$, so $f_m (x) := 1/q_n$ for every $m \geq n$.
Suppose now that $x \in \mathbb{R} \setminus \mathbb{Q}$.
Then $\forall q\in \mathbb{N},\exists! n'_q,n_q \in \mathbb{Z} \mbox{ such that }\frac{n'_q}{q} \leq x \leq \frac{n_q}{q}$, with each side of inequality being irreducible and $n_q-n'_q$ being minimal. (*)
So, $\forall p\in\mathbb{N}$, we may take sufficiently large $n$ such that $f_n(x)$ does not belong to any triangle whose vertex's heigth is $\geq \frac{1}{p}$, since by (*) we have a finite number of rationals with this property closest to $x$, and the triangles don't overlap. Since it holds for every $p \in \mathbb{N}$ we conclude that $$\forall p \in \mathbb{N}, f(x)\leq \frac{1}{p}.$$ Hence we conclude that $f(x) = 0$.
Since $f$ isn't continuous for every non-zero rational number (take some irrational sequence approximating the given rational), and $\mathbb{Q}\setminus \{0\}$ is dense in R we infer that for any interval the convergence isn't uniform.