2.3 Rational numbers

Definition 2.3 (Rational number).

A rational number is a real number that can be written as p/qp/q where pp and qq are integers, and q>0q>0.

Let’s explore this definition.

  • 12\frac{1}{2} is a rational number: put p=1p=1 and q=2q=2. (Or p=2p=2 and q=4q=4, the definition does not say that pp and qq must be unique).

  • 12-\frac{1}{2} is a rational number; put p=1p=-1 and q=2q=2.:

  • 0 is a rational number: put p=0p=0 and q=1q=1.

  • Any integer nn is a rational number. [What are pp and qq?]

We can write a rational number in simplest terms by cancelling any common factors in the numerator and denominator. We shall see later that this is actually a consequence of a result called the Fundamental Theorem of Arithmetic.

Later in this section, we shall prove that there are real numbers that are not rational. For now, observe that this is not obvious just from the definition; maybe such pp and qq exist for every real number.

Proposition 2.4.

The product of two rational numbers is rational.

Proof.

Suppose rr and ss are rational numbers. So r=pqr=\frac{p}{q} and s=uvs=\frac{u}{v} for some integers p,q,u,vp,q,u,v with q>0q>0 and v>0v>0. Then

rs=pquv=puqv.rs=\frac{p}{q}\frac{u}{v}=\frac{pu}{qv}.

As p,q,u,vp,q,u,v are integers, then so are pupu and qvqv. As qq and vv are positive, then so is qvqv. Thus rsrs is a rational number.

Exercise 2.5.

Prove that the sum of two rational numbers is rational.

Solution (please try for yourself before looking)

Suppose rr and ss are rational numbers. So r=pqr=\frac{p}{q} and s=uvs=\frac{u}{v} for some integers p,q,u,vp,q,u,v with q>0q>0 and v>0v>0. Then

r+s\displaystyle r+s =pq+uv\displaystyle=\frac{p}{q}+\frac{u}{v}
=pvqv+uqvq\displaystyle=\frac{pv}{qv}+\frac{uq}{vq}
=pv+uqqv.\displaystyle=\frac{pv+uq}{qv}.

As p,q,u,vp,q,u,v are integers, then so are pv+uqpv+uq and qvqv. As qq and vv are positive, then so is qvqv. Thus r+sr+s is a rational number.

Since the sum and product of two rational numbers are also rational, we say the collection of rational numbers is closed under addition and multiplication. These are two properties that contribute to the rational numbers forming an object known as a field. You will explore the concept of field more in the course Introduction to Mathematical Analysis.

2.3.1 From fractions of integers to decimal notation

Consider a rational number p/qp/q, where pp and qq are integers with q>0q>0. Because p/qp/q is a real number, we know that it has a decimal representation

pq=k=0nak10k+k=1bk110k,\tfrac{p}{q}=\sum_{k=0}^{n}a_{k}10^{k}+\sum_{k=1}^{\infty}b_{k}\frac{1}{10^{k}},

where each of a0,a1,a2,ana_{0},a_{1},a_{2}\ldots,a_{n} and b1,b2,b3b_{1},b_{2},b_{3}\ldots is a digit 0,1,2,,90,1,2,\ldots,9.

Example 2.6.

Let’s take a closer look at why 12\tfrac{1}{2} has decimal representation 0.50.5.

To write 12\tfrac{1}{2} in decimal notation means finding digits a0,a1,a2,ana_{0},a_{1},a_{2}\ldots,a_{n} and b1,b2,b3b_{1},b_{2},b_{3}\ldots such that

12=k=0nak10k+k=1bk110k.\tfrac{1}{2}=\sum_{k=0}^{n}a_{k}10^{k}+\sum_{k=1}^{\infty}b_{k}\frac{1}{10^{k}}.

Expanding the sums on the right-hand side gives

12\displaystyle\tfrac{1}{2} =a0100+a1101+a2102++an10n+b11101+b21102+b31103+\displaystyle=a_{0}10^{0}+a_{1}10^{1}+a_{2}10^{2}+\cdots+a_{n}10^{n}+b_{1}% \frac{1}{10^{1}}+b_{2}\frac{1}{10^{2}}+b_{3}\frac{1}{10^{3}}+\cdots
=a0+10a1+100a2++an10n+b110+b2100+b31000+.\displaystyle=a_{0}+10a_{1}+100a_{2}+\cdots+a_{n}10^{n}+\frac{b_{1}}{10}+\frac% {b_{2}}{100}+\frac{b_{3}}{1000}+\cdots.

