TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Powers of 2 in lexical order yield decibels (2019)

40 pointsby johndcookabout 3 years ago

5 comments

kazinatorabout 3 years ago
The lexicographic sort isn&#x27;t arbitrary:<p><pre><code> 1 = 2^0 &#x2F; 1 ~= 2^0 1.28 = 2^7 &#x2F; 100 ~= 2^7&#x2F;(2^6.6439) ~= 2^(7 - 6.6439) ~= 2^0.3561 1.6 = 2^4 &#x2F; 10 ~= 2^4&#x2F;(2^3.3219) ~= 2^(4 - 3.3219) ~= 2^0.6780 2.00 = 2^1 &#x2F; 1 ~= 2^1 2.56 = 2^8 &#x2F; 100 ~= 2^8&#x2F;(2^6.6439) ~= 2^(8 - 6.6439) ~= 2^1.3561 3.2 = 2^5 &#x2F; 10 ~= 2^5&#x2F;(2^3.3219) ~= 2^(5 - 3.3219) ~= 2^1.6780 4.0 = 2^2 &#x2F; 1 = 2^2 6.4 = 2^6 &#x2F; 10 ~= 2^6&#x2F;(2^3.3219) ~= 2^(6 - 3.3219) ~= 2^2.6780 8.0 = 2^3 &#x2F; 1 = 2^3 </code></pre> Differences between those powers of two:<p><pre><code> 0.3561 0.3219 0.3220 0.3561 0.3219 </code></pre> These increments are close to 1&#x2F;3 which is what you need to divide the musical octave (frequency doubling) into 3 steps:<p><pre><code> 2^(0&#x2F;3) = 1 2^(1&#x2F;3) ~= 1.2599 2^(2&#x2F;3) ~= 1.5784 2^(3&#x2F;3) = 2 </code></pre> There is a well-known relationship that when you divide a frequency factor of 10 into 10 steps, you get approximately three steps per musical octave (frequency doubling). You can see this on any 31 band graphical equalizer. This relies on the &quot;coincidence&quot; seen the other table shown:<p><pre><code> 10^0.0 = 1 10^0.1 ~= 1.2589 10^0.2 ~= 1.5849 10^0.3 = 1.9953 </code></pre> The geometric decade steps provide a close-to-exact doubling also, every three steps.<p>Right, so where did I get those 6.6439 and 3.3219 numbers? Those are just the approximations of log2(100) and log2(10).<p>At the heart of the &quot;lexicographic coincidence&quot; seems to be the observation that these logarithms have .64 and .32 fractional parts, or about 2&#x2F;3 and 1&#x2F;3.<p>So for instance since 100 = 2^(log2(100), we can rewrite 1.28 as 128 &#x2F; 2^(log2(100) which is 2^7&#x2F;2^(log2(100)).<p>So then we have powers of two on top and bottom and can subtract them: 2^(7 - log2(100)), which is where we get 7 - 6.6439 = 0.3561.
评论 #30505873 未加载
contravariantabout 3 years ago
For all intents and purposes multiplying by 2 and multiplying it by a power of 10 until it&#x27;s between 1 and 10 is equivalent to the dynamical system called an irrational rotation.<p>This equivalence isn&#x27;t particularly deep but what is important is that irrational rotations are uniquely ergodic. This means that for all intents and purposes this procedure with <i>any</i> starting point will give a set of points that uniformly cover the unit interval (or in this case 1 to 10, logarithmically).<p>It also helps that 2^10 is a near miss for 10^3.
评论 #30517066 未加载
ColinWrightabout 3 years ago
I think this is a lovely description&#x2F;derivation:<p><a href="https:&#x2F;&#x2F;twitter.com&#x2F;icecolbeveridge&#x2F;status&#x2F;1498410948117340163" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;icecolbeveridge&#x2F;status&#x2F;14984109481173401...</a><p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=VEPRK3O9K2s" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=VEPRK3O9K2s</a>
ccallowayabout 3 years ago
2 is roughly 10^(0.3)<p>Suppose that you take powers of 2, and then divide by 10 if it&#x27;s greater than 10.<p><pre><code> 2^7 ~= (10^(0.3))^7 = 10^2.1 --&gt; 10^(2.1 mod 1) = 10^0.1 2^4 ~= (10^(0.3))^4 = 10^1.2 --&gt; 10^(1.2 mod 1) = 10^0.2 2^1 ~= (10^(0.3))^1 = 10^0.3 --&gt; 10^(0.3 mod 1) = 10^0.3 2^8 ~= (10^(0.3))^8 = 10^2.4 --&gt; 10^(2.4 mod 1) = 10^0.4 ... </code></pre> where the arrow denotes dividing out as many powers of 10 as you can.<p>It seems surprising that the numbers are in the right order but of course it&#x27;s not. Doing lexicographic sort and then dividing out powers of 10 is the same as dividing out powers of 10 and then just doing a numeric sort. So the lex sort is a sort of (accidental) legerdemain here.<p>The powers to which you raise 2 are given by the inverses of 1, 2, 3 etc mod 10. In other words you&#x27;re raising (10^0.3) to a power k, chosen so that the remainder 0.3 * k mod 1 is the multiple of 0.1 that you need.<p><pre><code> 1 &#x2F; 3 mod 10 = 7 2 &#x2F; 3 mod 10 = 4 3 &#x2F; 3 mod 10 = 1 4 &#x2F; 3 mod 10 = 8 ... </code></pre> They are also given by multiples of 7 mod 3.
steerablesafeabout 3 years ago
Does this generalize? Like taking 2^0, 2^1, ..., 2^99 -&gt; lexicographical sort -&gt; putting the decimal point, and then comparing to 10^0.00, 10^0.01, ...?
评论 #30520608 未加载
评论 #30512918 未加载