4

There are 4 attached pictures of Ulam spirals.

  • A very zoomed out white version of the Ulam spiral
  • The same Ulam spiral but colored based on the x coordinates.
  • The same colored version, but zoomed in with some numbers and the 0,0 origin coordinate labeled.
  • An Ulam spiral for clarity from a 3rd party website.

Link to what an Ulam Spiral is: https://en.wikipedia.org/wiki/Ulam_spiral Note: The picture of this Ulam spirals attached to this post are base zero, unlike the base 1 example from wikipedia.

In the second picture, (the zoomed out colored one), if you look closely you will see a pattern of colors distributed unevenly in different parts of the spiral. This color pattern changes along the diagonals from the middle of the spiral. I'm trying to figure out if anyone has a way to explain why this happens, as I would assume there should be a random distribution throughout the whole column for a given x value.

Please note, when I refer to "x", I'm referring to the x coordinate in the Cartesian plane.

So, for (x, y) coordinates:

  • blue pixels are primes who's ulam values reside on the vertical lines of x such as:
    • ..,-6, -3, 0, 3, 6,..
  • red pixels are primes who's ulam values reside on the vertical lines of x such as:
    • ..,-5, -2, 1, 4, 7,..
  • green pixels are primes who's ulam values reside on the vertical lines of x such as:
    • ..,-4, -1, 2, 5, 8,..

Explained in another way, all primes that have a x coordinate of -6 are blue. All the ones with -5 are red. All the ones with -4 are green are so on, and this repeats for the entire Cartesian plane.

Blue, Red, Green is used to determine the colors of the primes based on the column they reside. Essentially I'm using a modulus 3 for column number to assign colors.

Why do we see randomness in left and right quadrants but mainly green and red in the top quadrant and blue and red mainly in the bottom quadrant. Note: I'm using the term "quadrant" here in a non traditional sense where the quadrant are based on the diagonals from the origin, not the x/y axis.

Interesting Note: Using the same method but flipped for Y, (if you do the coloring based on horizontal lines with given Y coordinates instead of X), you will instead see a seemingly random distribution in the top and bottom and then specific densities of prime in the left and right.

Can someone explain this or if it has already been written about somewhere?

enter image description here

Ulamspiralprimescolored

Additional pictures for clarity: (June 20th edit)

In the zoomed up examples for red pixels along x=1 and x=-2

  • x=1 red pixels ulam values: (59,13,2,23)
  • x=-2 red pixels ulam values: (97,17,19,43,113)

x,y (0,0) marked for clarity.

enter image description here

