Greedy algorithm for Egyptian fractions

Last updated

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). [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.

Contents

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.

Algorithm and examples

Fibonacci's algorithm expands the fraction to be represented, by repeatedly performing the replacement

(simplifying the second term in this replacement as necessary). For instance:

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

while other methods lead to the much better expansion

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)

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.

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.

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

(sequence A048860 in the OEIS).

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) = x2x − 1 = 0. The algorithm of Stratemeyer and Salzer performs the following sequence of steps:

  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 1/1. If x1 is the remaining fraction after the first step of the greedy expansion, it satisfies the equation P0(x1 + 1) = 0, which can be expanded as P1(x1) = x2
    1
    + x1 − 1 = 0
    .
  2. Since P1(x) < 0 for x = 1/2, and P1(x) > 0 for all x > 1, the root of P1 lies between 1/2 and 1, and the first term in its greedy expansion (the second term in the greedy expansion for the golden ratio) is 1/2. If x2 is the remaining fraction after this step of the greedy expansion, it satisfies the equation P1(x2 + 1/2) = 0, which can be expanded as P2(x2) = 4x2
    2
    + 8x2 − 1 = 0
    .
  3. Since P2(x) < 0 for x = 1/9, and P2(x) > 0 for all x > 1/8, 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 + 1/9) = 0, which can again be expanded as a polynomial equation with integer coefficients, P3(x3) = 324x2
    3
    + 720x3 − 5 = 0
    .

Continuing this approximation process eventually produces the greedy expansion for the golden ratio,

(sequence A117116 in the OEIS).

Other integer sequences

The length, minimum denominator, and maximum denominator of the greedy expansion for all fractions with small numerators and denominators can be found in the On-Line Encyclopedia of Integer Sequences as sequences OEIS:  A050205 , OEIS:  A050206 , and OEIS:  A050210 , respectively. In addition, the greedy expansion of any irrational number leads to an infinite increasing sequence of integers, and the OEIS contains expansions of several well known constants. Some additional entries in the OEIS, though not labeled as being produced by the greedy algorithm, appear to be of the same type.

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

Related Research Articles

<span class="mw-page-title-main">Fibonacci number</span> Integer in the infinite Fibonacci sequence

In mathematics, the Fibonacci numbers, commonly denoted Fn, form a sequence, the Fibonacci sequence, in which each number is the sum of the two preceding ones. The sequence commonly starts from 0 and 1, although some authors start the sequence from 1 and 1 or sometimes from 1 and 2. Starting from 0 and 1, the first few values in the sequence are:

The Collatz conjecture is one of the most famous unsolved problems in mathematics. The conjecture asks whether repeating two simple arithmetic operations will eventually transform every positive integer into 1. It concerns sequences of integers in which each term is obtained from the previous term as follows: if the previous term is even, the next term is one half of the previous term. If the previous term is odd, the next term is 3 times the previous term plus 1. The conjecture is that these sequences always reach 1, no matter which positive integer is chosen to start the sequence.

In mathematics, a continued fraction is an expression obtained through an iterative process of representing a number as the sum of its integer part and the reciprocal of another number, then writing this other number as the sum of its integer part and another reciprocal, and so on. In a finite continued fraction, the iteration/recursion is terminated after finitely many steps by using an integer in lieu of another continued fraction. In contrast, an infinite continued fraction is an infinite expression. In either case, all integers in the sequence, other than the first, must be positive. The integers are called the coefficients or terms of the continued fraction.

<i>Liber Abaci</i> Mathematics book written in 1202 by Fibonacci

Liber Abaci is a historic 1202 Latin manuscript on arithmetic by Leonardo of Pisa, posthumously known as Fibonacci.

<span class="mw-page-title-main">Egyptian fraction</span> Finite sum of distinct unit fractions

An Egyptian fraction is a finite sum of distinct unit fractions, such as

<span class="mw-page-title-main">Square root of 2</span> Unique positive real number which when multiplied by itself gives 2

The square root of 2 is a positive real number that, when multiplied by itself, equals the number 2. It may be written in mathematics as or , and is an algebraic number. Technically, it should be called the principal square root of 2, to distinguish it from the negative number with the same property.

<span class="mw-page-title-main">Farey sequence</span> Increasing sequence of reduced fractions

