Probably Random

A blog by Paul Siegel

Decimals are Hard

April 14, 2018

Fractions are hard.

I am regularly regaled with tales of childhood trauma in the math classroom, and the arithmetic of fractions is a typical antagonist. Online guides on how to learn or teach fractions are a dime a dozen, and a professor of mathematics at the University of Pennsylvania even once called for their abolition from elementary education. Based on a brief stint teaching math to teenagers last year, I can confirm that fractions are trouble.

But they are also beautiful. The key idea which makes fractions tick is subdivision: if you want to compare, say, $\frac{1}{6}$ to $\frac{3}{8}$, the trick is to divide both quantities into smaller pieces (in this case, $24$ths) so that they are expressed in the same “units”. Once you truly internalize the idea of subdivision, the world of fractions welcomes you as a friend.

But I think most people would prefer to simply punch their fractions into a calculator wherein they are violently beaten into decimal notation. Decimal notation is simply the expression of a number in terms of fractions involving powers of ten: tenths, hundreths, thousandths, and so on. Instead of the perfectly ordinary object $\frac{1}{6}$, people are apparently much more content to work with $0.1666…$, shorthand for the limit of an infinite sequence of fractions with infinitely many distinct denominators.

Aside from the fact that I find this practice morally perverse, it leads almost immediately to some hairy philosophical questions and even some unsolved problems in mathematics. In other words, fractions may be hard, but decimals are arguably harder.

$0.9999… = ?$

Let us begin by confronting the beast of numbers whose decimal expansions require infinitely many nonzero digits. What does it even mean to write equations like $\frac{1}{3} = 0.333…$? What do the ellipses actually mean?

I don’t think it is particularly obvious - at the very least, it is less obvious than the notion of a fraction or a finite decimal expansion. In short, the ellipses are best thought of as a limiting procedure. We can form without ambiguity the sequence of numbers $0.3$, $0.33$, $0.333$, etc., and it is possible to show that this sequence is getting closer and closer to a limiting value as we continue further and further out. There is even an algorithm which calculates the limiting value precisely; to see it, it is ironically easiest to convert everything back into fractions:

\[0.3 = \frac{3}{10}, \quad .33 = \frac{3}{10} + \frac{3}{10^2}, \quad .333 = \frac{3}{10} + \frac{3}{10^2} + \frac{3}{10^3}\]

This is best expressed using language borrowed from calculus (an unfortunate property for a tool used to teach arithmetic to children):

\[.333... = \lim_{N \to \infty} \sum_{k=1}^N \frac{3}{10^k}\]

This is what I would take to be the definition of the notation $0.333…$: it is the limit of an infinite series. Of course, it is not obvious that this limit exists or that its value is $\frac{1}{3}$, but it helps to rewrite things a bit:

\[.333... = \frac{3}{10} \lim_{N \to \infty} \sum_{k=0}^N \left(\frac{1}{10}\right)^k\]

The sum appearing on the right-hand side is an example of a geometric series, and there is a particularly simple formula which simplifies these sorts of sums:

\[\sum_{k=0}^N r^k = \frac{1 - r^{N+1}}{1 - r}\]

for any number $r$. In our case, where $r = \frac{1}{10}$, we can start to see what happens as $N$ approaches infinity: $r^{N+1}$ gets closer and closer to zero, so the limit is simply $\frac{1}{1 - r}$. This holds whenever $\abs{r} < 1$. It follows that the limit which defines $0.333…$ exists, and its value is:

\[0.333... = \frac{3}{10} \lim_{N \to \infty} \sum_{k=0}^N \left(\frac{1}{10}\right)^k = \frac{3}{10} \frac{1}{1 - \frac{1}{10}} = \frac{1}{3}\]

Whew.

As an application of this calculation, we can settle a question which vexes many who bother to think carefully about decimal arithmetic: what is the value of $0.999…$? This question is closely related to Zeno’s dichotomy paradox, which questions how one can traverse any distance given that one must first traverse half the distance, then a quarter, then an eigth, and so on. The hardest part of the $0.999…$ puzzle (as well as Zeno’s paradox) is getting the definition of a limit right, but with the calculation above as a guide the reader can verify that $0.999…$. Is equal to $1$.

