ArticleslgStudy

computer science

Greedy algorithm for Egyptian fractions

Greedy algorithm for Egyptian fractions is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Greedy algorithm for Egyptian fractions rather than just read about it. In short: 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 ⁠5/6⁠ = ⁠1/2⁠ + ⁠1/3⁠.

Key takeaways

  • Greedy algorithm for Egyptian fractions belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Greedy algorithm for Egyptian fractions to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Greedy algorithm for Egyptian fractions from memory before moving on to harder problems.

Reference excerpt

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 ⁠5/6⁠ = ⁠1/2⁠ + ⁠1/3⁠. 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). 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. 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. 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) 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 x is called the greedy Egyptian expansion, Sylvester expansion, or Fibonacci–Sylvester expansion of x. However, the term Fibonacci expansion usually refers, not to this method, but to representation of integers as sums of Fibonacci numbers.

Algorithm and examples Fibonacci's algorithm expands the fraction x/y<1 to be represented, by repeatedly performing the replacement xy=1⌈yx⌉+(−y)modxy⌈yx⌉ (simplifying the second term in this replacement as necessary). For instance: 715=13+215=13+18+1120. in this expansion, the denominator 3 of the first unit fraction is the result of rounding ⁠15/7⁠ up to the next larger integer, and the remaining fraction ⁠2/15⁠ is the result of simplifying ⁠−15 mod 7/15 × 3⁠ = ⁠6/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 fraction ⁠1/120⁠ is what is left from ⁠7/15⁠ after subtracting both ⁠1/3⁠ and ⁠1/8⁠. 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 5121=125+1757+1763309+1873960180913+11527612795642093418846225, while other methods lead to the much better expansion 5121=133+1121+1363. Wagon (1991) suggests an even more badly-behaved example, ⁠31/311⁠. The greedy method leads to an expansion with ten terms, the last of which has over 500 digits in its denominator; however, ⁠31/311⁠ has a much shorter non-greedy representation, ⁠1/12⁠ + ⁠1/63⁠ + ⁠1/2799⁠ + ⁠1/8708⁠.

Sylvester's sequence and closest approximation Sylvester's sequence 2, 3, 7, 43, 1807, ... (OEIS: A000058) can be viewed as generated by an infinite greedy expansion of this type for the number 1, where at each step we choose the denominator ⌊ ⁠y/x⁠ ⌋ + 1 instead of ⌈ ⁠y/x⁠ ⌉. Truncating this sequence to k terms and forming the corresponding Egyptian fraction, e.g. (for k = 4) 12+13+17+143=18051806 results in the closest possible underestimate of 1 by any k-term Egyptian fraction. 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.

Maximum-length expansions and congruence conditions Any fraction ⁠x/y⁠ requires at most x terms in its greedy expansion. Mays (1987) and Freitag & Phillips (1999) examine the conditions under which the greedy method produces an expansion of ⁠x/y⁠ with exactly x terms; these can be described in terms of congruence conditions on y.

Every fraction ⁠1/y⁠ requires one term in its greedy expansion; the simplest such fraction is ⁠1/1⁠. Every fraction ⁠2/y⁠ requires two terms in its greedy expansion if and only if y ≡ 1 (mod 2); the simplest such fraction is ⁠2/3⁠. A fraction ⁠3/y⁠ requires three terms in its greedy expansion if and only if y ≡ 1 (mod 6), for then −y mod x = 2 and ⁠y(y + 2)/3⁠ is odd, so the fraction remaining after a single step of the greedy expansion, (−y)modxy⌈yx⌉=2y(y+2)3 is in simplest terms. The simplest fraction ⁠3/y⁠ with a three-term expansion is ⁠3/7⁠. A fraction ⁠4/y⁠ 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 ⁠4/y⁠ with a four-term expansion is ⁠4/17⁠. The Erdős–Straus conjecture states that all fractions ⁠4/y⁠ 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 ⁠x/y⁠ that have x-term greedy expansions and that have the smallest possible denominator y for each x is

Approximation of polynomial roots Stratemeyer (1930) and Salzer (1947) describe a method of finding an accurate approximation for the roots of a polynomial based on the greedy method. Their algorithm computes the greedy expansion of a root; at each step in this expansion it maintains an auxiliary polynomial that has as its root the remaining fraction to be expanded. Consider as an example applying this method to find the greedy expansion of the golden ratio, one of the two solutions of the polynomial equation P0(x) = x2 − x − 1 = 0. The algorithm of Stratemeyer and Salzer performs the following sequence of steps:

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Greedy algorithm for Egyptian fractions

Start with the simplest possible case. Write down what Greedy algorithm for Egyptian fractions claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Greedy algorithm for Egyptian fractions before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Greedy algorithm for Egyptian fractions ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Greedy algorithm for Egyptian fractions

In research
Greedy algorithm for Egyptian fractions appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Greedy algorithm for Egyptian fractions in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Greedy algorithm for Egyptian fractions is common in secondary-school and first-year university syllabi. It links to neighbouring topics Egyptian fractions, Greedy algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Greedy algorithm for Egyptian fractions outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Greedy algorithm for Egyptian fractions” →

How to study Greedy algorithm for Egyptian fractions in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Greedy algorithm for Egyptian fractions means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Greedy algorithm for Egyptian fractions out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Greedy algorithm for Egyptian fractions in simple terms?

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 ⁠5/6⁠ = ⁠1/2⁠…

Why does Greedy algorithm for Egyptian fractions matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Greedy algorithm for Egyptian fractions?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Greedy algorithm for Egyptian fractions.

Tags

  • Egyptian fractions
  • Greedy algorithms

Keep exploring