In mathematics, the Farey sequence of order n is the sequence of completely reduced fractions, either between 0 and 1, or without this restriction, which when in lowest terms have denominators less than or equal to n, arranged in order of increasing size.

In number theory, a Keith number or repfigit number is a natural number in a given number base with digits such that when a sequence is created such that the first terms are the digits of and each subsequent term is the sum of the previous terms, is part of the sequence. Keith numbers were introduced by Mike Keith in 1987. They are computationally very challenging to find, with only about 100 known.

A unit fraction is a rational number written as a fraction where the numerator is one and the denominator is a positive integer. A unit fraction is therefore the reciprocal of a positive integer, 1/n. Examples are 1/1, 1/2, 1/3, 1/4, 1/5, etc.

<span class="mw-page-title-main">Practical number</span> Number such that it and all smaller numbers may be represented as sums of its distinct divisors

In number theory, a practical number or panarithmic number is a positive integer such that all smaller positive integers can be represented as sums of distinct divisors of . For example, 12 is a practical number because all the numbers from 1 to 11 can be expressed as sums of its divisors 1, 2, 3, 4, and 6: as well as these divisors themselves, we have 5 = 3 + 2, 7 = 6 + 1, 8 = 6 + 2, 9 = 6 + 3, 10 = 6 + 3 + 1, and 11 = 6 + 3 + 2.

<span class="mw-page-title-main">Pell number</span> Natural number used to approximate √2

In mathematics, the Pell numbers are an infinite sequence of integers, known since ancient times, that comprise the denominators of the closest rational approximations to the square root of 2. This sequence of approximations begins 1/1, 3/2, 7/5, 17/12, and 41/29, so the sequence of Pell numbers begins with 1, 2, 5, 12, and 29. The numerators of the same sequence of approximations are half the companion Pell numbers or Pell–Lucas numbers; these numbers form a second infinite sequence that begins with 2, 6, 14, 34, and 82.

The Erdős–Straus conjecture is an unproven statement in number theory. The conjecture is that, for every integer that is 2 or more, there exist positive integers , , and for which

<span class="mw-page-title-main">Stern–Brocot tree</span> Ordered binary tree of rational numbers

In number theory, the Stern–Brocot tree is an infinite complete binary tree in which the vertices correspond one-for-one to the positive rational numbers, whose values are ordered from the left to the right as in a search tree.

Methods of computing square roots are numerical analysis algorithms for approximating the principal, or non-negative, square root of a real number. Arithmetically, it means given , a procedure for finding a number which when multiplied by itself, yields ; algebraically, it means a procedure for finding the non-negative root of the equation ; geometrically, it means given two line segments, a procedure for constructing their geometric mean.

The Engel expansion of a positive real number x is the unique non-decreasing sequence of positive integers such that

<span class="mw-page-title-main">Sylvester's sequence</span> Doubly exponential integer sequence

In number theory, Sylvester's sequence is an integer sequence in which each term is the product of the previous terms, plus one. The first few terms of the sequence are

In number theory, the odd greedy expansion problem asks whether a greedy algorithm for finding Egyptian fractions with odd denominators always succeeds. As of 2021, it remains unsolved.

The square root of 5 is the positive real number that, when multiplied by itself, gives the prime number 5. It is more precisely called the principal square root of 5, to distinguish it from the negative number with the same property. This number appears in the fractional expression for the golden ratio. It can be denoted in surd form as:

A repeating decimal or recurring decimal is decimal representation of a number whose digits are periodic and the infinitely repeated portion is not zero. It can be shown that a number is rational if and only if its decimal representation is repeating or terminating. For example, the decimal representation of 1/3 becomes periodic just after the decimal point, repeating the single digit "3" forever, i.e. 0.333.... A more complicated example is 3227/555, whose decimal becomes periodic at the second digit following the decimal point and then repeats the sequence "144" forever, i.e. 5.8144144144.... At present, there is no single universally accepted notation or phrasing for repeating decimals.

<span class="mw-page-title-main">Square root of 7</span> Positive real number which when multiplied by itself gives 7

The square root of 7 is the positive real number that, when multiplied by itself, gives the prime number 7. It is more precisely called the principal square root of 7, to distinguish it from the negative number with the same property. This number appears in various geometric and number-theoretic contexts. It can be denoted in surd form as:

References