09.12.2012 Views

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

Concrete mathematics : a foundation for computer science

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

122 NUMBER THEORY<br />

This means that we can trans<strong>for</strong>m the binary search algorithm to the following<br />

matrix-free procedure:<br />

while m # n do<br />

if m < n then (output(L); n := n-m)<br />

else (output(R); m := m-n) .<br />

For example, given m/n = 5/7, we have successively<br />

m=5 5 3 1 1<br />

n=7 2 2 2 1<br />

output L R R L<br />

in the simplified algorithm.<br />

Irrational numbers don’t appear in the Stern-Brocot tree, but all the<br />

rational numbers that are “close” to them do. For example, if we try the<br />

binary search algorithm with the number e = 2.71828. . , instead of with a<br />

fraction m/n, we’ll get an infinite string of L’s and R's that begins<br />

RRLRRLRLLLLRLRRRRRRLRLLLLLLLLRLR....<br />

We can consider this infinite string to be the representation of e in the Stern-<br />

Brocot number system, just as we can represent e as an infinite decimal<br />

2.718281828459... or as an infinite binary fraction (10.101101111110...)~.<br />

Incidentally, it turns out that e’s representation has a regular pattern in the<br />

Stern-Brocot system:<br />

e = RL”RLRZLRL4RLR6LRL8RLR10LRL’2RL . . . ;<br />

this is equivalent to a special case of something that Euler [84] discovered<br />

when he was 24 years old.<br />

From this representation we can deduce that the fractions<br />

RRLRRLRLLLL R L R R R R R R<br />

1 2 1 5 & 11 19 30 49 68 87 -------- 106 193 299 492 685 878 1071 1264<br />

1'1'1'2'3' 4' 7'11'18'25'32' 39' 71'110'181'252'323' 394' 465""<br />

are the simplest rational upper and lower approximations to e. For if m/n<br />

does not appear in this list, then some fraction in this list whose numerator<br />

is 6 m and whose denominator is < n lies between m/n and e. For example,<br />

g is not as simple an approximation as y = 2.714. . . , which appears in<br />

the list and is closer to e. We can see this because the Stern-Brocot tree<br />

not only includes all rationals, it includes them in order, and because all<br />

fractions with small numerator and denominator appear above all less simple<br />

ones. Thus, g = RRLRRLL is less than F = RRLRRL, which is less than

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!