math-to-play-with  ...Because when we play, we learn!

The Ulam spiral of primes

    The Ulam spiral is a graphical layout of prime numbers, credited to the Polish/American mathematician Stanislav Ulam who discovered it in 1963.

    Start at the center of a flat, two-dimensional surface; e.g., a sheet of paper or a computer screen, with the number 1. Next, form an outward spiral using one step for each next whole number (in Figure 2 we go counter-clockwise) and highlight the prime numbers.

    What will you see?

    • When laid out in a 90°-angled spiral like so:

      17 16 15 14 13
      18  5  4  3 12
      19  6  1  2 11
      20  7  8  9 10
      21 22 23 24 25 etc.
      
      the result is the Ulam spiral of primes (see also Figure 1).

      In Figure 1 it is pretty much impossible to see a spiral pattern especially since we do not see the actual numbers displayed with their values, What we do see, however, is that although the distribution of prime numbers on smaller scales is unpredictable, the pattern in the Ulam spiral shows quasi-regular patterns of straight lines of primes.

    • When laid out in polar coordinates with a rotation of 1 radian between numbers (Figure 2) —refer to the start of this video for a nice explanation of polar coordinates— the results is several distinct Archimedean spirals of primes.

      We would more or less expect these 'spiral' arms for numbers in general because of the way we have laid them out; i.e., subsequent numbers are rotated 1 radian and one full rotation = 2π ≈ 6 radian. Hence, the difference of 6 between numbers on the spiral arms. But again, given the unpredictability of primes, it is interesting to see them showing up in spirals as well.

    You can play with this below.

      Zoom factor:

      Figure 1: Ulam spiral of primes
      (primes are shown as red dots; non-primes are not shown)
         
      Figure 2: Archimedean spirals of primes

         

About math-to-play-withContactDisclaimersLicense