Now think about what the digits a0,a1,a2,ana_{0},a_{1},a_{2}\ldots,a_{n} and b1,b2,b3b_{1},b_{2},b_{3}\ldots could be. Putting b1=5b_{1}=5 and all other digits equal to zero makes the equation hold because the right-hand side becomes

a0=0+10a1=0+100a2=0++an10n=0+510+b2100=0+b31000=0+.\underbrace{a_{0}}_{=0}+\underbrace{10a_{1}}_{=0}+\underbrace{100a_{2}}_{=0}+% \cdots+\underbrace{a_{n}10^{n}}_{=0}+\frac{5}{10}+\underbrace{\frac{b_{2}}{100% }}_{=0}+\underbrace{\frac{b_{3}}{1000}}_{=0}+\cdots.

Therefore 12\tfrac{1}{2} has decimal representation 0.50.5.

Note that we have not proved that 0.50.5 is the only possible decimal representation of 12\frac{1}{2}. In fact, we shall discover later that it is not!

In this example, it is not so difficult to spot what the digits could be. But writing something like 10253\frac{1025}{3} in decimal notation would take more effort. Fortunately there is a process that can help – it is called the division algorithm.

There are many ways of writing down the division algorithm. You may have learned it as ‘short division’ (sometimes called the ‘bus stop method’) or ‘long division’.

Example 2.7.

Let’s find a decimal representation of 10253\frac{1025}{3} using the division algorithm. Since 10253\frac{1025}{3} is the result of dividing 10251025 by 33, we can use short division.

341.6663)101215.020202\begin{array}[]{r@{\;}c@{\;}rrrrrrrrrrrr}&&&3&4&1&.&6&6&6&\ldots\\ \cline{2-11}\cr 3&\Big{)}&1&{}^{1}0&{}^{1}2&5&.&{}^{2}0&{}^{2}0&{}^{2}0&\ldots% \end{array}

And so a decimal representation of 10253\frac{1025}{3} is 341.6¯341.\overline{6}.

There are other ways of writing down the division algorithm, so do not worry if this looks unfamiliar.

You could also type 1025÷31025\div 3 into a calculator. While that is fine when dividing specific integers, a calculator will not help us prove general statements about writing rational numbers in decimal notation.

The division algorithm gives us a process for writing any rational number in decimal notation.

Definition 2.8 (Terminating decimal).

We say a decimal representation ‘anan1a0.b1b2a_{n}a_{n-1}\ldots a_{0}.b_{1}b_{2}\ldots’ is terminating (or terminates) if only a finite number of the digits are nonzero.

For example,

  • 0.50.5 (which remember is shorthand for 0.50000.5000\ldots) is terminating;

  • 0.00010.0001 is terminating;

  • 0.3¯0.\overline{3} (which is shorthand for 0.3330.333\ldots) is not terminating.

  • 0.17¯0.\overline{17} (which is shorthand for 0.1717170.171717\ldots) is not terminating.

Proposition 2.9.

Every rational number has a decimal representation that either:

  1. (i)

    terminates; or

  2. (ii)

    eventually repeats a block of digits indefinitely to the right. In this case we say the decimal is periodic, or eventually periodic.

Proof.

Let xx be a rational number. Then there exist integerspp and qq, with q>0q>0, so that x=p/qx=p/q. In addition, assume that p0p\geq 0 and that pp has decimal representation ‘pnpn1p1p0p_{n}p_{n-1}\ldots p_{1}p_{0}’. Using short division, we can calculate:

q)pnp1p0.000\begin{array}[]{r@{\;}c@{\;}rrrrrrrrrrrr}\cline{2-11}\cr q&\Big{)}&p_{n}&% \ldots&p_{1}&p_{0}&.&0&0&0&\ldots\end{array}

Each step of the division algorithm involves calculating a remainder strictly less than qq, and so each remainder must be one of the integers 0,1,2,(q1)0,1,2,\ldots(q-1).

Once we reach the tail of 0s, one of two things must happen:

  • If the remainder at any step is 0 then the process stops and so xx has a terminating decimal representation.

  • Each remainder is one of the integers 1,2,,(q1)1,2,\ldots,(q-1). There are (q1)(q-1) such integers, and so the qqth remainder in the tail of 0s is certainly one we have seen before in the tail. From then on, the remainders repeat and so the decimal representation repeats.

If p<0p<0 then p>0-p>0 and so we can apply the same argument to write the positive number p/q-p/q in decimal notation. Negating the decimal representation then gives a representation of p/qp/q.

This proof used the so-called pigeonhole principle. This states that if nn items are put into mm containers, with n>mn>m, then at least one container must contain more than one item. Can you see where this was used in the proof?

