# Two monotone functions which equal on rational numbers

Let $f,g:\mathbb R\to \mathbb R$ be increasing and $f(r)=g(r)$ for every $r\in\mathbb Q$. Must we have $f(x)=g(x)$ for every $x\in\mathbb R$?

• A potentially-more-interesting variant: are the functions equal a.e.? – R.. Dec 5 '17 at 4:59
• @R. What does a.e. mean? – Eric Duminil Dec 5 '17 at 7:50
• @R.. That would make a nice follow-up question. I think such functions will be equal in a cocountable set (and thus almost everywhere ("a.e.")), but I don't know if every cocountable set can be realized this way. – Joonas Ilmavirta Dec 5 '17 at 8:17
• @R.. Wikipedia monotonic function says an increasing function defined on an interval is differentiable almost everywhere. In particular continuous almost everywhere. So for almost any $x$, both $f$ and $g$ are continuous in that $x$, and so it is clear that they agree there. So if we accept Wikipedia's statement, your answer is yes. – Jeppe Stig Nielsen Dec 5 '17 at 9:12
• @EricDuminil. ... "a.e". means "almost everwhere" which means "except on a set of Lebesgue-measure $0.$" See my previous comment: $f$ and $g$ agree except on a countable set, and countable sets are among the measure-$0$ sets. – DanielWainfleet Dec 5 '17 at 12:00

No. Take $$f(x)=x+\chi_{(\pi,+\infty)}(x)\,,\ \ \ g(x)=x+\chi_{[\pi,+\infty)}(x).$$ Here $\chi_A$ stands for the indicator function of the set $A$; i.e. $\chi_A$ is the function whose value at $x$ is $1$ if $x\in A$, and $0$ otherwise.
• @user3490 Maybe it is easier to define $f$ as $f(x)=x$ for $x\le\pi$ and $f(x)=x+1$ for $x>\pi$. And define $g$ by $g(x)=x$ for $x<\pi$ and $g(x)=x+1$ for $x\ge\pi$. Can you imagine their graphs? – Jeppe Stig Nielsen Dec 5 '17 at 9:17
As the accepted answer shows, it's not necessarily true that the functions are equal everywhere. However, we can show that the set of points where they are not equal is countable. (This implies, and in fact is stronger than, the statement that $f$ and $g$ are equal almost everywhere.)
First, note that if $x \in \mathbb R$ and both $f$ and $g$ are continuous at $x$, then we can take any sequence $\{r_n\}$ of rationals converging to $x$, and we have $$\lim_{n \to \infty}f(r_n) = f\left(\lim_{n \to \infty}r_n\right) = f(x)$$ where the first equality holds because $r_n \to x$ and $f$ is continuous at $x$. Similarly, $$\lim_{n \to \infty}g(r_n) = g(x)$$ Since $f(r_n) = g(r_n)$ for every $n$, this means that $f(x) = g(x)$. So, the functions are equal at any point where they are both continuous.
Furthermore, we know that $f$ and $g$ are monotone functions. This means that each function must be continuous everywhere except possibly on a countable set. For a proof, see here, for example. Let $D_f$ and $D_g$ respectively denote the sets where $f$ and $g$ are discontinuous. These sets are countable. Note that $D_f \cup D_g$ is still countable (the union of two countable sets is countable), and $f$ and $g$ are both continuous (hence equal) everywhere in the complement of $D_f \cup D_g$.