Thoughts on 1/7 and other rational numbers (Part 9)

Let’s now consider the decimal representation of \displaystyle \frac{8}{17}.

TI817

There’s no obvious repeating pattern. But we know that, since 17 has neither 2 nor 5 as a factor, that there has to be a repeating decimal pattern.

So… what is it?

When I ask this question to my students, I can see their stomachs churning a slow dance of death. They figure that the calculator didn’t give the answer, and so they have to settle for long division by hand.

That’s partially correct.

However, using the ideas presented below, we can perform the long division extracting multiple digits at once. Through clever use of the calculator, we can quickly obtain the full decimal representation even though the calculator can only give ten digits at a time.

green line

Let’s now return to where this series began… the decimal representation of \displaystyle \frac{1}{7} using long division. As shown below, the repeating block has length 6, which can be found in a few minutes with enough patience. By the end of this post, we’ll consider a modification of ordinary long division that facilitates the computation of really long repeating blocks.

longdivision17

Because we arrived at a repeated remainder, we know that we have found the repeating block. So we can conclude that \displaystyle \frac{1}{7} = 0.\overline{142857}.

Students are taught long division in elementary school and are so familiar with the procedure that not much thought is given to the logic behind the procedure. The underlying theorem behind long division is typically called the division algorithm. From Wikipedia:

Given two integers a and b, with b \ne 0, there exist unique integers q and r such that a = bq+r and $0 \le r < |b|$,  where |b| denotes the absolute value of b.

The number q is typically called the quotient, while the number r is called the remainder.

Repeated application of this theorem is the basis for long division. For the example above:

Step 1.

10 = 1 \times 7 + 3. Dividing by 10, 1 = 0.1 \times 7 + 0.3

Step 2.

30 = 4 \times 7 + 2. Dividing by 100, 0.3 = 0.04 \times 7 + 0.02

Returning to the end of Step 1, we see that

1 = 0.1 \times 7 + 0.3 = 0.1 \times 7 + 0.04 \times 7 + 0.02 = 0.14 \times 7 + 0.02

Step 3.

20 = 2 \times 7 + 6. Dividing by 1000, 0.02 = 0.002 \times 7 + 0.006

Returning to the end of Step 2, we see that

1 = 0.14 \times 7 + 0.02 = 0.14 \times 7 + 0.0002 \times 7 + 0.006 = 0.142 \times 7 + 0.006

And so on.

green line

By adding an extra zero and using the division algorithm, the digits in the decimal representation are found one at a time. That said, it is possible (with a calculator) to find multiple digits in a single step by adding extra zeroes. For example:

Alternate Step 1.

1000 = 142 \times 7 + 6. Dividing by 1000, 1 = 0.142 \times 7 + 0.006

Alternate Step 2.

6000 = 587 \times 7 + 1. Dividing by 100000, 0.006 = 0.000587 \times 7 + 0.000001

Returning to the end of Alternate Step 1, we see that

1 = 0.142 \times 7 + 0.006= 0.142 \times 7 + 0.000587\times 7 + 0.000001 = 0.142857 \times 7 + 0.000001

So, with these two alternate steps, we arrive at a remainder of 1 and have found the length of the repeating block.

The big catch is that, if a = 1000 or a = 6000 and b = 7, the appropriate values of q and r have to be found. This can be facilitated with a calculator. The integer part of 1000/7 and 6000/7 are the two quotients needed above, and subtraction is used to find the remainders (which must be less than 7, of course).

TI17

At first blush, it seems silly to use a calculator to find these values of q and r when a calculator could have been used to just find the decimal representation of 1/7 in the first place. However, the advantage of this method becomes clear when we consider fractions who repeating blocks are longer than 10 digits.

green lineLet’s now return to the question posed at the top of this post: finding the decimal representation of \displaystyle \frac{8}{17}. As noted in Part 6 of this series, the length of the repeating block must be a factor of \phi(17), where \phi is the Euler toitent function, or the number of integers less than 17 that are relatively prime with 17. Since 17 is prime, we clearly see that \phi(17) = 16. So we can conclude that the length of the repeating block is a factor of 16, or either 1, 2, 4, 8, or 16.

Here’s the result of the calculator again:

TI817

We clearly see from the calculator that the repeating block doesn’t have a length less than or equal to 8. By process of elimination, the repeating block must have a length of 16 digits.

Now we perform the division algorithm to obtain these digits, as before. This can be done in two steps by multiplying by 10^8 = 100,000,000.

TI817b

So, by the same logic used above, we can conclude that

\displaystyle \frac{8}{17} = 0.\overline{4705882352941176}

In other words, through clever use of the calculator, the full decimal representation can be quickly found even if the calculator itself returns only ten digits at a time… and had rounded the final 2941176 of the repeating block up to 3.

Thoughts on 1/7 and other rational numbers (Part 8)

In Part 6 of this series, I mentioned the following fact concerning the decimal representation of \displaystyle \frac{a}{b}: if neither 2 nor 5 is a factor of b, then the repeating block in the decimal representation of \displaystyle \frac{a}{b} has a length k that must be a factor of \phi(b). This function is the Euler toitent function or the number of integers less than b that are relatively prime with b.

In this post, I’d like to provide a justification for this theorem.

As discussed earlier, k is the least integer so that b is a factor of 10^k - 1. In the language of congruence, k is the least integer so that

10^k \equiv 1 (\mod b)

In other words, let G_b be the multiplicative group of numbers less than b that are relatively prime with b. By assumption 10 \in G_b. Then k is the order of 10 in G_b, and there’s a theorem that states that the order of an element of a group must be a factor of the order of the group, or the number of elements in the group. In our case, the order of G_b is the number of integers less than b that are relatively prime with b, or \phi(b).