To summarise this section, we have proved that every rational number has a terminating or eventually repeating decimal representation. In the next section, we shall prove the converse: that every real number with a terminating or eventually repeating decimal representation is rational.

2.3.2 From decimal notation to fractions of integers

Suppose xx is a real number with terminating decimal representation. Expanding the definition of decimal notation gives us xx as a sum of rational terms.

Example 2.10.

If xx has decimal representation 201.05201.05 then

x=𝟏×100+𝟎×101+𝟐×102+𝟎×110+𝟓×1102,x=\bm{1}\times 10^{0}+\bm{0}\times 10^{1}+\bm{2}\times 10^{2}+\bm{0}\times% \frac{1}{10}+\bm{5}\times\frac{1}{10^{2}},

where the digits are shown in bold just to make them stand out. Evaluating this calculation gives

x\displaystyle x =1+200+5100\displaystyle=1+200+\frac{5}{100}
=201+120\displaystyle=201+\frac{1}{20}
=201×20+120\displaystyle=\frac{201\times 20+1}{20}
=402120.\displaystyle=\frac{4021}{20}.
Proposition 2.11.

Every real number with a terminating decimal representation is a rational number.

Proof.

Let x0x\geq 0 with terminating decimal representation ‘anan1a0.b1b2bma_{n}a_{n-1}\ldots a_{0}.b_{1}b_{2}\ldots b_{m}’. (Here we are not writing the tail of 0s that continues indefinitely to the right.)

Then

x=k=0nak10k+k=1mbk110k,x=\sum_{k=0}^{n}a_{k}10^{k}+\sum_{k=1}^{m}b_{k}\frac{1}{10^{k}},

is a sum of finitely many rational numbers. Such a sum is rational by 2.5.

If x<0x<0 then x>0-x>0 and so we can apply the same argument to write the positive number x-x as a fraction of integers, then negate it to obtain xx as a fraction of integers.

If a decimal representation ‘anan1a0.b1b2a_{n}a_{n-1}\ldots a_{0}.b_{1}b_{2}\ldots’ is not terminating then precisely one of two things must happen. Either:

  1. (i)

    the fractional part ‘0.b1b20.b_{1}b_{2}\ldots’ eventually has a pattern (block of digits) that repeats indefinitely to the right; or

  2. (ii)

    it does not.

We would like to prove that eventually repeating decimals (the first case above) must represent rational numbers.

First consider the special case of real numbers with decimal representation ‘0.b1b2bm¯0.\overline{b_{1}b_{2}\ldots b_{m}}’. That is to say, the repeating pattern starts immediately to the right of the decimal point. This means we are considering decimal representations like:

  • 0.333=0.3¯0.333\ldots=0.\overline{3}; here m=1m=1 and b1=3b_{1}=3.

  • 0.090909=0.09¯0.090909\ldots=0.\overline{09}; here m=2m=2, b1=0b_{1}=0 and b2=9b_{2}=9.

Proposition 2.12.

The real number with decimal representation ‘0.b1b2bm¯0.\overline{b_{1}b_{2}\ldots b_{m}}’ is rational and equals

