Skip to main content

Section 1.1 How much information is contained in a number?

Suppose you need to write the actual value of a number, say \(\sqrt{2}\text{,}\) for instance on a piece of paper or on a segment of RAM. The symbol \(\sqrt{2}\) obviously is not the value of the number, it just explains to the reader which number we are talking about: it is the positive number whose square is equal to 2. In order to write the actual value of \(\sqrt{2}\text{,}\) we need to write the number using the positional notation in some base.

What do we mean exactly when we write 647? As we know since elementary school,
\begin{equation*} 647 = 6\times10^2+4\times10^1+7\times10^0 \end{equation*}
In other words, a digit in position \(k\) in a number written in decimal notation says how many summands of \(10^k\) are in the number. Notice that \(k\) can also be negative:
\begin{equation*} 6.47 = 6\times10^0+4\times10^{-1}+7\times10^{-2} \end{equation*}
If one starts evaluating \(\sqrt{2}\) in decimal notation, soon suspects the truth: this number has an infinite number of digits after the dot and they do not repeat.

How can we be sure of this? Recall from college algebra that every rational number, written in decimal, either has a finite number of (non-zero) digits after the dot or has a periodic pattern. Viceversa, every such number can be written as the ratio of two integers. Now, \(\sqrt{2}\) cannot be written as \(\frac{m}{n}\) for any two integers \(m,n\text{.}\) Indeed, if
\begin{equation*} \sqrt{2}=\frac{m}{n} \end{equation*}
then
\begin{equation*} m^2=2n^2 \end{equation*}
but this cannot be: in \(m^2\text{,}\) since it is a square, there is either none or an even number of factors 2, while in \(2n^2\text{,}\) for the same reason, there is an odd number of factors 2!

Since the number of digits is infinite and they do not repeat, the decimal expression of \(\sqrt{2}\) contains an infinite amount of information. Hence, there is no hope to store the exact explicit value of any irrational number in any physical device, not now nor ever.

In other words, when we assign, in any computer language, \(\sqrt{2}\) to a variable \(a\text{,}\) the value of \(a\) is not\(\sqrt{2}\) but an approximation of it. In particular, \(a^2\) is not exactly equal to 2, as the code above shows:

The situation does not improve much with decimal rational numbers. On one side, in any base most rational numbers have a periodic pattern after the dot. Since a concrete system can only store a finite number of digits, when we assign such number to a variable, that variable has a slightly different value. The code below shows the effects of this fact:

On the other side, given any integer \(k\text{,}\) most rational numbers with a finite number of digits have a number of digits larger than \(k\text{,}\) so even most of these numbers cannot be represented exactly in any given system of numbers representation.

What we learned in this section can be summarized as follows: