Greedy Algorithm For Egyptian Fractions
Greedy Algorithm For Egyptian Fractions
In mathematics, the greedy algorithm for Egyptian fractions is a greedy algorithm, first described by
Fibonacci, for transforming rational numbers into Egyptian fractions. An Egyptian fraction is a
representation of an irreducible fraction as a sum of distinct unit fractions, such as 56 = 12 + 13 . As the name
indicates, these representations have been used as long ago as ancient Egypt, but the first published
systematic method for constructing such expansions was described in 1202 in the Liber Abaci of Leonardo
of Pisa (Fibonacci).[1] It is called a greedy algorithm because at each step the algorithm chooses greedily
the largest possible unit fraction that can be used in any representation of the remaining fraction.
Fibonacci actually lists several different methods for constructing Egyptian fraction representations.[2] He
includes the greedy method as a last resort for situations when several simpler methods fail; see Egyptian
fraction for a more detailed listing of these methods. As Salzer (1948) details, the greedy method, and
extensions of it for the approximation of irrational numbers, have been rediscovered several times by
modern mathematicians, earliest and most notably by J. J. Sylvester (1880)[3] A closely related expansion
method that produces closer approximations at each step by allowing some unit fractions in the sum to be
negative dates back to Lambert (1770).
The expansion produced by this method for a number is called the greedy Egyptian expansion,
Sylvester expansion, or Fibonacci–Sylvester expansion of . However, the term Fibonacci expansion
usually refers, not to this method, but to representation of integers as sums of Fibonacci numbers.
in this expansion, the denominator 3 of the first unit fraction is the result of rounding 15
7 up to the next
2
larger integer, and the remaining fraction 15 is the result of simplifying −15 mod 7 6
15 × 3 = 45 . The denominator
of the second unit fraction, 8, is the result of rounding 15 2
up to the next larger integer, and the remaining
1 7
fraction 120 is what is left from 15 after subtracting both 13 and 18 .
As each expansion step reduces the numerator of the remaining fraction to be expanded, this method
always terminates with a finite expansion; however, compared to ancient Egyptian expansions or to more
modern methods, this method may produce expansions that are quite long, with large denominators. For
instance, this method expands
while other methods lead to the much better expansion
31
Wagon (1991) suggests an even more badly-behaved example, 311 . The greedy method leads to an
31
expansion with ten terms, the last of which has over 500 digits in its denominator; however, 311 has a much
1 1 1 1
shorter non-greedy representation, 12 + 63 + 2799 + 8708 .
results in the closest possible underestimate of 1 by any k-term Egyptian fraction.[4] That is, for example,
any Egyptian fraction for a number in the open interval ( 1805
1806 , 1) requires at least five terms.
Curtiss (1922)
describes an application of these closest-approximation results in lower-bounding the number of divisors of
a perfect number, while Stong (1983) describes applications in group theory.
Every fraction 1y requires one term in its greedy expansion; the simplest such fraction is 11 .
Every fraction 2y requires two terms in its greedy expansion if and only if y ≡ 1 (mod 2); the
simplest such fraction is 23 .
A fraction 3y requires three terms in its greedy expansion if and only if y ≡ 1 (mod 6), for then
−y mod x = 2 and y(y 3+ 2) is odd, so the fraction remaining after a single step of the greedy
expansion,
is in simplest terms. The simplest fraction 3y with a three-term expansion is 37 .
A fraction 4y requires four terms in its greedy expansion if and only if y ≡ 1 or 17 (mod 24), for
then the numerator −y mod x of the remaining fraction is 3 and the denominator is 1 (mod 6).
The simplest fraction 4y with a four-term expansion is 17
4
. The Erdős–Straus conjecture
states that all fractions 4y have an expansion with three or fewer terms, but when
y ≡ 1 or 17 (mod 24) such expansions must be found by methods other than the greedy
algorithm, with the 17 (mod 24) case being covered by the congruence relationship
2 (mod 3).
More generally the sequence of fractions xy that have x-term greedy expansions and that have the smallest
possible denominator y for each x is
1. Since P0(x) < 0 for x = 1, and P0(x) > 0 for all x ≥ 2, there must be a root of P0(x) between 1
and 2. That is, the first term of the greedy expansion of the golden ratio is 11 . If x1 is the
remaining fraction after the first step of the greedy expansion, it satisfies the equation
2
P0(x1 + 1) = 0, which can be expanded as P1(x1) = x1 + x1 − 1 = 0.
2. Since P1(x) < 0 for x = 12 , and P1(x) > 0 for all x > 1, the root of P1 lies between 12 and 1, and
the first term in its greedy expansion (the second term in the greedy expansion for the golden
ratio) is 12 . If x2 is the remaining fraction after this step of the greedy expansion, it satisfies the
2
equation P1(x2 + 12 ) = 0, which can be expanded as P2(x2) = 4x2 + 8x2 − 1 = 0.
3. Since P2(x) < 0 for x = 19 , and P2(x) > 0 for all x > 18 , the next term in the greedy expansion is
1
9
. If x3 is the remaining fraction after this step of the greedy expansion, it satisfies the
equation P2(x3 + 19 ) = 0, which can again be expanded as a polynomial equation with
2
integer coefficients, P3(x3) = 324x3 + 720x3 − 5 = 0.
Continuing this approximation process eventually produces the greedy expansion for the golden ratio,
(sequence A117116 in the OEIS).
Related expansions
In general, if one wants an Egyptian fraction expansion in which the denominators are constrained in some
way, it is possible to define a greedy algorithm in which at each step one chooses the expansion
where is chosen, among all possible values satisfying the constraints, as small as possible such that
and such that is distinct from all previously chosen denominators. Examples of methods defined
in this way include Engel expansion, in which each successive denominator must be a multiple of the
previous one, and odd greedy expansion, in which all denominators are constrained to be odd numbers.
However, it may be difficult to determine whether an algorithm of this type can always succeed in finding a
finite expansion. In particular, it is unknown whether the odd greedy expansion terminates with a finite
expansion for all fractions for which is odd, although it is possible to find finite odd expansions for
these fractions by non-greedy methods.
Notes
1. Sigler 2002.
2. Sigler 2002, chapter II.7
3. See for instance Cahen (1891) and Spiess (1907).
4. Curtiss 1922; Soundararajan 2005
References
Cahen, E. (1891), "Note sur un développement des quantités numériques, qui presente
quelque analogie avec celui en fractions continues", Nouvelles Annales des
Mathématiques, Ser. 3, 10: 508–514.
Curtiss, D. R. (1922), "On Kellogg's diophantine problem", American Mathematical Monthly,
29 (10): 380–387, doi:10.2307/2299023 (https://doi.org/10.2307%2F2299023),
JSTOR 2299023 (https://www.jstor.org/stable/2299023).
Freitag, H. T.; Phillips, G. M. (1999), "Sylvester's algorithm and Fibonacci numbers",
Applications of Fibonacci numbers, Vol. 8 (Rochester, NY, 1998), Dordrecht: Kluwer Acad.
Publ., pp. 155–163, MR 1737669 (https://mathscinet.ams.org/mathscinet-getitem?mr=17376
69).
Lambert, J. H. (1770), Beyträge zum Gebrauche der Mathematik und deren Anwendung,
Berlin: Zweyter Theil, pp. 99–104.
Mays, Michael (1987), "A worst case of the Fibonacci–Sylvester expansion", Journal of
Combinatorial Mathematics and Combinatorial Computing, 1: 141–148, MR 0888838 (http
s://mathscinet.ams.org/mathscinet-getitem?mr=0888838).
Salzer, H. E. (1947), "The approximation of numbers as sums of reciprocals", American
Mathematical Monthly, 54 (3): 135–142, doi:10.2307/2305906 (https://doi.org/10.2307%2F23
05906), JSTOR 2305906 (https://www.jstor.org/stable/2305906), MR 0020339 (https://maths
cinet.ams.org/mathscinet-getitem?mr=0020339).
Salzer, H. E. (1948), "Further remarks on the approximation of numbers as sums of
reciprocals", American Mathematical Monthly, 55 (6): 350–356, doi:10.2307/2304960 (http
s://doi.org/10.2307%2F2304960), JSTOR 2304960 (https://www.jstor.org/stable/2304960),
MR 0025512 (https://mathscinet.ams.org/mathscinet-getitem?mr=0025512).
Sigler, Laurence E. (trans.) (2002), Fibonacci's Liber Abaci, Springer-Verlag, ISBN 0-387-
95419-8.
Soundararajan, K. (2005), Approximating 1 from below using n Egyptian fractions,
arXiv:math.CA/0502247 (https://arxiv.org/abs/math.CA/0502247).
Spiess, O. (1907), "Über eine Klasse unendlicher Reihen", Archiv der Mathematik und
Physik, Third Series, 12: 124–134.
Stong, R. E. (1983), "Pseudofree actions and the greedy algorithm", Mathematische
Annalen, 265 (4): 501–512, doi:10.1007/BF01455950 (https://doi.org/10.1007%2FBF01455
950), MR 0721884 (https://mathscinet.ams.org/mathscinet-getitem?mr=0721884),
S2CID 120347233 (https://api.semanticscholar.org/CorpusID:120347233).
Stratemeyer, G. (1930), "Stammbruchentwickelungen für die Quadratwurzel aus einer
rationalen Zahl", Mathematische Zeitschrift, 31: 767–768, doi:10.1007/BF01246446 (https://
doi.org/10.1007%2FBF01246446), S2CID 120956180 (https://api.semanticscholar.org/Corp
usID:120956180).
Sylvester, J. J. (1880), "On a point in the theory of vulgar fractions", American Journal of
Mathematics, 3 (4): 332–335, doi:10.2307/2369261 (https://doi.org/10.2307%2F2369261),
JSTOR 2369261 (https://www.jstor.org/stable/2369261).
Wagon, S. (1991), Mathematica in Action, W. H. Freeman, pp. 271–277.