In other words, using these ideas from group theory, we can prove that k \mid \phi(b).

green line

Naturally, we don’t expect middle school students seeing long division for the first time to appreciate this property of decimal representations. Still, my main purpose in writing this post was to give a concrete example of how ideas from higher-level mathematics — like group theory — actually can shed insight into ideas that are first seen in school — even middle school. In other words, there’s a reason why UNT (and other universities) requires that college students who want to earn mathematics teaching certification with their degrees must have a major in mathematics.

Thoughts on 1/7 and other rational numbers (Part 7)

In a previous post concerning roundoff error, I mentioned that the number 1/10 equals

\displaystyle \frac{1}{2^4} + \frac{1}{2^5} +\frac{1}{2^8} + \frac{1}{2^9} + \frac{1}{2^{12}} + \frac{1}{2^{13}} + \dots

In other words, the binary expansion of 1/10 is

0.0001100110011001100110011001100....

That’s the expansion of the fraction in base 2, as opposed to base 10.

In the previous post, I verified that the above infinite series actually converges to 1/10:

S = \displaystyle \left(\frac{1}{2^4} + \frac{1}{2^5}\right) +\left(\frac{1}{2^8} + \frac{1}{2^9}\right) + \left(\frac{1}{2^{12}} + \frac{1}{2^{13}}\right) + \dots

S = \displaystyle \frac{3}{2^5} + \frac{3}{2^9} + \frac{3}{2^{13}} + \dots

S = \displaystyle \frac{\displaystyle \frac{3}{2^5}}{\quad \displaystyle 1 - \frac{1}{2^4} \quad}

S = \displaystyle \frac{\displaystyle \frac{3}{32}}{\quad \displaystyle \frac{15}{16} \quad}

S = \displaystyle \frac{3}{32} \times \frac{16}{15}

S = \displaystyle \frac{1}{10}

Still, a curious student may wonder how one earth one could directly convert 1/10 into binary without knowing the above series ahead of time.

This can be addressed by using the principles that we’ve gleaned in this study of decimal representations, except translating this work into the language of base 2. In the following, I will use the subscripts \hbox{ten} and \hbox{two} so that I’m clear about when I’m using decimal and binary, respectively.

To begin, we note that 10_{\hbox{\scriptsize ten}} = 1010_{\hbox{\scriptsize two}} = 10_{\hbox{\scriptsize two}} \times 101_{\hbox{\scriptsize two}}. (In other words, ten is equal to two times five.) So, following Case 3 of the previous post, we will attempt to write the denominator in the form

10_{\hbox{\scriptsize two}}^d \left(10_{\hbox{\scriptsize two}}^k - 1 \right), or 2_{\hbox{\scriptsize ten}}^d \left(2_{\hbox{\scriptsize ten}}^k - 1 \right)

  • If k = 1_{\hbox{\scriptsize ten}}, then 2_{\hbox{\scriptsize ten}}^1 - 1 = 1_{\hbox{\scriptsize ten}}, but 1_{\hbox{\scriptsize ten}} \div 5_{\hbox{\scriptsize ten}}  is not an integer.
  • If k = 2_{\hbox{\scriptsize ten}}, then 2_{\hbox{\scriptsize ten}}^2 - 1 = 3_{\hbox{\scriptsize ten}}, but 3_{\hbox{\scriptsize ten}} \div 5_{\hbox{\scriptsize ten}}  is not an integer.
  • If k = 3_{\hbox{\scriptsize ten}}, then 2_{\hbox{\scriptsize ten}}^3 - 1 = 7_{\hbox{\scriptsize ten}}, but 7_{\hbox{\scriptsize ten}} \div 5_{\hbox{\scriptsize ten}}  is not an integer.
  • If k = 4_{\hbox{\scriptsize ten}}, then 2_{\hbox{\scriptsize ten}}^4 - 1 = 15_{\hbox{\scriptsize ten}}. This time, 15_{\hbox{\scriptsize ten}} \div 5_{\hbox{\scriptsize ten}} = 3_{\hbox{\scriptsize ten}}. Written in binary,

101_{\hbox{\scriptsize two}} \times 11_{\hbox{\scriptsize two}} = 1111_{\hbox{\scriptsize two}}

We now return to the binary representation of 1/10_{\hbox{\scriptsize ten}} = 1/1010_{\hbox{\scriptsize two}}.

\displaystyle \frac{1}{1010_{\hbox{\scriptsize two}}} = \displaystyle \frac{1}{1010_{\hbox{\scriptsize two}}} \times \frac{11_{\hbox{\scriptsize two}}}{11_{\hbox{\scriptsize two}}}

\displaystyle \frac{1}{1010_{\hbox{\scriptsize two}}} = \frac{11_{\hbox{\scriptsize two}}}{11110_{\hbox{\scriptsize two}}}

Therefore, the binary representation has a delay of one digit and a repeating block of four digits:

\displaystyle \frac{1}{1010_{\hbox{\scriptsize two}}} = 0.0\overline{0011}

Naturally, this matches the binary representation given earlier.

Thoughts on 1/7 and other rational numbers (Part 6)

In Part 5 of this series, I showed that fractions of the form \displaystyle \frac{M}{10^d}, \displaystyle \frac{M}{10^k - 1}, and \displaystyle \frac{M}{10^d (10^k-1)} can be converted into their decimal representations without using long division and without using a calculator.

The amazing thing is that every rational number \displaystyle \frac{a}{b} can be written in one of these three forms. Therefore, after this conversion is made, then the decimal expansion can be found without a calculator.