Or is it? The precise definition of a limit - which I will not go into here - has been a cornerstone of mathematics for over a century. But the definition is rather different from the language that powered calculus for the first few hundred years of its existence; this language was based on “infinitesimal” quantities which are not zero but still somehow smaller than any positive number. In the 20th century mathematicians were able to provide rigorous foundations for the old language of infinitesimals, and it may be the case that $0.999…$ differs from $1$ by a nonzero infinitesimal in this framework.

I am too poorly educated in the new framework (dubbed non-standard analysis) to make a final judgment one way or the other, but the fact that one must confront serious technical and philosophical challenges to properly make sense of so simple an object as the number $\frac{1}{3}$ suggests to me that decimals should not necessarily have the final word on how we do arithmetic.

Decimals to fractions

It gets worse. Let’s say we set aside the philosophical issues raised in the last section. Decimal expansions have the advantage that they behave a bit like whole numbers for the purposes of basic arithmetic, so if it happens to be straightforward to pass back and forth between fractions and decimal expansions then maybe the philosophical baggage is worth it.

The good news is that there are algorithms for passing back and forth between a fraction and its decimal expansion. The bad news is that the behavior of these algorithms is highly unpredictable and poorly understood.

To begin, let us fix some terminology and notation. Recall that a rational number is a number which can be expressed as the ratio of two integers; $\frac{1}{3}$ is an example, while numbers like $\sqrt{2}$ and $\pi$ are not (though this is not obvious). The well-informed reader may be aware that rational numbers can be characterized by the fact that their decimal expansions are eventually repeating, meaning they consist of a finite sequence of digits followed by another sequence of digits which is repeated infinitely many times. For instance, the number:

\[0.123450101010101...\]

is rational, while the number:

\[0.12345010010001000010000010000001...\]

is not. This fact is important enough that it is worth proving in some detail.

Every real number with an eventually repeating decimal expansion is rational.

Express the decimal expansion of $x$ as:

\[x = 0.p_1 \ldots p_m \overline{r_1 \ldots r_n}\]

Here the $p_i$’s represent the digits of the finite prefix and the $r_j$’s are the digits of the repeating part (with the overline used as notation to indicate repetition). Multiplying both sides by $10^m$ gives:

\[10^m x = p_1 \ldots p_m . \overline{r_1 \ldots r_n}\]

This is the sum of an integer and a repeating decimal with no prefix, so it suffices to show that the repeating part $0.\overline{r_1 \ldots r_n}$ is a rational number. Let $y$ denote the integer whose digits are $r_1, \ldots, r_n$; we have:

\[0.\overline{r_1 \ldots r_n} = \sum_{k=1}^\infty \frac{y}{10^{kn}} = \frac{y}{10^n} \sum_{k=0}^\infty \left(\frac{1}{10^n}\right)^k\]

We recognize this as the sum of a geometric series as in the last section, and its sum is:

\[0.\overline{r_1 \ldots r_n} = \frac{y}{10^n} \frac{1}{1 - \frac{1}{10^n}} = \frac{y}{10^n - 1}\]

This is certainly the ratio of two integers, so it is rational.

Fractions to decimals and Artin’s conjecture

The converse of this statement is also true: every rational number has an eventually repeating decimal expansion. It turns out that to prove this statement it suffices to check rational numbers of the form $\frac{1}{p}$ where $p$ is a prime number; carrying out this reduction just involves some elementary number theory which we will omit for the sake of expediency. Note that the result is straightforward in the case $p = 2$ and $p = 5$, since the decimal expansions $0.5$ and $0.2$, respectively, have no repeating part. For the other primes we don’t even need a prefix: the decimal expansions simply consist of a finite sequence of digits repeating over and over.

To prove this we will use the language of arithemtic “mod $p$”, wherein we will reduce every integer to its remainder when divided by $p$. For instance, $20$ divided by $3$ is equal to $6$ with a remainder of $2$, so we we write:

