<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>math on Simia</title>
    <link>https://simia.net/tags/math/</link>
    <description>Recent content in math on Simia</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Wed, 04 Nov 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://simia.net/tags/math/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Centillion to the power of a centillion, or a googolplex?</title>
      <link>https://simia.net/posts/centillion-to-the-power-of-a-centillion-or-a-googolplex/</link>
      <pubDate>Wed, 04 Nov 2026 00:00:00 +0000</pubDate>
      
      <guid>https://simia.net/posts/centillion-to-the-power-of-a-centillion-or-a-googolplex/</guid>
      <description>Computers are good with numbers.
&amp;ldquo;what&amp;rsquo;s bigger, centillition to the power of a centillion, or a googolplex?&amp;rdquo;
I am glad that Google gives me a richly sourced and well reasoned answer, linked below:
&amp;ldquo;A googolplex is vastly bigger than a centillion to the power of a centillion.&amp;rdquo;
The Math
Centillion: In the short scale, a centillion is 10^303 (a 1 followed by 303 zeros) Centillion to the power of a centillion: (10^303)^(10^303) which is roughly 10^(10^305.</description>
      <content:encoded><![CDATA[<p>Computers are good with numbers.</p>
<p><em>&ldquo;what&rsquo;s bigger, centillition to the power of a centillion, or a
googolplex?&rdquo;</em></p>
<p>I am glad that Google gives me a richly sourced and well reasoned
answer, linked below:</p>
<p>&ldquo;A googolplex is vastly bigger than a centillion to the power of a
centillion.&rdquo;</p>
<p>The Math</p>
<ul>
<li>Centillion: In the short scale, a centillion is 10^303 (a 1 followed
by 303 zeros)</li>
<li>Centillion to the power of a centillion:
<ul>
<li>(10^303)^(10^303) which is roughly 10^(10^305.48).</li>
</ul>
</li>
<li>Googol and Googolplex:
<ul>
<li>A googol is 10^100</li>
<li>A googolplex is 10^googol = 10^(10^100).</li>
</ul>
</li>
</ul>
<p>Why a Googolplex Wins</p>
<ul>
<li>Centillion to the centillion power is roughly 10^(a number with
about 305 digits).</li>
<li>A googolplex is 10^(a number with 101 digits), which is orders of
magnitude larger.</li>
</ul>
<p>To put it in perspective, a googolplex is so large that writing out all
of its zeros in decimal form would require more paper and matter than
exists in the known physical universe.&quot;</p>
<p>Please don&rsquo;t outsource your thinking skills yet.</p>
<ul>
<li><a href="https://www.google.com/search?smstk=ChhuM2tndmFaRTg2V1VHdFhhMWJiUDgraz0QARgAKAA%3D&amp;smstidx=0&amp;q=what%27s+bigger%2C+centillition+to+the+power+of+a+centillion%2C+or+a+googolplex%3F&amp;udm=50&amp;csuir=1&amp;aep=34&amp;kgs=052315759a7d4d76&amp;shem=agpl%2Caiolsbe%2Casdpe%2Casple%2Cepsd1%2Cesd2e%2Crimspwouoe%2Csdpie&amp;shndl=37&amp;shmd=H4sIAAAAAAAA_3WOMU4DMRBFCRVKg0RJZdEgobBOGgqERM8lrNn1MB7J9lj2IG-ZNjfKGXKqbCSgQbT_673_14fr9UcPoI_NjEyEdWMmzMoxsrJko2I0oCnSsRr5NPBbS94YqUtAIiSxRJzf79-Cammv1vbeB2oKytMwSbINoU7huVRJYoGTawEqOg1faczAcSiZHu5-6Isy4gBsn67m_e1-dbw5rdx_bk5A2OxYIXvO9E2Towqel7d2N__J3MJnD9W73cvWl8v8GQfmql4MAQAA&amp;shmds=v1_Ac3VAoze9CwPx56sXQ-RwgfiH8gQJKAXEHLWem1yWI5-iJ4QpQ&amp;source=sh%2Fx%2Faim%2Fm1%2F1&amp;mtid=ny_ratmiGaiH7NYP2pH0SQ">Link to
answer</a></li>
</ul>
]]></content:encoded>
    </item>
    
    <item>
      <title>Additions with unique digits: a tale of puzzling and AI</title>
      <link>https://simia.net/posts/additions-with-unique-digits-a-tale-of-puzzling-and-ai/</link>
      <pubDate>Sun, 24 Aug 2025 00:00:00 +0000</pubDate>
      
      <guid>https://simia.net/posts/additions-with-unique-digits-a-tale-of-puzzling-and-ai/</guid>
      <description>The other day, Markus Krötzsch and I were catching up when one of his kids came in. She told us about a puzzle her math teacher gave her:
How many integer sums are there where the equation uses each digit at most once?
The simplest example is 1+2=3, but 12+47=59 also works. On the other hand, 1+9=10 isn’t a solution because the digit ‘1’ appears twice (in the first number and the sum).</description>
      <content:encoded><![CDATA[<p>The other day, <a href="https://www.korrekt.org/page/Markus_Kr%C3%B6tzsch">Markus
Krötzsch</a> and I were
catching up when one of his kids came in. She told us about a puzzle her
math teacher gave her:</p>
<p><em>How many integer sums are there where the equation uses each digit at
most once?</em></p>
<p>The simplest example is 1+2=3, but 12+47=59 also works. On the other
hand, 1+9=10 isn’t a solution because the digit ‘1’ appears twice (in
the first number and the sum). Markus’s wife Anja was the first of us to
find a solution using three-digit numbers.</p>
<p>I recommend trying to solve it yourself at this point, and then come
back to this post. It is much more fun like that.</p>
<p>Thinking for a moment, we realized there seemed to be quite a few
solutions. But how many? As computer scientists, our immediate thought
was to write a program. First, though, we estimated the complexity of a
brute force approach: if we tried all possible permutations of the
digits 0 to 9, that’s 10! permutations, or about 3.6 million. A
computer should work through that pretty quickly.</p>
<p>I started writing code, and did so even more inefficiently. I included
‘+’ and ‘=’ with the 10 digits, then iterated through all permutations
(and shorter versions) to check for solutions. This ballooned the
candidate pool to an upper bound of 12!x10, or about 5 billion. I knew
there was plenty of room for improvement – the code wasn’t smart – but
it should find all the results. I started running it. At this point, I
was pretty sure this was the kind of problem that with raw computational
power can be solved faster than taking the time to come up with &lsquo;smart&rsquo;
code and better heuristics. <a href="/pages/unique-digits-addition/denny">My full code is
here</a>.</p>
<p>As my code ran, Markus took it as a fun challenge and set out to create
a smarter solution — which, admittedly, shouldn’t be too hard. Instead
of iterating through all possible (and many impossible) equation
strings, he only permuted the numbers, applied a maximum length, and
checked those. <a href="/pages/unique-digits-addition/markus">Markus’
code</a> was impressively fast
– just <strong>4 seconds</strong>! It seemed like we had found the &lsquo;right&rsquo; way to
solve it, using better heuristics. Or had we?</p>
<p>Soon after, my code finished, taking <strong>20 minutes</strong>. We both had the
same answer! (You can find the answer in the linked material, but I am
keeping it out here in case you want to try it out yourself). Having two
different approaches with the same result gave us high confidence in the
answer.</p>
<p>Now, that’s where it could have ended. But the kids were teasing us: it
took us forever to write the code (less than half an hour, but still),
why didn’t we just ask ChatGPT for the answer?</p>
<p>We were pretty convinced there’s no chance ChatGPT would be able to
answer that. So we asked. Markus formulated the prompt (in German, due
to my prodding, so it’s more fun for his kid watching), and ChatGPT
started thinking.</p>
<p>I have never seen it thinking for so long. Almost seven minutes.</p>
<p>We used that time to laugh and joke about it. No way it would figure it
out! We were looking at the steps it was describing. They didn’t seem
too bad. What is a
<a href="https://en.wikipedia.org/wiki/Verbal_arithmetic">cryptarithm</a>? Never
heard of that. We were getting ready to amuse ourselves by watching and
dissecting ChatGPT’s answer.</p>
<p>Boy, we were wrong!</p>
<p>It returned the same number we had found. The answer was great! Not
only that, we looked into the thinking process and found <a href="/pages/unique-digits-addition/chatgpt">the code that
ChatGPT wrote</a>. That code
ran in fractions of a second. It wasn’t just faster; the way it built
the equations, digit by digit, felt like a fundamentally different
strategy than our permutations. Here is <a href="https://chatgpt.com/share/68a8d196-bab8-8007-9a27-192391ce5b07">a link to the full
conversation</a>
(<a href="/pages/unique-digits-addition/chatgpt-conversation">local
archive</a>).
Where my code ran in 20 minutes and Markus’s in 4 seconds, ChatGPT’s
code ran in 60 milliseconds.</p>
<p>We were completely baffled. I searched the Web for this riddle and
solutions, hoping to find indications it had been solved before, that it
was part of the corpus. It might be the case, but we didn’t find it
anywhere. ChatGPT came up with more efficient code, and was faster to
write it. We were deeply impressed, and were left with two questions,
without immediate answers:</p>
<ol>
<li>Given that this is a language model, how did it actually manage to
reach this solution? Why did this work?</li>
<li>Given that ChatGPT can do this, what does this mean? What are the
consequences of having such an ability available? How does this
change things?</li>
</ol>
<p>I kicked off my local <a href="https://ollama.com/">Ollama</a> with <a href="https://openai.com/index/introducing-gpt-oss/">OpenAI’s
recent Open Weight model</a>
(120 billion parameters), using Markus’s prompt. I let it run in the
background while Markus and I kept chatting. It took a long time – tens
of minutes? I didn’t keep track – and we were again confident it
wouldn’t be able to answer the question. This was mostly because my
local Ollama doesn’t have access to a Python interpreter. And indeed, it
answered that there were 45 solutions, very much off from the 1991
solutions we were looking for.</p>
<p>We were a bit relieved. It was getting late, so we called it a night.
Seeing Ollama struggle initially, giving me numbers far off the mark,
actually reinforced my earlier skepticism. It felt like my intuition
about what these models <em>couldn&rsquo;t</em> do was being confirmed – at least for
a moment. I asked the system to list all 45 solutions, and it did. I
noticed that 1+2=3 was missing. I asked if that would be a correct
answer and if it wanted to reconsider its number of solutions, then left
it to run while I went to sleep.</p>
<p>The next day I checked the answer. The model had increased its answer to
124 solutions and wrote new code. It told me I should run that Python
code myself, as a next step. So, again, the wrong answer.</p>
<p>And then I did run the code. From both <a href="/pages/unique-digits-addition/gpt-oss">the first
answer</a>, and <a href="/pages/unique-digits-addition/gpt-oss-v2">the second,
improved answer</a>. If you
actually run the code, both of them result in the correct answer! The
first version took about 20 seconds. The second version then took almost
half an hour to run, but I think that’s only because at this point the
LLM was becoming a bit extra cautious; it even checked for five-digit
numbers, although four-digit numbers were sufficient. I took the LLM’s
last code, made some <a href="/pages/unique-digits-addition/gpt-oss-cleaned">minor clean-up to the
code</a>, and reduced
it to four digits again, and the code gives the correct answer in 20
seconds again. <a href="/pages/unique-digits-addition/gpt-oss-conversation">My complete conversation with gpt-oss is available
here</a>.</p>
<p>Not only that: I would even claim that this cleaned-up code provides the
easiest to read and understand of all the solutions we discussed so far.
It iterates over all possible numbers up to four digits, making sure the
second number is always bigger than the first, gets their sum, checks
the result for digit uniqueness (quite elegantly using a set!), and
counts the solutions. The code is short and, I’d say, elegant.</p>
<p>Markus has also written <a href="/pages/unique-digits-addition/markus-v2">a second
version</a>, which beats the
one by ChatGPT in efficiency, running in only <em>20 milliseconds</em>, and
probably being so fast that the Unix time command doesn&rsquo;t measure it
reliably.</p>
<p>I am impressed by the answers by the models (and by Markus as well). I
think this is a great example of my biggest problem with all of these
models, something I’ve been saying for years: <strong>I cannot explain to
someone else what these models are good at, and what they are not good
at</strong>.</p>
<p>But I thought I had a good intuition myself. That I roughly knew what
kind of questions they would answer well, and which ones I shouldn’t
trust them with. What my experience from this experiment showed me is
that I do not. <strong>I don’t know what the capabilities of these models
are</strong>.</p>
<p>Given the <a href="https://www.heise.de/en/news/OpenAI-and-Google-win-gold-at-the-Math-Olympics-10496839.html">recent news around the math
olympiad</a>,
should I have expected such a result? Was this just a toss-up? Do these
systems now reliably solve problems like these? Would we have trusted
ChatGPt’s result, or would we have been skeptical, if Markus and I
hadn&rsquo;t calculated the result for the riddle ourselves?</p>
<p>I am tempted to rationalize it away, to think that the problem was
simpler than we made it, that my complex code involving permutations was
a red herring, and that’s why the systems could solve it. Maybe that’s
just me dealing with the <a href="https://en.wikipedia.org/wiki/AI_effect">AI
effect</a>, where we downplay AI
achievements once they happen.</p>
<p>Thanks for reading so far. And big thanks to Markus’s kids for bringing
up this riddle, and their math teacher for asking it.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Playing around with Aliquot</title>
      <link>https://simia.net/posts/playing-around-with-aliquot/</link>
      <pubDate>Sun, 28 Jan 2024 00:00:00 +0000</pubDate>
      
      <guid>https://simia.net/posts/playing-around-with-aliquot/</guid>
      <description>Warning! Very technical, not particularly insightful, and overly long post about hacking, discrete mathematics, and rabbit holes. I don&amp;rsquo;t think that anything here is novel, others have done more comprehensive work, and found out more interesting stuff. This is not research, I am just playing around. Ernest Davis is a NYU professor, author of many publications (including “Rebooting AI” with Gary Marcus) and a friend on Facebook. Two days ago he posted about Aliquot sequences, and that it is yet unknown how they behave.</description>
      <content:encoded><![CDATA[<ul>
<li><em>Warning! Very technical, not particularly insightful, and overly
long post about hacking, discrete mathematics, and rabbit holes. I
don&rsquo;t think that anything here is novel, others have done more
comprehensive work, and found out more interesting stuff. This is
not research, I am just playing around.</em></li>
</ul>
<p><a href="https://cs.nyu.edu/~davise/">Ernest Davis</a> is a NYU professor, author
of many publications (including “<a href="http://rebooting.ai/">Rebooting AI</a>”
with <a href="http://garymarcus.com/index.html">Gary Marcus</a>) and a friend on
Facebook. Two days ago he posted about <a href="https://en.wikipedia.org/wiki/Aliquot_sequence">Aliquot
sequences</a>, and that it
is yet unknown how they behave.</p>
<p>What is an Aliquot sequence? Given a number, take all its proper
divisors, and add them up. That’s the next number in the sequence.</p>
<p>It seems that most of these either lead to 0 or end in a repeating
pattern. But it may also be that they just keep on going indefinitely.
We don’t know if there is any starting number for which that is the
case. But the smallest candidate for that is 276.</p>
<p>So far, we know the first 2,145 steps for the Aliquot sequence starting
at 276. That results in a number with 214 digits. We don’t know the
successor of that number.</p>
<p>I was curious. I know that I wouldn’t be able to figure this out
quickly, or, probably ever, because I simply don’t have enough skills in
discrete mathematics (it’s not my field), but I wanted to figure out how
much progress I can make with <em>little</em> effort. So I coded something up.</p>
<p>Anyone who really wanted to make a crack on this problem would probably
choose C. Or, on the other side of the spectrum, Mathematica, but I
don’t have a license and I am lazy. So I chose JavaScript. There were
two hunches for going with JavaScript instead of my usual first
language, Python, which would pay off later, but I will reveal them
later in this post.</p>
<p>So, my first implementation was very naïve (<a href="https://github.com/vrandezo/aliquot/blob/main/aliquot1.js">source
code</a>). The
function that calculates the next step in the Aliquot sequence is
usually called s in the literature, so I kept that name:</p>
<p><code> const divisors = (integer) =&gt; {</code><br>
<code>   const result = []</code><br>
<code>   for(let i = BigInt(1); i &lt; integer; i++) {</code><br>
<code>     if(integer % i == 0) result.push(i)</code><br>
<code>   }</code><br>
<code>   return result</code><br>
<code> }</code></p>
<p><code> const sum = x =&gt; x.reduce(</code><br>
<code>   (partialSum, i) =&gt; partialSum + i, BigInt(0)</code><br>
<code> )</code></p>
<p><code> const s = (integer) =&gt; sum(divisors(integer))</code></p>
<p>I went for BigInt, not integer, because Ernest said that the 2,145th
step had 214 digits, and the standard integer numbers in JavaScript stop
being exact before we reach 16 digits (at 9,007,199,254,740,991, to be
exact), so I chose BigInt, which supports arbitrary long integer
numbers.</p>
<p>The first 30 steps ran each under a second on my one decade old 4 core
Mac occupying one of the cores, reaching 8 digits, but then already the
36th step took longer than a minute - and we only had 10 digits so far.
Worrying about the limits of integers turned out to be a bit
preliminary: With this approach I would probably not reach that limit in
a lifetime.</p>
<p>I dropped BigInt and just used the normal integers (<a href="https://github.com/vrandezo/aliquot/blob/main/aliquot2.js">source
code</a>). That
gave me 10x-40x speedup! Now the first 33 steps were faster than a
second, reaching 9 digits, and it took until the 45th step with 10
digits to be the first one to take longer than a minute. Unsurprisingly,
a constant factor speedup wouldn’t do the trick here, we’re fighting
against an exponential problem after all.</p>
<p>It was time to make the code less naïve (<a href="https://github.com/vrandezo/aliquot/blob/main/aliquot3.js">source
code</a>), and
the first idea was to not check every number smaller than the target
integer whether it divides (line 3 above), but only up to half of the
target integer.</p>
<p><code> const divisors = (integer) =&gt; {</code><br>
<code>   const result = []</code><br>
<code>   const half = integer / 2</code><br>
<code>   for(let i = 1; i &lt;= half; i++) {</code><br>
<code>     if(integer % i == 0) result.push(i)</code><br>
<code>   }</code><br>
<code>   return result</code><br>
<code> }</code></p>
<p>Tiny change. And exactly the expected impact: it ran double as fast. Now
the first 34 steps ran under one second each (9 digits), and the first
one to take longer than a minute was the 48th step (11 digits).</p>
<p>Checking until half of the target seemed still excessive. After all, for
factorization we only need to check until the square root. That should
be a more than constant speedup. And once we have all the factors, we
should be able to quickly reconstruct all the divisors. Now this is the
point where I have to admit that I have a cold or something, and the
code for creating the divisors from the factors is probably overly
convoluted and slow, but you know what? It doesn’t matter. The only
thing that matters will be the speed of the factorization.</p>
<p>So my next step (<a href="https://github.com/vrandezo/aliquot/blob/main/aliquot4.js">source
code</a>) was a
combination of a still quite naïve approach to factorization, with
another function that recreates all the divisors.</p>
<p><code> const factorize = (integer) =&gt; {</code><br>
<code>   const result = [ 1 ]</code><br>
<code>   let i = 2</code><br>
<code>   let product = 1</code><br>
<code>   let rest = integer</code><br>
<code>   let limit = Math.ceil(Math.sqrt(integer))</code><br>
<code>   while (i &lt;= limit) {</code><br>
<code>     if (rest % i == 0) {</code><br>
<code>       result.push(i)</code><br>
<code>       product *= i</code><br>
<code>       rest = integer / product</code><br>
<code>       limit = Math.ceil(Math.sqrt(rest))</code><br>
<code>     } else {</code><br>
<code>       i++</code><br>
<code>     }</code><br>
<code>   }</code><br>
<code>   result.push(rest)</code><br>
<code>   return result</code><br>
<code> }</code></p>
<p><code> const divisors = (integer) =&gt; {</code><br>
<code>   const result = [ 1 ]</code><br>
<code>   const inner = (integer, list) =&gt; {</code><br>
<code>     result.push(integer)</code><br>
<code>     if (list.length === 0) {</code><br>
<code>       return [ integer ]</code><br>
<code>     }</code><br>
<code>     const in_results = [ integer ]</code><br>
<code>     const in_factors = inner(list[0], list.slice(1))</code><br>
<code>     for (const f of in_factors) {</code><br>
<code>       result.push(integer*f)</code><br>
<code>       result.push(f)</code><br>
<code>       in_results.push(integer*f)</code><br>
<code>       in_results.push(f)</code><br>
<code>     }</code><br>
<code>     return in_results</code><br>
<code>   }</code><br>
<code>   const list = factorize(integer)</code><br>
<code>   inner(list[0], list.slice(1))</code><br>
<code>   const im = [...new Set(result)].sort((a, b) =&gt; a - b)</code><br>
<code>   return im.slice(0, im.length-1)</code><br>
<code> }</code></p>
<p>That made a big difference! The first 102 steps all were faster than a
second, reaching 20 digits! That’s more than 100x speedup! And then,
after step 116, the thing crashed.</p>
<p>Remember, integer only does well until 16 digits. The numbers were just
too big for the standard integer type. So, back to BigInt. The
availability of BigInt in JavaScript was my first hunch for choosing
JavaScript (although that would have worked just fine in Python 3 as
well). And that led to two surprises.</p>
<p>First, sorting arrays with BigInts is different from sorting arrays with
integers. Well, I find already sorting arrays of integers a bit weird in
JavaScript. If you don’t specify otherwise it sorts numbers
lexicographically, instead of by value:</p>
<p><code> [ 10, 2, 1 ].sort() == [ 1, 10, 2 ]</code></p>
<p>You need to provide a custom sorting function in order to sort the
numbers by value, e.g.</p>
<p><code> [ 10, 2, 1 ].sort((a, b) =&gt; a-b) == [ 1, 2, 10 ]</code></p>
<p>The same custom sorting functions won’t work for BigInt, though. The
custom function for sorting requires an integer result, not a BigInt. We
can write something like this:</p>
<p><code> .sort((a, b) =&gt; (a &lt; b)?-1:((a &gt; b)?1:0))</code></p>
<p>The second surprise was that BigInt doesn’t have a square root function
in the standard library. So I need to write one. Well, Newton is quickly
implemented, or copy and pasted (<a href="https://github.com/vrandezo/aliquot/blob/main/aliquot5.js">source
code</a>).</p>
<p>Now, with switching to BigInt, we get the expected slowdown. The first
92 steps run faster than a second, reaching 19 digits, and then the
first step to take longer than a minute is step 119, with 22 digits.</p>
<p>Also, the actual sequences started indeed diverging, due to the
inaccuracy of large JavaScript integer: step 83 resulted in
23,762,659,088,671,304 using integers, but 23,762,659,088,671,300 using
BigInt. And whereas that looks like a tiny difference on only the last
digit, the number for the 84th step showed already what a big difference
that makes: 20,792,326,702,587,410 with integers, and
35,168,735,451,235,260 with BigInt. The two sequences went entirely off.</p>
<p>What was also very evident is that at this point some numbers took a
long time, and others were very quick. This is what you would expect
from a more sophisticated approach to factorization, that it depends on
the number and size of the factors. For example, calculating step 126
required to factorize the number 169,306,878,754,562,576,009,556,
leading to 282,178,131,257,604,293,349,484, and that took more than 2
hours with that script on my machine. But then in Step 128 the result
552,686,316,482,422,494,409,324 was calculated from
346,582,424,991,772,739,637,140 in less than a second.</p>
<p>At that point I also started taking some of the numbers, and googled
them, surfacing <a href="https://hyperion64.hatenadiary.org/entry/20130728/p1">a Japanese blog
post</a> from ten
years ago that posted the first 492 numbers, and also confirming that
the 450th of these numbers corresponds to a published source. I compared
the list with my numbers and was happy to see they corresponded so far.
But I guesstimated I would not in a lifetime reach 492 steps, never mind
the actual 2,145.</p>
<p>But that’s OK. Some things just need to be let rest.</p>
<p>That’s also when I realized that I was overly optimistic because I
simply misread the number of steps that have been already calculated
when reading the original post: I thought it was about 200-something
steps, not 2,000-something steps. Or else I would have never started
this. But now, thanks to the sunk cost fallacy, I wanted to push it just
a bit further.</p>
<p>I took the biggest number that was posted on that blog post,
111,953,269,160,850,453,359,599,437,882,515,033,017,844,320,410,912, and
let the algorithm work on that. No point in calculating steps 129, which
is how far I have come, through step 492, if someone else already did
that work.</p>
<p>While the computer was computing, I leisurely looked for libraries for
fast factorization, but I told myself that no way am I going to install
some scientific C library for this. And indeed, I found a few, such as
the <a href="https://sourceforge.net/projects/msieve/">msieve project</a>.
Unsurprising, it was in C. But I also found a Website, <a href="https://www.cryptool.org/en/cto/msieve">CrypTool-Online
with msieve</a> on the Web (that’s
pretty much one of the use cases I hope
<a href="https://www.wikifunctions.org/">Wikifunctions</a> will also support rather
soonish). And there, I could not only run the numbers I already
calculated locally, getting results in subsecond speed which took
minutes and hours on my machine, but also the largest number from the
Japanese website was factorized in seconds.</p>
<p>That just shows how much better a good library is than my naïve
approach. I was slightly annoyed and challenged by the fact how much
faster it is. Probably also runs on some fast machine in the cloud.
Pretty brave to put a site like that up, and potentially have other
people profit from the factorization of large numbers for, e.g. Bitcoin
mining on your hardware.</p>
<p>The site is fortunately Open Source, and when I <a href="https://github.com/cryptool-org/cto">checked the source
code</a> I was surprised, delighted,
and I understood why they would make it available through a Website:
they <strong>don’t</strong> factorize the number in the cloud, but on the edge, in
your browser! If someone uses a lot of resources, they don’t mind: it’s
their own resources!</p>
<p>They took the msieve C library and compiled it to WebAssembly. And now I
was intrigued. That’s something that’s useful for my work too, to better
understand WebAssembly, as we use that in Wikifunctions too, although
for now server side. So I rationalized, why not see if I can get that
run on Node.</p>
<p>It was a bit of guessing and hacking. The JavaScript binding was written
to be used in the browser, and the binary was supposed to be loaded
through fetch. I guessed a few modifications, replacing fetch with
Node’s FS, and managed to run it in Node. The hacks are terrible, but
again, it doesn’t really matter as long as the factorization would speed
up.</p>
<p>And after a bit of trying and experimenting, I got it running (<a href="https://github.com/vrandezo/aliquot/blob/main/aliquot6.js">source
code</a>). And
that was my second hunch for choosing JavaScript: it had a great
integration for using WebAssembly, and I figured it might come in handy
to replace the JavaScript based solution. And now indeed, the
factorization was happening in WebAssembly. I didn’t need to install any
C libraries, no special environments, no nothing. I just could run Node,
and it worked. I am absolutely positive there are is cleaner code out
there, and I am sure I mismanaged that code terribly, but I got it to
run. At the first run I found that it added an overhead of 4-5
milliseconds on each step, making the first few steps much slower than
with pure JavaScript. That was a moment of disappointment.</p>
<p>But then: the first 129 steps, which I was waiting hours and hours to
run, zoomed by before I could even look. Less than a minute, and all the
492 steps published on the Japanese blog post were done, allowing me to
use them for reference and compare for correctness so far. The overhead
was irrelevant, even across the 2,000 steps the overhead wouldn’t amount
to more than 10 seconds.</p>
<p>The first step that took longer than a second was step 596, working on a
58 digit number. All the first 595 steps took less than a second each.
The first step that took more than a minute, was step 751, a 76 digit
number, taking 62 seconds, factorizing
3,846,326,269,123,604,249,534,537,245,589,642,779,527,836,356,985,238,147,044,691,944,551,978,095,188.
The next step was done in 33 milliseconds.</p>
<p>The first 822 steps took an hour. Step 856 was reached after two hours,
so that’s another 34 steps in the second hour. Unexpectedly, things
slowed down again. Using faster machines, modern architectures, GPUs,
TPUs, potentially better algorithms, such as
<a href="https://cado-nfs.gitlabpages.inria.fr/">CADO-NFS</a> or
<a href="https://www.math.ttu.edu/~cmonico/software/ggnfs/">GGNFS</a>, all of that
could speed that up by a lot, but I am happy how far I’ve gotten with,
uhm, <em>little</em> effort. After 10 hours, we had 943 steps and a 92 digit
number, 20 hours to get to step 978 and 95 digits. My goal was to reach
step 1,000, and then publish this post and call it a day. By then, a
number of steps already took more than an hour to compute. I hit step
1000 after about 28 and a half hours, a 96 digit number:
162,153,732,827,197,136,033,622,501,266,547,937,307,383,348,339,794,415,105,550,785,151,682,352,044,744,095,241,669,373,141,578.</p>
<p>I rationalize this all through “I had fun” and “I learned something
about JavaScript, Node, and WebAssembly that will be useful for my job
too”. But really, it was just one of these rabbit holes that I love to
dive in. And if you read this post so far, you seem to be similarly
inclined. Thanks for reading, and I hope I didn’t steal too much of your
time.</p>
<p>I also <a href="https://github.com/vrandezo/aliquot/blob/main/results.txt">posted a list of all the
numbers</a> I
calculated so far, because I couldn’t find that list on the Web, and I
found the list I found helpful. Maybe it will be useful for something. I
doubt it. <em>(P.S.: the list was already on the Web, I just wasn&rsquo;t looking
careful enough. Both, <a href="https://oeis.org/A008892">OEIS</a> and
<a href="http://factordb.com/sequences.php?se=1&amp;aq=276&amp;action=all&amp;fr=0&amp;to=100">FactorDB</a>
have the full list.)</em></p>
<p>I don’t think any of the lessons here are surprising:</p>
<ul>
<li>for many problems a naïve algorithm will take you to a good start,
and might be sufficient</li>
<li>but never fight against an exponential algorithm that gets big
enough, with constant speedups such as faster hardware. It’s a
losing proposition</li>
<li>But hey, first wait if it gets big enough! Many problems with
exponential complexity are perfectly solvable with naïve approaches
if the problem stays small enough</li>
<li>better algorithms really make a difference</li>
<li>use existing libraries!</li>
<li>advancing research is hard</li>
<li>WebAssembly is really cool and you should learn more about it</li>
<li>the state of WebAssembly out there can still be wacky, and sometimes
you need to hack around to get things to work</li>
</ul>
<p>In the meantime I played a bit with other numbers (thanks to having a 4
core computer!), and I will wager one ambitious hypothesis: <strong>if 276
diverges, so does 276,276, 276,276,276, 276,276,276,276, etc., all the
way to 276,276,276,276,276,276,276,276,276, i.e. 9 times &ldquo;276&rdquo;.</strong></p>
<p>I know that 10 times &ldquo;276&rdquo; converges after 300 steps, but I have tested
all the other &ldquo;lexical multiples&rdquo; of 276, and reached 70 digit numbers
after hundreds of steps. For 276,276 I pushed it further, reaching 96
digits at step 640. (And for at least 276,276 we should already know the
current best answer, because the Wikipedia article states that all the
numbers under one million have been calculated, and only about 9,000
have an unclear fate. We should be able to check if 276,276 is one of
those, which I didn&rsquo;t come around to yet).</p>
<p>Again, this is not research, but just fooling around. If you want actual
systematic research, the <a href="https://en.wikipedia.org/wiki/Aliquot_sequence">Wikipedia
article</a> has a number of
great links.</p>
<p>Thank you for reading so far!</p>
<p>P.S.: Now that I played around, I started following some of the links,
and wow, there&rsquo;s a whole community with great tools and infrastructure
having fun about Aliquot sequences and prime numbers doing this for
decades. This is extremely fascinating.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Double copy in gravity</title>
      <link>https://simia.net/posts/double-copy-in-gravity/</link>
      <pubDate>Sat, 15 May 2021 00:00:00 +0000</pubDate>
      
      <guid>https://simia.net/posts/double-copy-in-gravity/</guid>
      <description>When I was younger, I understood these theories much better. Today I read them like a fascinated, but a bit distant bystander.
But it is terribly interesting. What does turning physics into math mean? When we find a mathematical shortcut that works but we don&amp;rsquo;t understand - is this real? What is the relation between mathematical formulas and reality? And will we finally understand gravity some day?
It was an interesting article, but I am not sure I understood it all.</description>
      <content:encoded><![CDATA[<p>When I was younger, I understood these theories much better. Today I
read them like a fascinated, but a bit distant bystander.</p>
<p>But it is terribly interesting. What does turning physics into math
mean? When we find a mathematical shortcut that works but we don&rsquo;t
understand - is this real? What is the relation between mathematical
formulas and reality? And will we finally understand gravity some day?</p>
<p>It was an interesting article, but I am not sure I understood it all. I
guess, I&rsquo;m getting old. Or just too specialized.</p>
<ul>
<li><a href="https://www.quantamagazine.org/how-gravity-is-a-double-copy-of-other-forces-20210504/">https://www.quantamagazine.org/how-gravity-is-a-double-copy-of-other-forces-20210504/</a></li>
</ul>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