green line

Case 1. If the denominator b has a prime factorization of the form 2^m 5^n, then \displaystyle \frac{a}{b} can be rewritten in the form \displaystyle \frac{M}{10^d}, where d = \max(m,n).

For example,

\displaystyle \frac{3}{160} = \displaystyle \frac{3}{2^5 \times 5}

\displaystyle \frac{3}{160} = \displaystyle \frac{3}{2^5 \times 5} \times \frac{5^4}{5^4}

\displaystyle \frac{3}{160} = \displaystyle \frac{3 \times 5^4}{2^5 \times 5^5}

\displaystyle \frac{3}{160} = \displaystyle \frac{1875}{10^5}

\displaystyle \frac{3}{160} = 0.01875

The step of multiplying both sides by \displaystyle \frac{5^4}{5^4} is perhaps unusual, since we’re so accustomed to converting fractions into lowest terms and not making the numerators and denominators larger. This particular form of 1 was chosen in order to get a power of 10 in the denominator, thus facilitating the construction of the decimal expansion.

green line

Case 2. If the denominator b is neither a multiple of 2 nor 5, then  \displaystyle \frac{a}{b} can be rewritten in the form \displaystyle \frac{M}{10^k - 1}.

For example,

\displaystyle \frac{3}{11} = \displaystyle \frac{3}{11} \times \frac{9}{9}

\displaystyle \frac{3}{11} = \displaystyle \frac{27}{99}

\displaystyle \frac{3}{11} = 0.\overline{27}

This example wasn’t too difficult since we knew that 9 \times 11 = 99. However, finding the smallest value of k that works can be a difficult task requiring laborious trial and error.

However, we do have a couple of theorems that can assist in finding k. First, since k is the length of the repeating block, we are guaranteed that k must be less than the denominator b since, using ordinary long division, the length of the repeating block is determined by how many steps are required until we get a remainder that was seen before.

However, we can do even better than that. Using ideas from number theory, it can be proven that k must be a factor of \phi(b), which is the Euler toitent function or the number of integers less than b that are relatively prime with b. In the example above, the denominator was 11, and clearly, if 1 \le n < 11, then \gcd(n,11) = 1. Since there are 10 such numbers, we know that k must be a factor of 10. In other words, k must be either 1, 2, 5, or 10, thus considerably reducing the amount of guessing and checking that has to be done. (Of course, for the example above, k=2 was the least value of k that worked.)

In general, if n = p_1^{a_1} p_2^{a_2} \dots p_r^{a_r} is the prime factorization of n, then

\phi(n) = n \left( \displaystyle 1 - \frac{1}{p_1} \right) \left( \displaystyle 1 - \frac{1}{p_2} \right) \dots \left( \displaystyle 1 - \frac{1}{p_r} \right)

For the example above, since 11 was prime, we have \phi(11) = 11 \left( \displaystyle 1 - \frac{1}{11} \right) = 10.

green line

Case 3. Suppose the prime factorization of the denominator b both (1) contains 2 and/or 5 and also (2) another prime other than 2 and 5. This is a mixture of Cases 1 and 2, and the fraction \displaystyle \frac{a}{b} can be rewritten in the form \displaystyle \frac{M}{10^d (10^k-1)}.

For example, consider

\displaystyle \frac{11}{74} = \displaystyle \frac{11}{2 \times 37}

Following the rule for Case 1, we should multiply by \displaystyle \frac{5}{5} to get a 10 in the denominator:

\displaystyle \frac{11}{74} = \displaystyle \frac{11}{2 \times 37} \times \frac{5}{5} = \frac{55}{10 \times 37}

Next, we need to multiply 37 by something to get a number of the form 10^k - 1. Since 37 is prime, every number less than 37 is relatively prime with 37, so \phi(37) = 36. Therefore, k must be a factor of 36. So, k must be one of 1, 2, 3, 4, 6, 9, 12, 18, and 36.

(Parenthetically, while we’ve still got some work to do, it’s still pretty impressive that — without doing any real work — we can reduce the choices of k to these nine numbers. In that sense, the use of \phi(n) parallels how the Rational Root Test is used to determine possible roots of polynomials with integer coefficients.)

So let’s try to find the least value of k that works.

  • If k = 1, then 10^1 - 1 = 9, but 9 \div 37 is not an integer.
  • If k = 2, then 10^2 - 1 = 99, but 99 \div 37 is not an integer.
  • If k = 3, then 10^3 - 1 = 999, and it turns out that 999 \div 37 = 27, an integer.

Therefore,

\displaystyle \frac{11}{74} = \frac{55}{10 \times 37} \times \frac{27}{27}

\displaystyle \frac{11}{74} = \frac{1485}{10 \times 999}

\displaystyle \frac{11}{74} = \frac{999 + 486}{10 \times 999}

\displaystyle \frac{11}{74} = \frac{999}{10 \times 999}+ \frac{486}{10 \times 999}

\displaystyle \frac{11}{74} = \frac{1}{10}+ \frac{486}{10 \times 999}

\displaystyle \frac{11}{74} = 0.1 + 0.0\overline{486}

\displaystyle \frac{11}{74} = 0.1\overline{486}

Thoughts on 1/7 and other rational numbers (Part 5)

Students are quite accustomed to obtaining the decimal expansion of a fraction by using a calculator. Here’s an (uncommonly, I think) taught technique for converting certain fractions into a decimal expansion without using long division and without using a calculator. I’ve taught this technique to college students who want to be future high school teachers for several years, and it never fails to surprise.

First off, it’s easy to divide any number by a power of 10, or 10^k. For example,