\[20 = 2 \mod 3\]

Note that the only possible values of these remainders are the numbers $0, 1, \ldots, p-1$.

Every rational number of the form $\frac{1}{p}$ where $p$ is a prime number other than $2$ and $5$ has a repeating decimal expansion.

Consider the numbers $10^n$ reduced mod $p$. There are infinitely many numbers of this form but only $p$ possible values mod $p$, so at least one value occurs more than once. In other words, there are integers $n_1$, $n_2$, and $r$ such that:

\[10^{n_1} = 10^{n_2} = r \mod p\]

Assume without loss of generality that $n_1 > n_2$; subtracting, we get:

\[10^{n_1} - 10^{n_2} = 10^{n_2}(10^{n_1 - n_2} - 1) = 0 \mod p\]

This means that the expression $10^{n_2}(10^{n_1 - n_2} - 1)$ is divisible by $p$; since $p$ is prime we must have either that $p$ divides $10^{n_2}$ or $10^{n_1 - n_2} - 1$. But the only prime factors of $10^{n_2}$ are $2$ and $5$, so by our assumption on $p$ the latter must hold.

Setting $n = n_1 - n_2$, this means there is some $y$ such that $yp = 10^n - 1$. Dividing, we get:

\[\frac{1}{p} = \frac{y}{10^n - 1} = \frac{y}{10^n} \frac{1}{1 - \frac{1}{10^n}}\]

But as in the proof of the previous proposition we can express this as the sum of a geometric series in powers of $10$. Thus the decimal expansion is just $\frac{1}{p} = 0.\overline{y}$.

There is of course an algorithm, namely long division, which computes the decimal expansion of any rational number. But in order to know when to halt the algorithm we need some information about the number $n$ of repeating digits in the expansion, which we will call the period of the number. The periods of the reciprocals of the first few primes (other than $2$ and $5$) don’t exhibit any obvious pattern:

\[\frac{1}{3} = 0.\overline{3} \quad n = 1\] \[\frac{1}{7} = 0.\overline{142857} \quad n = 6\] \[\frac{1}{11} = 0.\overline{09} \quad n = 2\] \[\frac{1}{13} = 0.\overline{076923} \quad n = 6\] \[\frac{1}{17} = 0.\overline{0588235294117647} \quad n = 16\] \[\frac{1}{19} = 0.\overline{052631578947368421} \quad n = 18\]

Looking back at the proof of the previous proposition, we see that $n$ is the solution to the equation:

\[10^n = 1 \mod p\]

Solving equations of this form is called the discrete logarithm problem; this problem is so computationally intractible in general that it is used as an alternative to prime factorization for constructing secure cryptographic systems.

One elementary fact (which the clever reader might try to prove) is that $p-1$ is always divisible by $n$, and in particular $p-1$ is the maximum value for $n$. In the table of values above we see that $n$ attains its maximum value three times: for $p=7$, $p=13$, and $p=17$.

Question: Are there infinitely many primes $p$ such that the decimal expansion of the number $\frac{1}{p}$ has period $p-1$?

This is an open problem. Emil Artin conjectured in 1927 that there are infinitely many such primes and he even predicted their density in the integers, but as of 2018 there is no proof. The best progress currently is a proof due to Hooley in 1967 that Artin’s conjecture would follow from the Generalized Riemann Hypothesis, one of the most important unsolved problems in mathematics.

Conclusion

Decimals are hard. It is unlikely that the ideas in this post will affect your life much if you are content to punch numbers into a calculator when you need to do arithmetic. And I certainly don’t want this post to be construed as a recommendation for how arithmetic should be taught in schools - mathematical pedagogy and mathematics are very different subjects.

Instead, the point of this post was to show that even some of the most basic questions about arithmetic with decimals are connected to deep unsolved problems in mathematics. This is not the case for arithmetic with fractions, which can be more or less entirely reduced to the technique of subdivision. So if you believe that fractions are conceptually more difficult than decimals, I beg to differ!