18 comments

  • kurlberg4 minutes ago
    There is a cute argument (I think it is due to Erdos) that, asymptotically, 0% of the integers in [0,n^2] appears in the &quot;n by n multiplication table&quot;:<p>By Erdos-Kac, almost all integers of size about n^2 have about log(log(n^2)) ~ log(log(n)) prime factors. However, almost all integers in the multiplication table have about 2*log(log(n)) prime factors.<p>Kevin Ford gets much more precise asymptotic estimates.
  • Dylan168073 hours ago
    &gt; I find it interesting to consider that if you pick a value at random, it will usually fail! That is, most 64-bit integers cannot be written as the product of two 32-bit integers.<p>While I find the 17% number interesting to think about, &quot;most&quot; is far less interesting. Multiplication doesn&#x27;t care about order so you&#x27;re instantly cutting 2^64 possibilities down to about 2^63. That&#x27;s a hair&#x27;s breadth away from &quot;most&quot; already, and considering even a tiny amount of overlapping results gets you there.<p>What gets interesting is actually trying to quantify the overlapping results.
    • ot2 hours ago
      Yeah the number sounds a lot less impressive if you say that you only get 2^61.44 integers out of 2^64. In other words, a 4% entropy loss.<p>Information quantities are more meaningfully expressed in number of bits.
    • FabHK2 hours ago
      &gt; Multiplication doesn&#x27;t care about order so you&#x27;re instantly cutting 2^64 possibilities down to about 2^63.<p>Not sure I understand.<p>Adding two 32 bit integers takes you to 33 bit integers. (1111 + 1111 = 11110).<p>Addition doesn&#x27;t care about order, so you&#x27;re instantly cutting 2^33 possibilities down to 2^32. Or so is your argument. But in reality you can reach nearly all of those 2^33 numbers.
      • sdenton42 hours ago
        Concatenating arbitrary 32 bit ints covers all possible 64 bit ints. So the space of all pairs of 32 bit ints is in bijection with 64 bit ints.<p>Commutativity introduces a relation on pairs of 32 bit ints (a,b) ~ (b,a), which accounts for one bit of information. Thus, at most 50% of 64bit ints show up as products of 32 bit ints.
        • FabHK1 hour ago
          Ah, fair enough, thanks everyone. So basically the argument is if that we have a deterministic function taking a pair (x_1, x_2) with x_i in X with |X| = M, then the function can produce at most M^2 outputs. And knowing that the function is symmetric cuts it down to M(M+1)&#x2F;2. (Which is still far bigger than the 2M in my addition analogy.) Cheers.
        • Dylan168071 hour ago
          Except the perfect squares don&#x27;t reduce by half, so it&#x27;s not <i>quite</i> 50% but it&#x27;s very close.
      • topaz02 hours ago
        The 2^64 in gps argument comes from the number of pairs of 32 bit numbers, not from the upper bound of multiplying two 32 bit numbers. So for the addition case the symmetry argument is still only good enough to get you down to about 2^63, which doesn&#x27;t help you at all because you have much stronger information from the upper bound.
      • klodolph2 hours ago
        Addition in this case is cutting from 2^64 to 2^33-1.<p>The 2^64 number is the number of inputs. For an operation which is commutative, you expect the outputs to be 2^63+2^32 or smaller, since you’ve introduced symmetry.
    • danbruc3 hours ago
      All the primes above 2^32 are out, but that accounts for only two point something percent.
      • topaz01 hour ago
        But also all of their multiples. I suspect that those account for the vast majority.
    • HarHarVeryFunny1 hour ago
      Why does order matter?<p>Whether a 64-bit number can be written as the product of two 32-bit ones depends only on the prime factors of the 64-bit number - it&#x27;s a property of the number itself, and apparently 17% of 64-bit numbers have this property.
      • orlp54 minutes ago
        The input space is 32 + 32 = 64 bits. The output space is 64 bits. So the best you can do is an 1-to-1 mapping.<p>However, since a * b = b * a, our input space has a lot of duplicate outputs. So from this alone you can conclude roughly half of the output space must be uncovered by any input pair, simply because there aren&#x27;t enough input pairs.
        • HarHarVeryFunny3 minutes ago
          OK - thanks. I must have misunderstood what the other poster was saying, since I thought they were objecting to the &quot;most&quot; characterization.
    • PaulHoule3 hours ago
      ... or just considering the even numbers almost all of them are 2 x N where N&gt;2^32 and that gets you to within a hair of &quot;most&quot; and if you add in the odd thirds for which the same is true you get a bound of 2&#x2F;3 - epsilon.
      • topaz02 hours ago
        It&#x27;s a bit more subtle than that -- most n&gt;2^32 are not prime in which case 2 x n has more factorizations you would have to check.<p>(Just by way of example, for n=2^33, 2n=2^34 but also =2^17*2^17)
    • adgjlsfhk13 hours ago
      A lot of the remaining is multiples of 4, which you can either get from having a 2 in both factors or a 4 in one (multiples of 9 are similar).
    • thaumasiotes2 hours ago
      &gt; While I find the 17% number interesting to think about, &quot;most&quot; is far less interesting. Multiplication doesn&#x27;t care about order so you&#x27;re instantly cutting 2^64 possibilities down to about 2^63. That&#x27;s a hair&#x27;s breadth away from &quot;most&quot; already<p>It&#x27;s much worse than that. It&#x27;s difficult for a 64-bit product to have the high bit set if the multiplicands are both no larger than 32 bits.
  • _alternator_20 minutes ago
    &gt; You might be able to come up with a more efficient algorithm.<p>Challenge accepted. Suppose we want to know the answer to 3 decimal places (so we&#x27;d match the headline). And suppose I allow my algorithm to be wrong one in a thousand times (&quot;probably approximately correct&quot;).<p>Then sample some constant number C of random 64 bit integers. Run the following algorithm which separates each random sample into one of three classes: Y (has 32 but factors), N (does not have 32 bit factors), U (unknown).<p>Check if prime using probabilistic miller rabin. (Error prob goes to zero exponentially fast). If prime, return N. If it&#x27;s not a prime, then run T steps of pollard rho to determine whether the number has 32 but factors; return Y,N, or U depending of the factors found up to step T.<p>The key observation is that T can be chosen to make the UNKNOWN class very small (with high probability), and so our estimate should rapidly converge to 17%Y, 83%N, ~0.001%U<p>For fixed error tolerance, this would run in roughly a constant number of iterations, independent of N.
  • jandrese37 minutes ago
    This just seems like an expansion of prime numbers to includes factors in the 2^33+ range. Basically you&#x27;re calculating if a number is prime but stopping the check when the factors go above 2^32.
    • intuitionist19 minutes ago
      Having a prime factor greater than 2^32 accounts for about 80% of the 64-bit integers that can’t be expressed as a product of 32-bit integers. But it’s not the only way; you can also have three prime factors in the range (2^16, 2^32), for instance.
    • Taek31 minutes ago
      Well, technically yes, but &#x27;stopping the factors at 32 bits&#x27; is a plenty interesting constraint because it excludes all 64 bit composite numbers that have at least one factor above 2^32.<p>You have to redo the math to make the constraint work.
  • tobz10001 hour ago
    &gt; the proportion of all 2n-bit values that can be generated by the product of two n-bit values goes to zero as n becomes large. This means that if you have, say, 10000000-bit integers multiplying 10000000-bit integers, you’d expect relatively few 100000000000000-bit integers to be produced.<p>That should be &quot;relatively few 20000000-bit integers&quot;, right?
    • tgv1 hour ago
      Perhaps it&#x27;s binary.
  • henry20233 hours ago
    There are about 4 billion 64 bit integers for each 32 bit integer.<p>The chance of a random 64 bit integer being a 32 bit integer is 0.0000000233 %<p>The chance of a random 64 bit integer being a product of two 32 bit integers is 17%<p>Nice
    • HWR_143 hours ago
      There are about 18.446 quintillion more 64-bit integers than 32-bit integers.
      • adrian_b2 hours ago
        True, but there are as many 64-bit integers as pairs of 32-bit integers.<p>Therefore the fact that relatively few 64-bit numbers are products of 32-bit integers means that a lot of pairs of 32-bit integers give by multiplication the same product.
      • moefh2 hours ago
        I think they meant to write &quot;There are about 4 billion <i>TIMES</i> more 64 bit integers than 32 bit integers&quot;.
        • henry20232 hours ago
          Indeed, edited the mistake
      • bo10241 hour ago
        There are about 2^64 more 64-bit integers than 32-bit integers.
    • layer83 hours ago
      The chance of a random 64-bit integer matching some pair of 32-bit integers is a 100%, though.
    • brookst2 hours ago
      Or, the odds of a random 64-bit integer being a 32-bit integer are the same as you or me guessing a random 32 bit integer.
    • rao-v2 hours ago
      Wonder what the limit is as you add more 32 bit integers to the product. Just the primes over 32 bit?
      • thaumasiotes2 hours ago
        If you&#x27;re allowed to multiply as many 32-bit numbers as you want, the only numbers you won&#x27;t be able to achieve by so doing are those with any prime factor larger than 2^32.<p>This is more than just the prime numbers. For example, a 41-bit prime can be multiplied by 16 and it will still fit into 64 bits.
        • nyeah1 hour ago
          What are you assuming about overflow? Three 32-bit numbers multiply out to 96 bits.
  • pants23 hours ago
    I dream of a future where all 64-bit integers are products of 32-bit integers. Together, we can change math for the better.
    • jerf2 hours ago
      Indeed, but justice requires that we recursively continue all the way to the base case, until all 32-bit integers are products of 16-bit integers, all 16-bit integers are products of 8-bit integers, all 8-bit integers are products of 4-bit integers, all 4-bit integers are products of 2-bit integers, and all 2-bit integers are products of 1-bit integers. Only when we have reach all the way down that list to the very, very smallest of the numbers around us and brought justice to them will the future be able to arrive. I literally can not wait for that day.
      • order-matters2 hours ago
        Enough of this divided binary world, we are all one
    • jihadjihad3 hours ago
      Why stop there? We can dream of a future where math is bent to our will [0] for the betterment of all mankind!<p>0: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Indiana_pi_bill" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Indiana_pi_bill</a>
    • dvh3 hours ago
      1 + 1 = 3 (for sufficiently large values of 1)
      • Taek28 minutes ago
        I thought you were making a joke but if we&#x27;re assuming that the 1&#x27;s are being rounded or truncated before the final value cake is produced I guess you are right.
      • sshine2 hours ago
        It helps if you take the limit of 1 going towards 1.5.<p>Most 1s won&#x27;t go towards 1.5, but sometimes you&#x27;re lucky.
    • brookst2 hours ago
      There should be a law!
    • kleiba23 hours ago
      I upvoted you, not because I think your joke is particularly great, but I hate that HN has this tendency to downvote comments that are clearly meant as a humorous contribution. And I get it, no-one wants HN to turn into Reddit. I also understand that not every joke lands. But I just think it&#x27;s unnecessary to downvote, you could simply <i>ignore</i>.
      • zamadatix3 hours ago
        &quot;Ignore&quot; is one of those things that sounds like it&#x27;s a neutral choice but really isn&#x27;t in practice - it&#x27;s still just saying &quot;can only ever be positively pressured&quot;. IMO people shouldn&#x27;t go as far as flag though, at the very least, and if it&#x27;s already at the bottom of the sort there is no sense dumping on it further.<p>My current comment itself, for instance, also doesn&#x27;t really add anything to the discussion about the article and I&#x27;d have no expectation people leave it from going negative. Maybe the will, maybe they won&#x27;t, but there is no reason to expect they should in principle of me loving tangents :D.
  • kingstnap1 hour ago
    This is something I had thought about some time back where I was thinking about the feasibility of somehow using the upper and lower registers inside a multiplier as general purpose storage for fun &#x2F; seeing if you could make them more compact.<p>Anyway here is a fun pattern you get when you multiply 8 bit unsigned integers. Not all pairs of (upper bits, lower bits) are reachable, and it has a lot of distinct patterns.<p><a href="https:&#x2F;&#x2F;i.imgur.com&#x2F;Gb3HDR0.png" rel="nofollow">https:&#x2F;&#x2F;i.imgur.com&#x2F;Gb3HDR0.png</a><p>(Should I host the image on GitHub Gists so it doesn&#x27;t vanish?)
  • da_chicken3 hours ago
    This feels like a underlying property that contributes to of Benford&#x27;s Law[0]. That is, most numbers we measure and record are the results of various independent (addition) and dependent (multiplication) factors stacking together, and we observe this property in the distribution of them.<p>[0]: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Benford%27s_law" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Benford%27s_law</a>
  • fogleman23 minutes ago
    Does it actually matter for hash uniformity, though?
  • cobbzilla1 hour ago
    I must be missing something. Aren’t ~50% of 64-bit integers the product of the number 2 and another 32-bit integer?
    • slazaro1 hour ago
      Going from 32 bits to 64 bits doesn&#x27;t double the range (that would be adding 1 bit), it squares the range.
    • mplanchard1 hour ago
      I don’t think so, because that only gets you up to 2x2^32, which is nowhere near halfway to 2^64
    • jlarocco58 minutes ago
      No. 50% of them are the product of 2 and a 63-bit integer.
  • PunchyHamster1 hour ago
    Well, that is entirely not surprising. Pretty sure people writing not terrible hash functions figured it decades ago
  • crest2 hours ago
    So you&#x27;re better of using a 8x8-&gt;16 widening multiplication SIMD instruction or even just a multi register TBL&#x2F;TBX instruction?
  • MarkusQ3 hours ago
    If this seems counterintuitive, consider that only about a third of the two-digit numbers ({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, 28, 30, 32, 35, 36, 40, 42, 45, 48, 49, 54, 56, 63, 64, 72, 81}) can be written as the product of two one-digit numbers.
    • childintime2 hours ago
      where is the graph and the theorem for integers of n bits, with n going to infinity?
      • mswphd2 hours ago
        The math was linked in the article<p><a href="https:&#x2F;&#x2F;arxiv.org&#x2F;pdf&#x2F;1908.04251" rel="nofollow">https:&#x2F;&#x2F;arxiv.org&#x2F;pdf&#x2F;1908.04251</a>
  • nicechianti2 hours ago
    [dead]