This is just an example where every ulam value is explicit (grabbed from here: http://primorial-sieve.com).

enter image description here

  • What do you mean by $x$ prime of the form $3k$? The only prime of the form $3k$ is $3$. Could you please reformulate your question to be more clear? – Alex M. Jun 13 '22 at 08:07
  • @AlexM. I need help understanding what you are asking.

    This is a normal ulam spiral where the black pixels are non prime numbers and the red/green/blue pixels are primes. I'm coloring the pixels different colors based on the which column in the cartesian plane the prime resides. Would you be able to help me formulate my question more clearly?

    – Michael Tidwell Jun 13 '22 at 19:12
  • If I understand correctly, you colour the points $(x,y)$ red whenever $x$ is a prime of the form $3k$. Now think: what are the prime numbers of the form $3k$? Obviously, just $3$ and $-3$, so the only red points should be $(3,y)$ and $(-3, y)$ (two vertical lines), so you already have a problem with your colouring algorithm because it paints way more red points than it should. Either I have misunderstood you, or you have a mistake in your implementation. – Alex M. Jun 13 '22 at 21:31
  • @AlexM. Please read over the question again as I've made some edits. I'm pretty sure you'll be able to understand now. If not let me know.. but I'm unsure how this could be more clear. Please provide at least 1 example if you think there is a problem with the colouring algorithm. – Michael Tidwell Jun 20 '22 at 21:50
  • I'm not confident in what my eyes are seeing. Changing how I zoom in to the picture the patterns change up completely. Instead of relying on a visual, may I suggest you provide a plot of a binned count of red blue and green points and juxtapose them and then try to deduce conclusions from it? EDIT: I can see the pattern but only at a certain zoom level. – DinosaurEgg Jun 22 '22 at 15:29
  • Download the pictures, don't rely on the web browser, open with your favorite photo software/viewer. Another thing you can try is clicking the picture and then clicking the "magnify zoom". I'll have time later today to get counts per diagonal quadrant later tonight. – Michael Tidwell Jun 22 '22 at 17:09

1 Answers1

1

First, let's make the correspondence between integers and lattice points in the plane explicit. If you start the Ulam spiral with a $0$ at the origin, the point $(x, y) \in \mathbb Z \times \mathbb Z$ corresponds to the integer: \begin{cases} 4x^2 - 3x + y & \text{ if in the right quadrant,} \\ 4y^2 - y - x & \text{ if in the top quadrant,} \\ 4x^2 - x - y & \text{ if in the left quadrant,} \\ 4y^2 - 3y + x & \text{ if in the bottom quadrant.} \\ \end{cases} (By "quadrants", I really mean which segment of the Ulam spiral it's on. So e.g. $(x, -x)$ counts as being in the bottom quadrant, while $(x+1, -x)$ is at a corner of Ulam's spiral and thus counts as part of both the bottom and right quadrants.)

The key is to understand when the values of these polynomials are divisible by $3$, in terms of $x$ and $y$. (If the number is divisible by $3$, then of course it's not prime unless it's $p = 3$ itself.) You have colored a prime number blue if the corresponding $x$ is congruent to $0 \pmod 3$, red if it is $1 \pmod 3$, and green if it is $2 \pmod 3$. Let's plug each of these congruences into each of the polynomials above.

In the top quadrant: we have $4y^2 - y - x \equiv y^2 - y - x \pmod 3$. If $x \equiv 0 \pmod 3$, then the polynomial is $0 \pmod 3$ if and only if $y \equiv 0$ or $1 \pmod 3$. If $x \equiv 1 \pmod 3$, then the polynomial is never $0 \pmod 3$. If $x \equiv 2 \pmod 3$, then the polynomial is $0 \pmod 3$ if and only if $y \equiv 2 \pmod 3$. So two-thirds of the blue dots, none of the red dots, and one-third of the green dots correspond to multiples of $3$. Among numbers that aren't multiples of $3$, we see a $1 : 3 : 2$ ratio of blue, red, and green; thus we should expect to see the same ratio among primes. This appears to match your picture.

In the bottom quadrant: we have $4y^2 - 3y + x \equiv y^2 + x \pmod 3$. If $x \equiv 0 \pmod 3$, then the polynomial is $0 \pmod 3$ if and only if $y \equiv 0 \pmod 3$. If $x \equiv 1 \pmod 3$, then the polynomial is never $0 \pmod 3$. If $x \equiv 2 \pmod 3$, then the polynomial is $0 \pmod 3$ if and only if $y \equiv 1$ or $2 \pmod 3$. So one-third of the blue dots, none of the red dots, and two-thirds of the green dots correspond to multiples of $3$. Thus we should see a $2 : 3 : 1$ ratio of blue, red, and green, which also looks about right.

In the right quadrant, regardless of the value we choose for $x \pmod 3$, there is exactly one value of $y \pmod 3$ making $$ 4x^2 - 3x + y \equiv 0 \pmod 3, $$ namely $y \equiv -(4x^2 - 3x) \equiv -x^2 \pmod 3$. So one-third of the dots of each color correspond to multiples of $3$, and we should see equally many primes of each color. The same reasoning applies to the left quadrant.

Finally, since you mentioned coloring based on $y$ instead of $x$: if you exchange the roles of $x$ and $y$, then this just switches the formulas for the right and bottom quadrants, and similarly the top and left quadrants. This explains why the unusual behavior "migrates" from the top and bottom quadrants to the left and right ones.