fractionizer: Numbers in the range [0.005, 1] as a sum of 2, 3, 4 or 5 unit fractions of special types.

[ #AncientEgypt, language, library, math, mit, music, sound ] [ Propose Tags ]

Inspired by the ancient Egyptian mathematics. See the ideas description and formulation in the related draft paper.

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,,,,,,,,,,,,,,,,,,,,, (info)
Change log
Dependencies base (>=4.13 && <5) [details]
License MIT
Copyright Oleksandr Zhabenko
Author Oleksandr-Zhabenko
Category Math, Music, Sound, Language
Uploaded by OleksandrZhabenko at 2023-10-19T11:31:23Z
Distributions NixOS:
Downloads 553 total (68 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2023-10-19 [all 1 reports]

Readme for fractionizer-

[back to package description]

Mathematical problem solution

Let's consider the problem of decomposition (approximation) of fractions that lie in the range [0.005, 2/3) by the sum of two fractions with 1 in the numerators (so called unit fractions) and, possibly, natural, unequal numbers in the denominators.

We will consider one of the two denominators to be a natural number, smaller than the other number in the denominator, and we will look for such a pair of numbers that, when rounded to natural numbers, will give the minimum absolute error of the resulting approximation. Mathematically, this leads to a problem and its further solution below.

Finally, we can decompose (approximate) the fraction in the range [0.005, 1] by the sum of 2, 3, 4, 5 or more unit fractions, with likely different denominators, just as like in the Egyptian mathematics.

In relation to music, this means that we can create rhythmic patterns using these unit fractions by treating the 1 as the music bar (notes between two consequtive barlines), but this leads to patterns that use irrational (non-dyadic) music meters and together to slightly different (hopefully, not perceptible) from 1 summary duration.

The tests show that there are some numerical instability for the numbers with more digits after the dot. So we use just 3 digits as correct after the dot, but the errors are calculated with respect to the original value with all the digits included.

More is by the link in the package description.

Relation to music rhythm and meter

It can be used to produce music by approximation of the meter. This leads to interesting structures.

It also is directly connected to the irrational time signatures in music.

General error behaviour

Since the version there is a possibility to use the results with absolute error of some sign.

Sum of 4 unit fractions

Since the version there is a function to decompose the fraction into sum of not more than 4 unit fractions. The precision of this operation is rather high, so for many cases we can with enough precision say that every fraction inside the [0.005, 2/3] range can be approximated with the sum of 4 unit fractions. See the function lessErrSimpleDecomp4PG.

Sum of 5 unit fractions

Since the version there is a function to decompose the fraction into sum of not more than 5 unit fractions. The precision of this operation is better than for 4 unit fractions (see above). See the function lessErrSimpleDecomp5PG.

Ancient Egyptian canonical representation

Since the version there is a function to represent the fraction using the canonical ancient Egyptian representation. Can be interesting from the historical perspective.

Since the version there is a new module EgyptianFractions related to this functionality.

Corrections of the incorrect earlier behaviour

In the version there were fixed issues with ErrorImpact > 0 that led earlier to incorrect behaviour.


Since the version there is an approach that preferably the fractions in every number of parts should have the most exact approximation (for 2, 3, 4, 5 unit fractions and probably @2/3@ as as another part).


Author would like to support the foundation Gastrostars and its founder Emma Kok. The founder inspired him to conduct such a research. Besides, the author is grateful to the Hackage website for publishing the Haskell code related to the research.

On the 2023-04-19 there is the founder's namesday, the memory of St. Emma of Lesum or Emma of Stiepel (also known as Hemma and Imma).

On the 2023-04-25 there is St. Apostle and Evangelist Mark's Day, he is a patron of Egypt.

If you would like to share some financial support with the Foundation Gastrostars, please, contact the mentioned foundation using the URL:

Contact Foundation GASTROSTARS


Donation Page