b1b2bm999m 9s.\frac{\text{`$b_{1}b_{2}\ldots b_{m}$'}}{\underbrace{99\ldots 9}_{\text{$m$ $9% $s}}}.

This result looks complicated because of the notation. It may help to understand the claim by considering some examples:

  • 0.3¯0.\overline{3} is rational and 0.3¯=390.\overline{3}=\frac{3}{9};

  • 0.09¯0.\overline{09} is rational and 0.09¯=9990.\overline{09}=\frac{9}{99};

  • 0.123¯0.\overline{123} is rational and 0.123¯=1239990.\overline{123}=\frac{123}{999}.

Proof.

Let x=0.b1b2bm¯x=\text{`$0.\overline{b_{1}b_{2}\ldots b_{m}}$'}. Writing xx as a sum of terminating decimals, and then expanding the decimal notation gives

x\displaystyle x =0.b1b2bm+0.000m 0sb1b2bm+0.000m 0s00m 0sb1b2bm+\displaystyle=\text{`$0.b_{1}b_{2}\ldots b_{m}$'}+\text{`$0.\underbrace{00% \ldots 0}_{\text{$m$ $0$s}}b_{1}b_{2}\ldots b_{m}$'}+\text{`$0.\underbrace{00% \ldots 0}_{\text{$m$ $0$s}}\underbrace{0\ldots 0}_{\text{$m$ $0$s}}b_{1}b_{2}% \ldots b_{m}$'}+\cdots
=(k=1mbk10k)+110m(k=1mbk10k)+1102m(k=1mbk10k)+\displaystyle=\left(\sum_{k=1}^{m}\frac{b_{k}}{10^{k}}\right)+\frac{1}{10^{m}}% \left(\sum_{k=1}^{m}\frac{b_{k}}{10^{k}}\right)+\frac{1}{10^{2m}}\left(\sum_{k% =1}^{m}\frac{b_{k}}{10^{k}}\right)+\cdots
=b+b10m+b(10m)2+b(10m)3+.\displaystyle=b+\frac{b}{10^{m}}+\frac{b}{(10^{m})^{2}}+\frac{b}{(10^{m})^{3}}% +\cdots.

The whole right-hand side is a geometric series with first term (k=1mbk10k)\displaystyle\left(\sum_{k=1}^{m}\frac{b_{k}}{10^{k}}\right) and common ratio r=110mr=\dfrac{1}{10^{m}}, which is strictly between 0 and 11. Therefore the right-hand side converges to

k=1mbk10k1110m=10mk=1mbk10k10m1=k=1mbk10mk10m1.\displaystyle\dfrac{\sum_{k=1}^{m}\frac{b_{k}}{10^{k}}}{1-\frac{1}{10^{m}}}=% \dfrac{10^{m}\sum_{k=1}^{m}\frac{b_{k}}{10^{k}}}{10^{m}-1}=\dfrac{\sum_{k=1}^{% m}b_{k}10^{m-k}}{10^{m}-1}.

It follows that xx is rational since the numerator and denominator are both integers.

Informally, in decimal notation, the numerator is ‘b1b2bmb_{1}b_{2}\ldots b_{m}’ and the denominator is 999m 9s\underbrace{99\ldots 9}_{\text{$m$ $9$s}}.

We have established that decimals of the form ‘0.b1b2bm¯0.\overline{b_{1}b_{2}\ldots b_{m}}’ represent rational numbers. We now extend this result to any decimal which eventually has a pattern that repeats indefinitely to the right.

Proposition 2.13.

Every real number with a decimal representation that eventually repeats a block of digits indefinitely to the right is rational.

Proof.

Let x0x\geq 0 and suppose xx has an eventually repeating decimal representation ‘anan1a0.b1b2bl1blbl+1bm¯a_{n}a_{n-1}\ldots a_{0}.b_{1}b_{2}\ldots b_{l-1}b_{l}\overline{b_{l+1}\ldots b% _{m}}’.

Then 10lx10^{l}x can be written as anan1a0b1b2bl1bl+0.bl+1bm¯\text{`$a_{n}a_{n-1}\ldots a_{0}b_{1}b_{2}\ldots b_{l-1}b_{l}$'}+\text{`$0.% \overline{b_{l+1}\ldots b_{m}}$'}’ and so, applying Proposition 2.12 to the fractional part gives

10lx\displaystyle 10^{l}x =anan1a0b1b2bl1bl+bl+1bl+2bm999(ml) 9s\displaystyle=\text{`$a_{n}a_{n-1}\ldots a_{0}b_{1}b_{2}\ldots b_{l-1}b_{l}$'}% +\frac{\text{`$b_{l+1}b_{l+2}\ldots b_{m}$'}}{\underbrace{99\ldots 9}_{\text{$% (m-l)$ $9$s}}}

Dividing both sides by 10l10^{l} shows that we can write xx as a sum of two rational numbers. Hence xx is rational.

If x<0x<0 then, as usual, we can apply the same argument to x-x and then negate the resulting rational number.

2.3.3 Some real numbers have more than one decimal representation

We have been careful in these notes not to state that every real number has a unique decimal representation. Indeed, this is not true and is worth exploring.

By Proposition 2.12, we know that 0.9¯0.\overline{9} represents the rational number 99=1\frac{9}{9}=1. In other words, the real number 11 has (at least) two decimal representations, namely

1 and 0.999.1\quad\text{ and }\quad 0.999\ldots.

In fact, this is true of any nonzero integer: 2=1.9¯2=1.\overline{9}, 3=2.9¯3=2.\overline{9}, and so on.

Similarly, any nonzero terminating decimal representation has an equivalent repeating one. For example:

  • 0.1=0.09¯0.1=0.0\overline{9};

  • 0.5=0.49¯0.5=0.4\overline{9};

  • 0.08=0.079¯0.08=0.07\overline{9};

  • 0.184=0.1839¯0.184=0.183\overline{9}.

We record this as a proposition.

Proposition 2.14.

Every nonzero real number with a terminating decimal representation also has an eventually repeating one.

Proof.

Let x>0x>0 with terminating decimal representation ‘anan1a0.b1b2bma_{n}a_{n-1}\ldots a_{0}.b_{1}b_{2}\ldots b_{m}’. We may assume bm0b_{m}\neq 0 [can you see why?]. Replace the digit bmb_{m} with bm1b_{m}-1 and add an infinitely long string of 99s to the right. Then this new decimal representation is

y=k=0nak10k+k=1m1bk110k+(bm1)10m+k=m+1910k.y=\sum_{k=0}^{n}a_{k}10^{k}+\sum_{k=1}^{m-1}b_{k}\frac{1}{10^{k}}+\frac{(b_{m}% -1)}{10^{m}}+\sum_{k=m+1}^{\infty}\frac{9}{10^{k}}.

But k=m+1910k\displaystyle\sum_{k=m+1}^{\infty}\frac{9}{10^{k}} is a geometric series with limit 110m\dfrac{1}{10^{m}} [check you agree], and so

y\displaystyle y =k=0nak10k+k=1m1bk110k+bm10m110m+110m\displaystyle=\sum_{k=0}^{n}a_{k}10^{k}+\sum_{k=1}^{m-1}b_{k}\frac{1}{10^{k}}+% \frac{b_{m}}{10^{m}}-\frac{1}{10^{m}}+\frac{1}{10^{m}}
=k=0nak10k+k=1mbk110k\displaystyle=\sum_{k=0}^{n}a_{k}10^{k}+\sum_{k=1}^{m}b_{k}\frac{1}{10^{k}}
=x.\displaystyle=x.

If x<0x<0 then we can apply the above argument to x-x.

We have just established that it is possible to have two different decimal representations of the same real number. We shall now prove that this only happens under the conditions in Proposition 2.14.

Proposition 2.15.

Let 0.b1b20.b_{1}b_{2}\ldots and 0.c1c20.c_{1}c_{2}\ldots be different non-terminating decimal representations. Then these represent different real numbers.

Proof.

Let xx be represented by 0.b1b20.b_{1}b_{2}\ldots and yy be represented by 0.c1c20.c_{1}c_{2}\ldots.

Since the decimal representations are different, there must be a first digit from the left where they are different.

Suppose this is the mmth digit after the decimal point and suppose assume bm>cmb_{m}>c_{m} (otherwise switch the roles of xx and yy). Our strategy is to find zz so that x>zx>z and zyz\geq y; then we can conclude that x>yx>y [try plotting z,x,yz,x,y on the real line to convince yourself of this]. Hence xyx\neq y.

Note, since bm>cmb_{m}>c_{m} it follows that bm>0b_{m}>0.

Let zz be the real number with decimal representation below.

x=0.b1b2bm1bmbm+1bm+2z=0.b1b2bm1bm00=0.b1b2bm1bm199y=0.c1c2cm1cmcm+1cm+2\begin{array}[]{cccccccccccc}x&=&0&.&b_{1}&b_{2}&\ldots&b_{m-1}&b_{m}&b_{m+1}&% b_{m+2}&\ldots\\ z&=&0&.&b_{1}&b_{2}&\ldots&b_{m-1}&b_{m}&0&0&\ldots\\ &=&0&.&b_{1}&b_{2}&\ldots&b_{m-1}&b_{m}-1&9&9&\ldots\\ y&=&0&.&c_{1}&c_{2}&\ldots&c_{m-1}&c_{m}&c_{m+1}&c_{m+2}&\ldots\end{array}

We have used the proof of Proposition 2.14, to represent zz also as an eventually repeating decimal. The digits are aligned to make it easier to compare xx, yy and zz.

Now:

  • x>zx>z, because xx is non-terminating and so does not have a tail of 0s; and

  • zyz\geq y. Because bm>cmb_{m}>c_{m}, the greatest cmc_{m} could be is bm1b_{m}-1. Therefore z>yz>y unless cm=bm1c_{m}=b_{m}-1 and cm+1=cm+2==9c_{m+1}=c_{m+2}=\cdots=9, in which case z=yz=y.

Thus yz<xy\leq z<x and so xyx\neq y.

We now summarise this section on rational numbers in a single result.

Proposition 2.16.

A nonzero real number is rational if and only if it has an eventually repeating decimal representation.

Proof.

Let xx be a nonzero real number.

If xx is rational then, by Proposition 2.9, its decimal representation either terminates or repeats indefinitely to the right. If it terminates then, by Proposition 2.14, it has an equivalent representation with a tail of 99s.

If xx has an eventually repeating decimal representation then, by Proposition 2.13, it is rational.