\displaystyle \frac{4312}{1000} = 4.312 and \displaystyle \frac{71}{10000} = 0.00071

What’s less commonly known is that it’s also easy to divide by 10^k - 1, or 99\dots 9, a numeral with k consecutive 9s. (This number can be used to prove the divisibility rules for 3 and 9 and is also the subject of one of my best math jokes.) The rule can be illustrated with a calculator:

TI999

In other words, if M < 10^k - 1, then the decimal expansion of \displaystyle \frac{M}{10^k-1} is a repeating block of k digits containing the numeral M, possibly adding enough zeroes to fill all k digits.

To prove that this actually works, we notice that

\displaystyle \frac{M}{10^k - 1} = M \times \frac{ \displaystyle \frac{1}{10^k}}{\quad \displaystyle 1 - \frac{1}{10^k} \quad}

 \displaystyle \frac{M}{10^k - 1} = M \times \left(\displaystyle \frac{1}{10^k} + \frac{1}{10^{2k}} + \frac{1}{10^{3k}} + \dots \right)

\displaystyle \frac{M}{10^k-1} = M \times 0.\overline{00\dots01}

The first line is obtained by multiplying the numerator and denominator by \displaystyle \frac{1}{10^k}. The second line is obtained by using the formula for an infinite geometric series in reverse, so that the first term is \displaystyle \frac{1}{10^k} and the common ratio is also \displaystyle \frac{1}{10^k}. The third line is obtained by converting the series — including only powers of 10 — into a decimal expansion.

If M > 10^k - 1, then the division algorithm must be used to get a numerator that is less than 10^k-1. Fortunately, dividing big numbers by 10^k-1 is quite easy and can be done without a calculator. For example, let’s find the decimal expansion of \displaystyle \frac{123456}{9999} without a calculator. First,

123456 = 12(10000) + 3456

123456 = 12(9999 + 1) + 3456

123456 = 12(9999) + 12(1) + 3456

123456 = 12(9999) + 3468

Therefore,

\displaystyle \frac{123456}{9999} = \displaystyle \frac{12(9999) + 3468}{9999}

\displaystyle \frac{123456}{9999} = \displaystyle \frac{12(9999)}{9999} + \frac{3468}{9999}

\displaystyle \frac{123456}{9999} = \displaystyle 12 + \frac{3468}{9999}

\displaystyle \frac{123456}{9999} = \displaystyle 12.\overline{3468}

This can be confirmed with a calculator. Notice that the repeating block doesn’t quite match the digits of the numerator because of the intermediate step of applying the division algorithm.

TI9999

green line

In the same vein, it’s also straightforward to find the decimal expansion of fractions of the form \displaystyle \frac{M}{10^d (10^k-1)}, so that the denominator has the form 99\dots9900\dots00. This is especially easy if M < 10^k -1. For example,

\displaystyle \frac{123}{99900} = \frac{1}{100} \times \frac{123}{999} = \frac{1}{100} \times 0.\overline{123} = 0.00\overline{123}

On the other hand, if M > 10^k-1, then the division algorithm must be applied as before. For example, let’s find the decimal expansion of \displaystyle \frac{51237}{99000}. To begin, we need to divide the numerator by 99, as before. Notice that, for this example, an extra iteration of the division algorithm is needed to get a remainder less than 99.

51237 = 512(100) + 37

51237 = 512(99 + 1) + 37

51237 = 512(99) + 512 + 37

51237 = 512(99) + 549

51237= 512(99) + 5(100) + 49

51237 = 512(99) + 5(99 + 1) + 49

51237 = 512(99) + 5(99) + 5 + 49

51237 = 517(99) + 54

Therefore,

\displaystyle \frac{51237}{99000} = \displaystyle \frac{517(99) + 54}{99000}

\displaystyle \frac{51237}{99000} = \displaystyle \frac{517(99)}{99000} + \frac{54}{99000}

\displaystyle \frac{51237}{99000} = \displaystyle \frac{517}{1000} + \frac{54}{99000}

\displaystyle \frac{51237}{99000} = 0.517 + 0.000\overline{54}

\displaystyle \frac{51237}{99000} = 0.517\overline{54}

In particular, notice that the three 0s in the denominator correspond to a delay of length 3 (the digits 517), while the 99 = 10^2 - 1 in the denominator corresponds to the repeating block of length 2.

These can be confirmed for students who may be reluctant to believe that decimal expansions can be found without a calculator.

TI99000

Thoughts on 1/7 and other rational numbers (Part 4)

In Part 3 of this series, I considered the conversion of a repeating decimal expansion into a fraction. This was accomplished by an indirect technique which was pulled out of the patented Bag of Tricks. For example, if x = 0.\overline{432} = 0.432432432\dots, we start by computing 1000x and then subtracting.

1000x = 432.432432\dots

x = 0.432432\dots

999x = 432

x = \displaystyle \frac{432}{999} = \displaystyle \frac{16}{37}

As mentioned in Part 3, most students are a little bit skeptical that this actually works, and often need to type the final fraction into a calculator to be reassured that the method actually works. Most students are also a little frustrated with this technique because it does come from the Bag of Tricks. After all, the first two steps (setting the decimal equal to x and then multiplying x by 1000) are hardly the most intuitive things to do first… unless you’re clairvoyant and know what’s going to happen next.

In this post, I’d like to discuss a more direct way of converting a repeating decimal into a fraction. In my experience, this approach presents a different conceptual barrier to students. This is a more direct approach, and so students are more immediately willing to accept its validity. However, the technique uses the formula for an infinite geometric series, which (unfortunately) most senior math majors cannot instantly recall. They’ve surely seen the formula before, but they’ve probably forgotten it because a few years have passed since they’ve had to extensively use the formula.

