{"id":212,"date":"2006-11-15T15:31:51","date_gmt":"2006-11-15T15:31:51","guid":{"rendered":"http:\/\/scientopia.org\/blogs\/goodmath\/2006\/11\/15\/egyptian-fractions\/"},"modified":"2006-11-15T15:31:51","modified_gmt":"2006-11-15T15:31:51","slug":"egyptian-fractions","status":"publish","type":"post","link":"http:\/\/www.goodmath.org\/blog\/2006\/11\/15\/egyptian-fractions\/","title":{"rendered":"Egyptian Fractions"},"content":{"rendered":"<p>While I was researching yesterdays post on Archimedes integration, one of the things I read reminded me of one of the stranger things about Greek and earlier math. They had a notion that the only valid fractions were *unit* fractions; that is, fractions whose numerator is 1. A fraction that was written with a numerator larger than one was considered *wrong*. Even today, if you look in a lot of math books, they use the term &#8220;vulgar fraction&#8221; for non-unit fractions.<br \/>\nObviously, there *are* fractions other that *1\/n*. The way that they represented them is now known as *Egyptian fractions*. An Egyptian fraction is expressed as the sum of a finite set of unit fractions. So, for example, instead of writing the vulgar fraction 2\/3, the Greeks would write<br \/>\n&#8220;1\/2 + 1\/6&#8221;.<\/p>\n<p><!--more--><br \/>\nHistory<br \/>\n&#8212;&#8212;&#8212;&#8212;<br \/>\nWe don&#8217;t know that much about the origins of Egyptian fractions.  What we do know is that the earliest written record of their use is in an Egyptian scroll from roughly the 18th century BC, which is why they&#8217;re known as Egyptian fractions.<br \/>\nThat scroll, known as the *Rhind Papyrus* is one of the most fascinating things in the entire history of mathematics. It appears to be something along the lines of a *textbook* of Egyptian mathematics: a set of questions written roughly in the form of test questions, and fully worked answers. The scroll includes tables of fractions written in unit-fraction sum form, as well as numerous algebra (in roughly the equational reasoning form we use today!) and geometry problems. From the wording of the<br \/>\nscroll, it&#8217;s strongly implied that the author is recording techniques well-known by the mathematicians of the day, but kept secret from the masses. (What we would call mathematicians were<br \/>\npart of the priestly class in Egypt, usually temple scribes. Things like advanced math were considered a sort of sacred mystery, reserved to the temples.)<br \/>\nSo we don&#8217;t really know *when* they were invented, or by whom. But from the time of the Egyptians, through the empires of the Greeks and Romans, they continued to be considered the *correct* mathematical notation for fractions.<br \/>\nAs I said in the introduction, vulgar fractions were considered to be ugly at best, and incorrect at worst, all the way into the middle ages. Fibonacci defined what is still pretty much the canonical algorithm for computing the Egyptian fraction form of a rational number.<br \/>\nNot too long after Fibonacci, the obsession with avoiding vulgar fractions declined. But they&#8217;ve stayed around both because of the historical documents that use them, and because they&#8217;re useful as a way for looking at certain problems in number theory. (Not to mention as a foundation for a lot of nifty mathematical puzzles.)<br \/>\nComputing Egyptian Fraction Form<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\nThe primary algorithm for computing the Egyptian fraction form is a classic example of what CS geeks like me call a *greedy algorithm*. The greedy algorithm doesn&#8217;t always generate the shortest possible<br \/>\negyptian fraction form, but it is guaranteed to terminate with a finite (if ugly) sequence.<br \/>\nThe basic idea of the algorithm is:<br \/>\nGiven a vulgar fraction x\/y, the egyptian form egypt(x\/y) = 1\/(&lceil;y\/x&rceil;) + egypt(remainder),<br \/>\nwhere remainder=(-y mod x)\/(y&times;&lceil;y\/x&rceil;).<br \/>\nOr, in a slightly more useful form, here&#8217;s the above written as a Haskell program, which returns the list of unit fractions (For non-Haskell folks out there, x%y is a Haskell type constructor which creates the fraction x\/y; and &#8220;x:y&#8221; creates a list with head &#8220;x&#8221; and tail &#8220;y&#8221;.)<br \/>\negypt :: Rational -&gt; [Rational]<br \/>\negypt 0 = []<br \/>\negypt fraction =<br \/>\n(1%denom):(remainders) where<br \/>\nx = numerator fraction<br \/>\ny = denominator fraction<br \/>\ndenom = ceiling (y%x)<br \/>\nremx = (-y) `mod` x<br \/>\nremy = y*denom<br \/>\nremainders = egypt (remx%remy)<br \/>\n*(Thanks to  Bruno for helping me fix the stupid problem with the code above.) *<br \/>\nAnd for fun, the reverse process, converting from the Egyptian form to vulgar:<br \/>\nvulgar :: [Rational] -&gt; Rational<br \/>\nvulgar r = foldl (+) 0 r<br \/>\nA few examples of fractions in Egyptian form:<br \/>\n* 4\/5 = 1\/2 + 1\/4 + 1\/20<br \/>\n* 9\/31 = 1\/4 + 1\/25 + 1\/3100<br \/>\n* 21\/50 = 1\/3 + 1\/12 + 1\/300<br \/>\n* 1023\/1024 = 1\/2 + 1\/3 + 1\/7 + 1\/44 + 1\/9462 + 1\/373029888<br \/>\nAs you can see, the Fibonacci algorithm for Egyptian fractions can generate some really<br \/>\nugly terms. It often generates sequences of fractions that are longer than necessary, and that include ridiculously large and awkward denominators. For example, the last fraction above can be written more clearly as (1\/2 + 1\/4 + 1\/8 + 1\/16 + 1\/64 + 1\/128 + 1\/256 + 1\/512 + 1\/1024).  One of the canonical examples of weakness of the Fibonacci algorithm is 5\/121 = 1\/25 + 1\/757 + 1\/763309 + 1\/873960180913+ 1\/1527612795642093418846225, which can be written  much more simply as 1\/33 + 1\/121 + 1\/363.<br \/>\nThe problem, though, is that the Fibonacci algorithm is the only *efficient* method we know for computing Egyptian fractions. *(Actually, I was wrong about the previous sentence. The sources that I was reading when I wrote the article were out of date, and I didn&#8217;t check the web the way I should have. In the comments, David Eppstein pointed out that there are much better algorithms that the greedy one, and [his website includes implementations of a number of them](http:\/\/www.ics.uci.edu\/~eppstein\/numth\/egypt\/)*.  We don&#8217;t know any particularly *good* ways of computing the minimal length forms. In fact, we don&#8217;t even know what the complexity bounds of computing a minimal Egyptian fraction are.<br \/>\nConclusion<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nWhat&#8217;s I find particularly interesting about Egyptian fractions is how long they lasted, given how incredibly hard to work with they are. Adding fractions in Egyptian form is difficult; multiplying two fractions is absolutely insane. Multiplying an integer by an Egyptian fraction is a pain, but not as bad as multiplying two Egyptian fractions. From a purely practical standpoint, they seem downright ridiculous. As early as 150 AD, they were roundly critiqued by Ptolemy himself! And yet, they were *the* way that fractions were written for close to three *thousand* years.  The aesthetics of<br \/>\nalways using unit fractions overwhelmed the practicality of tractable arithmetic.<br \/>\nThere are a bunch of interesting open problems involving Egyptian fractions: I&#8217;ll just leave you with one example that I found on Wikipedia. Paul Erd&ouml;s, the great Hungarian mathematician, tried to prove that for any fraction 4\/n, there was an Egyptian fraction containing exactly three terms. Doing brute force tests, it&#8217;s been shown to be true for every number *n* smaller than 10<sup>14<\/sup>, but no one has been able to figure out how to prove it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While I was researching yesterdays post on Archimedes integration, one of the things I read reminded me of one of the stranger things about Greek and earlier math. They had a notion that the only valid fractions were *unit* fractions; that is, fractions whose numerator is 1. A fraction that was written with a numerator [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[43],"tags":[],"class_list":["post-212","post","type-post","status-publish","format-standard","hentry","category-numbers"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4lzZS-3q","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/comments?post=212"}],"version-history":[{"count":0,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/212\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/media?parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/categories?post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/tags?post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}