lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Why you don't really want] irrational tuplets [nor CF approximations]


From: Alexander Kobel
Subject: [Why you don't really want] irrational tuplets [nor CF approximations]
Date: Tue, 8 Nov 2016 21:00:35 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 2016-11-08 18:15, Hans Åberg wrote:
I gave an example of a true irrational time signature [1]. The code
is actually written in 12/8, with a MIDI approximation in 19/8. Such
meter approximations can be obtained using continued fractions
convergents [2]. For the rendering, it suffices with an approximation
that separates and orders the notes that occur at different times.
For the MIDI it suffices to be within its accuracy, or alternatively,
what performers might do.

Seriously: I'm a half-mathematician by training (probably a lesser one than Hans, but still), and work all day in computer algebra; I share the admiration for the elegance of CF approximations. But for this purpose, I really think you should use dyadic fractions, say, 2^-20. Or at least fractions with a common denominator, say, 1,000,000, if you're anything like other humans and consider them easier to parse.

Let's do the math: For rendering purposes, with a resolution of 1200 dpi, you have 12,000 dots on a 10-inch wide paper. You will not be able to distinguish any resolution higher than 1 ppm for sure. For musical purposes (by a computer, not a human - that's out of question), assume 192 kHz frequency at max. Account for Shannon's theorem and aliasing issues, that makes it 384 kHz. With a reasonable base tempo of one quarter per second, that's appx. (1.6e6 s)^-1 max resolution. Granted: that's slightly more than what you get with a million as a denominator, but just. (BTW: I didn't check the above calculations; probably the numbers are off, because the mathematician in me ignores constant factors, and the computer scientist in me doesn't do calculations in his head... ;-))

There are multiple benefits: No blow-up of the least common multiple of the denominators - it simply stays the same. No issues with accuracy - fits well to machine integers used for the rationals. In particular, no crashes because you suddenly exceed the implementation-based range. Even exactly convertible to hardware floats (double prec) if you use dyadic fractions. Finally: Significantly easier calculations for you to do to figure out the right durations to sync at barlines.

Of course, it's much more satisfying to do the "right thing" (tm). But that's using the exact values. Exact computation is non-trivial even for arbitrarily large rationals. Exact calculations with algebraic numbers are possible, but not quite around the corner (that's good; otherwise, I'd need a new job). Exact representation and /some/ operations with an /a priori/ chosen subset of /some/ of the transcendentals is just possible, but a long way around several corners (that's even better, just in case I need a new job at some point). Exact computation with arbitrary real numbers is infeasible. And that's not a "today's computers are not fast enough". It's simply fundamentally impossible.

And the most interesting numbers for a creative mind will be those that are the most complicated to capture and implement. Which reminds me of the phonograph in Hofstadter's wonderful "Gödel, Escher, Bach - an Eternal Golden Braid". If you didn't read it yet, here's a hint for a christmas gift...

On a side note, CF approximations are optimal in the sense that they give the best approximation with numerator and denominator that do not exceed any given bound. But they are /not/ better than dyadic approximations if your measure is the asymptotic growth of the worst-case bitlength of numerator and denominator that is required to achieve a certain approximation quality.


Cheers,
Alexander



reply via email to

[Prev in Thread] Current Thread [Next in Thread]