Anyway, here’s the method applied to 0.\overline{432}. To begin, we recall the meaning of a decimal representation in the first place:

0.432432432 \dots = \displaystyle \frac{4}{10} + \frac{3}{100} + \frac{2}{1000} + \displaystyle \frac{4}{10^4} + \frac{3}{10^5} + \frac{2}{10^6} + \displaystyle \frac{4}{10^7} + \frac{3}{10^8} + \frac{2}{10^9} + \dots

Combining fractions three at a time (matching the length of the repeating block), we get

0.432432432 \dots = \displaystyle \frac{432}{10^3} + \displaystyle \frac{432}{10^6} + \frac{432}{10^9} + \dots

This is an infinite geometric series whose first term is \displaystyle \frac{432}{10^3}, and the common ratio that’s multiplied to go from one term to the next is \displaystyle \frac{1}{10^3}. Using the formula for an infinite geometric series and simplifying, we conclude

0.432432432 \dots = \displaystyle \frac{ \quad \displaystyle \frac{432}{1000} \quad }{\quad 1 - \displaystyle \frac{1}{1000} \quad}

0.432432432 \dots = \displaystyle \frac{ \displaystyle \quad \frac{432}{1000} \quad}{ \displaystyle \quad \frac{999}{1000} \quad}

0.432432432 \dots = \displaystyle \frac{ 432}{ 999}

0.432432432 \dots = \displaystyle \frac{ 16}{ 37}

green line

For what it’s worth, the decimal representation could have been simplified by using three separate geometric series. Some students find this to be more intuitive, combining the unlike fractions at the final step as opposed to the initial step.

0.432432432 \dots = \left( \displaystyle \frac{4}{10} + \frac{4}{10^4} + \displaystyle \frac{4}{10^7} + \dots \right)

\quad \quad \quad \quad + \left( \displaystyle \frac{3}{100} + \frac{3}{10^5} + \displaystyle \frac{3}{10^8} + \dots \right)

+ \left( \displaystyle \frac{2}{1000} + \frac{2}{10^6} + \displaystyle \frac{2}{10^9} + \dots \right)

0.432432432 \dots = \displaystyle \frac{ \quad \displaystyle \frac{4}{10} \quad }{\quad 1 - \displaystyle \frac{1}{1000} \quad} + \frac{ \quad \displaystyle \frac{3}{100} \quad }{\quad 1 - \displaystyle \frac{1}{1000} \quad} + \frac{ \quad \displaystyle \frac{2}{1000} \quad }{\quad 1 - \displaystyle \frac{1}{1000} \quad}

0.432432432 \dots = \displaystyle \frac{ \quad \displaystyle \frac{4}{10} \quad }{\quad \displaystyle \frac{999}{1000} \quad} + \frac{ \quad \displaystyle \frac{3}{100} \quad }{\quad \displaystyle \frac{999}{1000} \quad} + \frac{ \quad \displaystyle \frac{2}{1000} \quad }{\quad \displaystyle \frac{999}{1000} \quad}

0.432432432 \dots = \displaystyle \frac{ 400}{ 999} + \frac{30}{999} + \frac{2}{999}

0.432432432 \dots = \displaystyle \frac{ 432}{ 999}

0.432432432 \dots = \displaystyle \frac{ 16}{ 37}

green lineFinally, this direct technique also works for repeating decimals with a delay, like 0.41\overline{6}.

0.41666\dots = \displaystyle \frac{4}{10} + \frac{1}{100} + \left( \frac{6}{1000} + \frac{6}{10^4} + \frac{6}{10^5} + \dots \right)

0.41666\dots = \displaystyle \frac{4}{10} + \frac{1}{100} + \displaystyle \frac{ \quad \displaystyle \frac{6}{1000} \quad }{\quad 1 - \displaystyle \frac{1}{10} \quad}

0.41666\dots = \displaystyle \frac{4}{10} + \frac{1}{100} +\displaystyle \frac{ \quad \displaystyle \frac{6}{1000} \quad }{\quad \displaystyle \frac{9}{10} \quad}

0.41666\dots = \displaystyle \frac{4}{10} + \frac{1}{100} +\frac{6}{900}

0.41666\dots = \displaystyle \frac{375}{900}

0.41666\dots = \displaystyle \frac{5}{12}

Thoughts on 1/7 and other rational numbers (Part 3)

In Part 2 of this series, I discussed the process of converting a fraction into its decimal representation. In this post, I consider the reverse: starting with a decimal representation, and ending with a fraction.

Let me say at the onset that the process I’m about to describe appears to be a dying art. When I show this to my math majors who want to be high school teachers, roughly half have either not seen it before or else have no memory of seeing it before. (As always, I hold my students blameless for the things that they were simply not taught at a younger age, and part of my job is repairing these odd holes in their mathematical backgrounds so that they’ll have their best chance at becoming excellent high school math teachers.) I’m guessing that this algorithm is a dying art because of the ease and convenience of modern calculators.

So let me describe how I describe this procedure to my students. To begin, suppose that we’re given a repeating decimal like 0.\overline{432} = 0.432432432\dots. How do we change this into a decimal? Let’s call this number x.

I’m now about to do something that, if you don’t know what’s coming next, appears to make no sense. I’m going to multiply x by 1000. Students often give skeptical, quizzical, and/or frustrated looks about this non-intuitive next step… they’re thinking, “How would I ever have thought to do that on my own?” To allay these concerns, I explain that this step comes from the patented Bag of Tricks. Socrates gave the Bag of Tricks to Plato, Plato gave it to Aristotle, it passed down the generations, my teacher taught the Bag of Tricks to me, and I teach it to my students. Multiplying by 1000 on the next step is absolutely not obvious, unless you happen to know via clairvoyance what’s going to come next.

