3 ms·
The basic idea to optimize the algorithm (which I got from this [1] SO answer) is to recognize that you only ever update the numerator and denominator of either
by colanderman 3y ago
The basic idea to optimize the algorithm (which I got from this [1] SO answer) is to recognize that you only ever update the numerator and denominator of either bound in a linear fashion. So rather than potentially repeatedly update a given bound, you alternate between the two, and use algebra to determine the multiple by which the bound should be updated.
Regarding the intersection of fractions and music, "just intonation" is the term you want to research.
[1] https://stackoverflow.com/a/45314258 https://stackoverflow.com/a/45314258