One begins to wonder if...

Playing with more examples will make one wonder if one always gets a final representation , and one comes to realise that one particular approach (the ' greedy ' approach, first noted evidently by Fibonacci, 1202AD) stands out: something rather special and fruitful happens if one systematically determines the '?' substitutes by always chosing the ' first possible unit fraction ' (in the sense of what we did above). Here is the important, simple result:

Theorem (the first step of the greedy algorithm ). Let a and b be natural numbers with a < b (that's just to ensure that a/b lies between 0 and 1). If a divides b , then (trivially) a/b is already a unit fraction, otherwise

  • let 1/n be the nearest unit fraction to a/b from below
    (meaning:
    1/n < a/b , while a/b < 1/(n-1) , for some natural number n , with 2 <= n );

then the numerator of the fraction a/b-1/n ( = (a*n-b)/(b*n) , which is, of course, positive)
is
smaller than the numerator of the fraction a/b (in other words, a > a*n-b > 0)

Proof. (It's simply a matter of dividing b by a , and choosing the remainder to be positive and less than a .)

Let b = aq + r , with quotient q and remainder r , chosen so that 0 < r < a . (The ' n ' of the theorem is simply the 'ceiling' (in Maple 'ceil') of b/a , which, since b/a = q+r/a , will be q+1 .) Then

a/b-1/n = (an-b)/bn = (a*(q+1)-b)/bn

and the numerator a*n-b = a*(q+1)-b = aq+a-b = aq+a-aq-r = a-r < a , the numerator of a/b . [end of proof]

Note these 'ceil' commands:

> ceil(14/3);

5

> ceil(1/(3/14));

5

> ceil(1/(1/14));

14

>

We want a nice working procedure, and it is easy to make one if one just works up to it from an actual example.

If one started with (e.g.) 3/15 , it would already be a unit fraction ( 1/5 ), and so we want to cover that kind of thing... , but if we started with (e.g.) 171/3391 (which lies between 1/20 and 1/19 ) then we set:

171/3391 = 1/20 + (a bit extra) = 1/n[1] + r[1]

and define r[0] (which we will use in place of a/b ) and n[1] by setting:

> r[0] := 171/3391;
n[1] := ceil(1/r[0]);

r[0] := 171/3391

n[1] := 20

>

We now define r[1] , and from it, n[2] , the denominator of the second unit fraction:

> r[1]:= r[0] - 1/n[1];
n[2]:= ceil(1/r[1]);

r[1] := 29/67820

n[2] := 2339

>

Thus far we then have 171/3391 = 1/20+1/2339+r[2] , and let's (unthinkingly) continue in the obvious manner:

  • define define r[2] , and from it, n[3] , the denominator of the third unit fraction
  • define r[3] , and from it, n[4] , the denominator of the fourth unit fraction
    ... until we find we've come to the end

> r[2]:= r[1] - 1/n[2];
n[3]:= ceil(1/r[2]);

r[2] := 11/158630980

n[3] := 14420999

> r[3]:= r[2] - 1/n[3];
n[4]:= ceil(1/r[3]);

r[3] := 9/2287617203949020

n[4] := 254179689327669

> r[4]:= r[3] - 1/n[4];
n[5]:= ceil(1/r[4]);

r[4] := 1/581465830200392717055551434380

n[5] := 581465830200392717055551434380

> r[5]:= r[4] - 1/n[5];
n[6]:= ceil(1/r[5]);

r[5] := 0

Error, division by zero

>

Thus, the above led to r[0] = 171/3391 = 1/n[1]+1/n[2]+1/n[3]+1/n[4]+1/n[5]+r[5] (with r[5] = 0 , and )

That, clearly, is the point at which we STOP, since r[4] is a unit fraction, and we see that we have 171/3391 is:

> 1/n[1] + 1/n[2] + 1/n[3] + 1/n[4] + 1/n[5];

171/3391

>

We now want Maple to recognise in a general setting that we have reached the stopping point... ; that's where the use of 'while' will come to our rescue. You've already seen that in other circumstances (gcd, binary, etc). It's clear that the appropriate program lines are these (with 'k' starting at 1):

r[k] := r[k-1] - 1/n[k];
n[k+1] := ceil(1/r[k]);

The above single case may be tidied up as follows (first note the use of Maple's (type, integer) command):

> type(8.75, integer);

false

> type(27/4, integer);

false

> type(28/4, integer);

true

> r[0] := 171/3391;
n[1] := ceil(1/r[0]);
for k while type(1/r[k-1], integer) = false do
r[k] := r[k-1] - 1/n[k];
n[k+1] := ceil(1/r[k]);
od;
seq(1/n[m], m=1..k);

r[0] := 171/3391

n[1] := 20

r[1] := 29/67820

n[2] := 2339

r[2] := 11/158630980

n[3] := 14420999

r[3] := 9/2287617203949020

n[4] := 254179689327669

r[4] := 1/581465830200392717055551434380

n[5] := 581465830200392717055551434380

1/20, 1/2339, 1/14420999, 1/254179689327669, 1/5814...

>

If we suppress the semi-colons we will just see the unit fractions:

> r[0] := 171/3391:
n[1] := ceil(1/r[0]):
for k while type(1/r[k-1], integer) = false do
r[k]:= r[k-1] - 1/n[k]:
n[k+1]:= ceil(1/r[k]):
od:
seq(1/n[m], m=1..k);

1/20, 1/2339, 1/14420999, 1/254179689327669, 1/5814...

>

Contact details 

After August 31st 2007 please use the following Gmail address: jbcosgrave at gmail.com


This page was last updated 18 February 2005 15:07:06 -0000