Anyway, let’s write down x and also 1000x.

1000x = 432.432432\dots

x = 0.432432\dots

Notice that the decimal parts of both x and 1000x are the same. Subtracting, the decimal parts cancel, leaving

999x = 432

or

x = \displaystyle \frac{432}{999} = \displaystyle \frac{16}{37}

In my experience, most students — even senior math majors who have taken a few theorem-proof classes and hence are no dummies — are a little stunned when they see this procedure for the first time. To make this more real and believable to them, I then ask them to pop out their calculators to confirm that this actually worked. (Indeed, many students need this confirmation to be psychologically sure that it really did work.)

TI1637

Then I ask my students, why did we multiply by 1000? They’ll usually give the correct answer: so that the decimal parts will cancel. My follow-up question is, what should we do if the decimal is 0.\overline{24}? They’ll usually respond that we should multiply by 100 or, in general, by 10^n, where n is the length of the repeating block.

This strategy, of course, works for $0.\overline{142857}$, eventually yielding

0.\overline{142587} = \displaystyle \frac{142857}{999999} = \displaystyle \frac{1}{7}

after cancellation.

green line

The same procedure works for decimal expansions with a delay, like x = 0.72\overline{3}. This time, I’ll ask them how we should go about changing this into a fraction. I usually get at least one of three responses. I love getting multiple responses, as this gives the students a chance to came the “different” answers, compare the different strategies, and

Answer #1. Multiply x by 1000 since the repeating pattern starts at the 3rd decimal place.

1000x = 723.333\dots

x = 0.7233\dots

\therefore 999x = 722.61

x =\displaystyle\frac{722.61}{999} = \displaystyle\frac{72261}{99900} = \displaystyle \frac{217}{300}

Answer #2. Multiply x by 10 since the repeating block has length 1.

10x = 7.23333\dots

x = 0.7233\dots

\therefore 9x = 6.51

x = \displaystyle \frac{6.51}{9} = \displaystyle\frac{651}{900} = \displaystyle\frac{217}{300}

Answer #3. First multiply x by 100 to get rid of the delay. Then multiply 100 x by an extra 10 since the repeating block has length 1.

1000x = 723.333\dots

100x = 72.33\dots

\therefore 900x = 651

x = \displaystyle\frac{651}{900} = \displaystyle\frac{217}{300}

green line

The above discussion concerned repeating decimals. For completeness, converting terminating decimals into a fraction is easy. For example,

0.124 = \displaystyle \frac{1}{10} + \frac{2}{100} + \frac{4}{1000} = \displaystyle \frac{124}{1000} = \displaystyle \frac{31}{250}

green line

One more thought. The concept behind Part 2 of this series shows that a rational number of the form k/n, where both k and n are integers, must have either a terminating decimal expansion or else a repeating decimal expansion (possibly with a delay). In this post, we went the other direction. Therefore, we have the basis for the following theorem.

Theorem. A number x is rational if and only if it has either a terminating decimal expansion or else a repeating decimal expansion.

The contrapositive of this theorem is perhaps intuitively obvious.

Theorem. A number x is irrational if and only if it has a non-terminating and non-repeating decimal expansion.

In my experience, most students absolutely believe both of these theorems. For example, most students believe that \sqrt{2} has a decimal expansion that neither terminates nor repeats. That said, most math majors are surprised to discover that it does take quite a bit of work — like a formal write-up of Parts 2 and 3 of this series — to actually prove this statement from middle-school mathematics.

Thoughts on 1/7 and other rational numbers (Part 2)

Let’s take another look at the decimal expansion of 1/7:

TI17

This result from a calculator should convince most students that \displaystyle \frac{1}{7} = 0.\overline{142857}. After all, there’s a second 142 after the first 7, and the ending 9 is consistent with rounding up the 857.

So the evidence that \displaystyle \frac{1}{7} = 0.\overline{142857} is persuasive.

But does this prove beyond a shadow of a doubt that this decimal representation is correct?

Sadly, no. Taken by itself, the result of the calculator is also consistent with, to give just one example, \displaystyle \frac{1}{7} = 0.\overline{142857142910235}, which also would truncate after 10 decimal places to the result shown above.

In short, the calculator gives evidence that the decimal expansion is correct, but does not prove that it’s correct.

Which leads to the obvious question: how do we prove it?

green_speech_bubble

One method, which used to be taught in elementary school (I honestly don’t know if this is taught anymore), is by traditional long division:longdivision17

After six steps, we finally get to a remainder that was previously seen (in this case, on the first step). Therefore, we tell students, the subsequent digits have to repeat.

By the way, this is the essence of the proof for why every rational number has either a repeating decimal representation (possibly with a delay, like 0.1\overline{6}) or else a terminating decimal representation. Though a more formal proof would be preferred by professional mathematicians, the idea is simple: in the algorithm for long division for k/n, there are only n possible remainders: 0, 1, \dots, n-1. So we eventually have to arrive at a remainder that was seen before. If that remainder is 0, then the decimal representation terminates. Otherwise, the decimal representation repeats itself.

In my experience, every math major that I’ve ever met intuitively knows that the above theorem is true. After all, they’ve worked intensively with decimals since 5th grade and have seen decimals in the lower elementary grades. However, very few can articulate why it’s true.

Thoughts on 1/7 and other rational numbers (Part 1)

