Function that maps the "pureness" of a rational number? By pureness I mean a number that shows how much the numerator and denominator are small.
E.g. $\frac{1}{1}$ is purest, $\frac{1}{2}$ is less pure (but the same as $\frac{2}{1}$), $\frac{2}{3}$ is less pure than the previous examples, $\frac{53}{41}$ is worse, .... $\pi$ isn't pure at all (as well as e...).
 A: A natural pureness measure is the level of the Stern-Brocot tree at which the fraction occurs. Since each run of consecutive left or right steps in the tree corresponds to a continued fraction term equal to the length of the run, the pureness may be defined as the sum of the continued fraction terms.
A: In the same spirit as Rob Arthan's answer, you could use the first time a rational number appears in the Calfin-Wilf sequence.
Define a sequence $a_n$ with $a_0 = 0$, $a_1 = 1$ obeying the recurrences $a_{2n} = a_n$ and $a_{2n + 1} = a_n + a_{n+1}$.  We get
$$0, 1, 1, 2, 1, 3, 2, 3, 1, 4, 3, 5, \ldots$$
The Calfin-Wilf sequence is $c_n = a_n / a_{n+1}$:
$$\frac{0}{1},\frac{1}{1}, \frac{1}{2}, \frac{2}{1}, \frac{1}{3}, \frac{3}{2}, \ldots$$
Every positive rational number appears exactly once in this sequence.  Thus with this measure of "purity", you can always tell which of two rational numbers is "purer".
A: How about $f(\frac{p}{q})=pq$ for rational numbers and $f(x)=0$ when it's irrational?
A: I've read that Euler ranked the harmoniousness of musical intervals, and thus the simplicity of rational numbers, in a way consistent with this function:

*

*$f(p) = p-1$, if $p$ is prime

*$f(ab) = f(a)+f(b)$

*$f(a:b:c:\dots) = f(\mathrm{lcm}(a,b,c,\dots))$
assuming, of course, that the argument is expressed in lowest terms.
Much later: I should mention that I read this in On the Sensations of Tone by Hermann Helmholtz; in Alexander Ellis's translation (1885, reprinted by Dover in 1954), it's the last paragraph on page 230.
A: You can take,
$$\frac{a}{b}\mapsto \frac{a+b}{\gcd(a,b)},$$
Note that this is independent of the choice of representative since $\gcd(na,nb)=n\gcd(a,b)$ for non-negative integers $n$.
For your examples,
$$\frac{1}{1}\mapsto 2,\quad \frac{1}{2}\mapsto 3,\quad\frac{2}{3}\mapsto 5,\quad\frac{53}{41}\mapsto 94.$$
Another possibility is
$$\frac{a}{b}\mapsto \frac{ab}{(\gcd(a,b))^2},$$
which yields
$$\frac{1}{1}\mapsto 1,\quad\frac{1}{2}\mapsto 2,\quad\frac{2}{3}\mapsto 6,\quad\frac{53}{41}\mapsto 2173.$$
Both these "pureness" functions have the property that $a/b$ is as pure as $b/a$, as we would expect.
The following table shows how the first choice partitions the positive rationals into "pureness classes". Each row corresponds to rationals of the same pureness.
$$
\begin{align}
& \frac{1}{1} \\
& \frac{1}{2}\quad\frac{2}{1} \\
& \frac{1}{3}\quad\frac{3}{1} \\
& \frac{1}{4}\quad\frac{2}{3}\quad\frac{3}{2}\quad\frac{4}{1} \\
& \frac{1}{5}\quad\frac{5}{1} \\
& \frac{1}{6}\quad\frac{2}{5}\quad\frac{3}{4}\quad\frac{4}{3}\quad\frac{2}{5}\quad\frac{6}{1} \\
& \frac{1}{7}\quad\frac{3}{5}\quad\frac{5}{3}\quad\frac{7}{1} \\
& \frac{1}{8}\quad\frac{2}{7}\quad\frac{4}{5}\quad\frac{5}{4}\quad\frac{7}{2}\quad\frac{8}{1} \\
& \frac{1}{9}\quad\frac{3}{7}\quad\frac{7}{3}\quad\frac{9}{1} \\
& \frac{1}{10}\quad\frac{2}{9}\quad\frac{3}{8}\quad\frac{4}{7}\quad\frac{5}{6}\quad\frac{6}{5}\quad\frac{7}{4}\quad\frac{8}{3}\quad\frac{9}{2}\quad\frac{10}{1}
\end{align}
$$
A: Maybe you can get inspiration from the Thomae's function.
A: $f(\frac{a}{b})=\frac{1}{|a|+|b|}$
For the following conditions on $x$, $f(x)$ is either zero or not defined:


*

*$x$ irrational

*$x=0$


Higher output values implies high purity.
A: I have often used the sum of the terms in the Continued Fraction. This is


*

*finite for rational numbers

*the same for $x$ and $\frac1x$

*for $0\lt x\lt 1$, the same for $x$ and $1-x$


$$
1=(1)\to1
$$
$$
\frac12=(0,2)\to2\quad\text{and}\quad2=(2)\to2
$$
$$
\frac23=(0,1,2)\to3
$$
$$
\frac{53}{41}=(1,3,2,2,2)\to10
$$
etc.
A: The order of the Farey sequence where the (fractional part) of the rational number first occurs is a measure that should be of interest to you. As you will see from the link, the Farey sequences have many fascinating properties.
