17 April 2009
In a recent conversation on an online mailing list, the topic arose of drawing a graph showing how many divisors the positive integers have (the graph would start off 1, 2, 2, 3, 2, 4...). Some list members wanted to see the data plotted in 3D. Of course, a 1D dataset isn't that interesting when displayed in 3D—it just becomes another example of chartjunk.
However, it's possible to create a 2D arrangement of the positive integers by organizing them into a spiral. The spiral arrangement is particularly appropriate in the context of counting divisors; if you create a spiral arrangement of positive integers, and colour the primes black and the composites white, you obtain what's called the Ulam spiral, a design that turns out to have some surprising regularities given that it's a depiction of the distribution of primes.
At the same time, I had seen some recent information about two new open-source rendering tools: SunFlow and Luxrender. (I had heard of SunFlow before, but was reminded of it because of the image on the cover of this month's CACM.) I had been meaning to try them out, and this seemed like a good opportunity.
In the image below, each box represents a positive integer. The integers are arranged in a spiral like Ulam's, but each is shown as a box whose height is the number of divisors that integer has. The boxes for the numbers 1, 2 and 3 have red, green and blue spikes sticking out of them (respectively) to orient you. The whole thing is rendered using SunFlow with sexy global illumination and diffuse surfaces. Click on it for a larger version.
The result is kind of cool architecturally, but it has the downside that it's difficult to make out the embedded Ulam spiral (the set of blocks of height 2). In the second image, the height of the block representing integer N is chosen to be 24-d, where d is the number of divisors N has. Thus the primes have height 4 (and are the tallest blocks in the picture), and each additional divisor chops the height of a block in half. The deep pit adjacent to the blue box represents the number 12.
The "white-on-white" look seems to be very popular these days. The effect in this case is definitely a kind of math porn.