I’m guessing that not many people ever blocked time out of their busy schedules to purposefully memorize the decimal representation of a fraction. Nevertheless, in my experience, most math majors and math teachers can immediately convert, from memory, most (but not all — more on this later) fractions of the form \displaystyle \frac{k}{n} into its decimal representation as long as the denominator n is less than or equal to 10. They can also go the other direction, mentally recognizing a decimal expansion as a fraction of this form.

This memorization occurs not because of purposeful study but because these fractions arise so commonly from 6th grade through college that students can’t help but memorize them. They just come up so often that good students almost can’t help but memorize them.

Here are the decimal representations of \displaystyle \frac{k}{n}, where the fraction is in lowest terms and 1 \le k < n \le 10.

\displaystyle \frac{1}{2} = 0.5

\displaystyle \frac{1}{3} = 0.\overline{3} \quad \displaystyle \frac{2}{3} = 0.\overline{6}

\displaystyle \frac{1}{4} = 0.25 \quad \displaystyle \frac{3}{4} = 0.75

\displaystyle \frac{1}{5} = 0.2 \quad \displaystyle \frac{2}{5} = 0.4 \quad \displaystyle \frac{3}{5} = 0.6 \quad \displaystyle \frac{4}{5} = 0.8

\displaystyle \frac{1}{6} = 0.1\overline{6} \quad \displaystyle \frac{5}{6} = 0.8\overline{3}

\displaystyle \frac{1}{7} = 0.\overline{142857} \quad \displaystyle \frac{2}{7} = 0.\overline{285714} \quad \displaystyle \frac{3}{7} = 0.\overline{428571}

\displaystyle \frac{4}{7} = 0.\overline{571428} \quad \displaystyle \frac{5}{7} = 0.\overline{714285} \quad \displaystyle \frac{6}{7} = 0.\overline{857142}

\displaystyle \frac{1}{8} = 0.125 \quad \displaystyle \frac{3}{8} = 0.375 \quad \displaystyle \frac{5}{8} = 0.625 \quad \displaystyle \frac{7}{8} = 0.875

\displaystyle \frac{1}{9} = 0.\overline{1} \quad \displaystyle \frac{2}{9} = 0.\overline{2} \quad \displaystyle \frac{4}{9} = 0.\overline{4} \quad \displaystyle \frac{5}{9} = 0.\overline{5} \quad \displaystyle \frac{7}{9} = 0.\overline{7} \quad \displaystyle \frac{8}{9} = 0.\overline{8}

\displaystyle \frac{1}{10} = 0.1 \quad \displaystyle \frac{3}{10} = 0.3 \quad \displaystyle \frac{7}{10} = 0.7 \quad \displaystyle \frac{9}{10} = 0.9

Like I said, most (but not all) of these have been memorized by math majors and math teachers. The exceptions, not surprisingly, are the fractions with a denominator of 7.

When I was a child, I read somewhere the following rule for memorizing the decimal expansion of \displaystyle \frac{k}{7}. I must have been lucky, because I have yet to meet a student that also saw this rule. The following is not a formal proof of the rule, but it does work for the purposes of memorization.

Step 1. Let’s begin with \displaystyle \frac{1}{7}. The decimal expansion can be remembered by repeating “3, 2, 6” along with repeating “up, down.” Repeating both patterns, we get

up 3

down 2

up 6

down 3

up 2

down 6

So,

Start at 1:

up 3: \quad 1 + 3 = 4

down 2: \quad 4 - 2 = 2

up 6: \quad 2 + 6 = 8

down 3: \quad 8 - 3 = 5

up 2: \quad 5 + 2 = 7

down 6: \quad 7 - 6 = 1

The pattern returns back to 1, and the digits repeat. That’s the decimal expansion:

\displaystyle \frac{1}{7} = 0.142857142857\dots

Steps 2-6. For \displaystyle \frac{2}{7}, \dots, \frac{6}{7}, the digits repeat in the same pattern as \displaystyle \frac{1}{7}, just starting at a different place. For example:

For \displaystyle \frac{2}{7}, the second smallest of the digits 1, 4, 2, 8, 5, \hbox{~and~} 7 is 2. So we’ll drop the first 1 and 4 and start on 2:

\displaystyle \frac{1}{7} = 0.2857142857\dots = 0.\overline{285714}

For \displaystyle \frac{4}{7}, the fourth smallest of the digits 1, 4, 2, 8, 5, \hbox{~and~} 7 is 5. So we’ll drop the first 1, 4, 2, and 8 and start on 5:

\displaystyle \frac{4}{7} = 0.57142857\dots = 0.\overline{571428}

green line

P.S. Plenty of math majors (though perhaps not a majority) have also memorized the decimal expansions of \displaystyle\frac{k}{11} and \displaystyle \frac{k}{12}. For 11, the rule is multiply k by 9 to form the two-digit repeating block. In other words:

4 \times 9 = 36, and so \displaystyle \frac{4}{11} = 0.\overline{36}

8 \times 9 = 72, and so \displaystyle \frac{8}{11} = 0.\overline{72}

1 \times 9 = 9, and so \displaystyle \frac{1}{11} = 0.\overline{09}

For 12, the only lowest-term fractions are \displaystyle \frac{1}{12}, \displaystyle \frac{5}{12}, \displaystyle \frac{7}{12}, and \displaystyle \frac{11}{12}. To begin, the first should be memorized:

\displaystyle \frac{1}{12} = 0.08333\dots = 0.08\overline{3}

The others are obtained by addition or subtraction:

\displaystyle \frac{7}{12} = \displaystyle \frac{1}{2} + \frac{1}{12} = 0.5 + 0.08333\dots = 0.58333\dots = 0.58\overline{3}

