# Counterexample: Continuous, but not uniformly continuous functions do not preserve Cauchy Sequences

I want to prove this:

There exists a continuous function $f:\mathbb{Q}\to\mathbb{Q}$, but not uniformly continuous, and a Cauchy sequence $\{x_n\}_{n\in\mathbb{N}}$ of rational numbers such that $\{f(x_n)\}_{n\in\mathbb{N}}$ is not a Cauchy sequence.

More particular: Does there exist a Cauchy sequence $\{x_n\}_{n\in\mathbb{N}}$ of rational numbers such that $\{x_n^2\}$ is not Cauchy?

I think that would be weird, and the counterexample should be with some function that is continuous in $\mathbb{Q}$ but not in $\mathbb{R}$. Am I right? Which would be some example of that?

Let us note $$A = \{x \in \mathbb{Q} : x > \sqrt{2}\}.$$ Then the characteristic function $\chi_A : \mathbb{Q} \to \mathbb{Q}$ is continuous but doesn't preserve Cauchy sequences.
• @Arthur If $\chi_A$ were uniformally continuos, then you would be able find $\delta >0$ such that, for any $x,y \in \mathbb{Q}$ if $|x-y|<\delta$ the $|f(x)-f(y)|<\frac{1}{2}$. Clealy, this is not the case: for any $\delta>0$ just take $x \in (\sqrt{2}-\delta/2 , \sqrt{2}]\cap \mathbb{Q}$ and $y \in [\sqrt{2},\sqrt{2}+\delta/2) \cap \mathbb{Q}$ and you wil have $|x-y|<\delta$, $f(x)=1$ and $f(y)=0$. By the way, that is precisely why it does not preserve Cauchy sequences. – Ramiro Mar 5 '16 at 1:15
You are right that the counterexample must be a function which is not the restriction to $\mathbb{Q}$ of a continuous function from $\mathbb{R}$ to $\mathbb{R}$. In particular, there does not exist a Cauchy sequence of rational numbers $(x_n)$ such that $(x_n^2)$ is not Cauchy.
Let $(x_n)$ be a Cauchy sequence of rational numbers and let $f:\mathbb{R}\to\mathbb{R}$ be a continuous function such that $f(\mathbb{Q})\subset\mathbb{Q}$. Since $(x_n)$ is Cauchy and $\mathbb{R}$ is complete, $(x_n)$ converges (in $\mathbb{R}$, not necessarily to a rational number). Then by the continuity of $f$, the sequence $(f(x_n))$ converges. But convergent sequences are Cauchy, so $(f(x_n))$ is Cauchy. Restricting the function $f$ to $\mathbb{Q}$ and applying it to $(x_n)$ still yields a Cauchy sequence.
Another simple example is given by $f(x)=\frac1{x^2-2}$.