\displaystyle \frac{5}{12} = \displaystyle \frac{1}{2} - \frac{1}{12} = 0.5 - 0.08333\dots = 0.41666\dots = 0.41\overline{3}

\displaystyle \frac{11}{12} = 1 - \frac{1}{12} = 1 - 0.08333\dots = 0.91666\dots = 0.91\overline{6}

Calculator errors: When close isn’t close enough (Part 2)

In the previous post, I gave a simple classroom demonstration to illustrate that some calculators only approximate an infinite decimal expansion with a terminating decimal expansion, and hence truncation errors can propagate. This example addresses the common student question, “What’s the big deal if I round off to a few decimal places?”

TItrunc1

(For what it’s worth, I’m aware that some current high-end calculators are miniature computer algebra systems and can formally handle an answer of \displaystyle \frac{1}{3} instead of its decimal expansion.)

Students may complain that the above exercise is artificial and unlikely to occur in real life. I would suggest following up with a real-world, non-artificial, and tragic example of an accident that happened in large part due to truncation error. This incident occurred during the first Gulf War in 1991 (perhaps ancient history to today’s students). I’m going to quote directly from the website http://www.ima.umn.edu/~arnold/disasters/patriot.html, published by Dr. Douglas Arnold at the University of Minnesota. Perhaps students don’t need to master the details of this explanation (a binary expansion as opposed to a decimal expansion might be a little abstract), but I think that this example illustrates truncation error vividly.

On February 25, 1991, during the Gulf War, an American Patriot Missile battery in Dharan, Saudi Arabia, failed to track and intercept an incoming Iraqi Scud missile. The Scud struck an American Army barracks, killing 28 soldiers and injuring around 100 other people. Patriot missile A report of the General Accounting office, GAO/IMTEC-92-26, entitled Patriot Missile Defense: Software Problem Led to System Failure at Dhahran, Saudi Arabia reported on the cause of the failure.

It turns out that the cause was an inaccurate calculation of the time since boot due to computer arithmetic errors. Specifically, the time in tenths of second as measured by the system’s internal clock was multiplied by 1/10 to produce the time in seconds. This calculation was performed using a 24 bit fixed point register. In particular, the value 1/10, which has a non-terminating binary expansion, was chopped at 24 bits after the radix point. The small chopping error, when multiplied by the large number giving the time in tenths of a second, led to a significant error.

Indeed, the Patriot battery had been up around 100 hours, and an easy calculation shows that the resulting time error due to the magnified chopping error was about 0.34 seconds.

The number 1/10 equals

\displaystyle \frac{1}{2^4} + \frac{1}{2^5} +\frac{1}{2^8} + \frac{1}{2^9} + \frac{1}{2^{12}} + \frac{1}{2^{13}} + \dots

In other words, the binary expansion of 1/10 is

0.0001100110011001100110011001100....

Now the 24 bit register in the Patriot stored instead

0.00011001100110011001100

introducing an error of

0.0000000000000000000000011001100... binary,

or about 0.000000095 decimal. Multiplying by the number of tenths of a second in 100 hours gives

0.000000095 \times 100 \times 60 \times 60 \times 10=0.34.

A Scud travels at about 1,676 meters per second, and so travels more than half a kilometer in this time. This was far enough that the incoming Scud was outside the “range gate” that the Patriot tracked.

Ironically, the fact that the bad time calculation had been improved in some parts of the code, but not all, contributed to the problem, since it meant that the inaccuracies did not cancel.

The following paragraph is excerpted from the GAO report.

The range gate’s prediction of where the Scud will next appear is a function of the Scud’s known velocity and the time of the last radar detection. Velocity is a real number that can be expressed as a whole number and a decimal (e.g., 3750.2563…miles per hour). Time is kept continuously by the system’s internal clock in tenths of seconds but is expressed as an integer or whole number (e.g., 32, 33, 34…). The longer the system has been running, the larger the number representing time. To predict where the Scud will next appear, both time and velocity must be expressed as real numbers. Because of the way the Patriot computer performs its calculations and the fact that its registers are only 24 bits long, the conversion of time from an integer to a real number cannot be any more precise than 24 bits. This conversion results in a loss of precision causing a less accurate time calculation. The effect of this inaccuracy on the range gate’s calculation is directly proportional to the target’s velocity and the length of the the system has been running. Consequently, performing the conversion after the Patriot has been running continuously for extended periods causes the range gate to shift away from the center of the target, making it less likely that the target, in this case a Scud, will be successfully intercepted.

green line

A quick note of clarification. To verify the binary expansion of 1/10, we use the formula for an infinite geometric series.

S = \displaystyle \left(\frac{1}{2^4} + \frac{1}{2^5}\right) +\left(\frac{1}{2^8} + \frac{1}{2^9}\right) + \left(\frac{1}{2^{12}} + \frac{1}{2^{13}}\right) + \dots

S = \displaystyle \frac{3}{2^5} + \frac{3}{2^9} + \frac{3}{2^{13}} + \dots

S = \displaystyle \frac{\displaystyle \frac{3}{2^5}}{\quad \displaystyle 1 - \frac{1}{2^4} \quad}

S = \displaystyle \frac{\displaystyle \frac{3}{32}}{\quad \displaystyle \frac{15}{16} \quad}

S = \displaystyle \frac{3}{32} \times \frac{16}{15}

S = \displaystyle \frac{1}{10}

OK, that verifies the answer. Still, a curious student may wonder how one earth one could directly convert 1/10 into binary without knowing the above series ahead of time. I will address this question in a future post.