Spiral's from (prime) squares $p^2$ and gaps

152 Views Asked by At

This is recreational math. I created some colorful spirals from natural numbers and prime numbers. I do not understand observations I made. If possible I would like a more indepth answer and some intuition if possible.

Method:

Spirals created by squares. Image 1): First row left image: spiral created of integer series: $2,3,4...$. Squares are created and stacked, creating a spiral. Look at the spiral as 3D, every new square is put on bottom. Unit square $1 \times 1$ is the white "hole" in center.

Information Images:

  • Image 1): The natural number sequence $2, 3, 4, 5...$ square spiral seems to grow linear with 1 unit.
  • Image 2): The prime number square spiral shows the gaps between primes (modules 4 for every edge). The prime number square spiral build of $N=500$ starts looking like natural number spiral.

Observation:

  1. When looking at $N=0$ to $500$ the prime gaps look linear distributed. The five colored bands are almost evenly spaced.
  2. When zooming in from $N=0$ to $50$ the prime gaps look chaotic.

My explanation:

Prime numbers grow with $f(x)=x \log(x)$.

  1. From $x=0$ to $N$ gaps look distributed linear (also seen in color coding images). Did determine linear fit $R^2$ and converges to $1$ in that range according my derivation (not posted here) .
  2. Looking at $N \rightarrow \infty$ the slope thus prime gap growth is not linear and grows.
  3. Zooming in on small range real prime gaps not $x \log(x)$ they are distributed chaotic.

Question:

Does someone have any names for these 3 kind of properties? What kind of theorems/intuition are related to these figures/properties? These are all counterintuitive observations.

My level is enthusiast/amateur hobby.

Image 1):Image 1 Image 2):Image 2

import numpy as np
import sympy as sp
import matplotlib.pyplot as plt1
from matplotlib.patches import Rectangle

#Create pyplot and set style widget
#%matplotlib widget
fig, ax1= plt1.subplots(figsize=(15, 15))

#Load Colormap
def get_cmap(n, name='tab20c'):
    #Reds, Pastel1
    return plt1.cm.get_cmap(name, n)

#Load prime table (for large spirals)
#p= np.loadtxt("Primetable.txt", delimiter=",", unpack=False)

#Set size of square spiral, Load colormap
size=15; x=0; y=0; maximum=0; cmap = get_cmap(size)

#lineair Squares load list
a=np.arange(2,size+2,1)
q=0; c=0; k=0

while k<size:

    num=sp.prime(q+1)
    #num=p[q]
    #num=a[q]
    ps=num*num-2
    
    #Detemrine angle square. Determimie polarity (quadrant in plot)
    alpha=(q+1)*np.pi/2
    
    polarity=c%4
    if polarity==0:
        sx=1; sy=1
    if polarity==1:
        sx=-1; sy=1       
    if polarity==2:
        sx=-1; sy=-1        
    if polarity==3:
        sx=1; sy=-1    

    #Plot squares. Conditional prime check possible on: num or ps (p^2-2)
    if sp.isprime(int(ps)):
        
        #Plot rectangle z-order bottom np.random.rand(3,)
        ax1.add_patch(Rectangle((x,y),sx*num,sy*num,facecolor=cmap(c),zorder=(-c),linewidth=0,edgecolor='black',linestyle="-",alpha=1))
        #Plot rectangle outline z-order top
        ax1.add_patch(Rectangle((x,y),sx*num,sy*num,facecolor='none',zorder=(-c),linewidth=0.5,edgecolor='black',linestyle="-",alpha=1)) 
        #Number labels
        ax1.annotate(num,xy=(x, y), xycoords='data',xytext=(x-4*sx, y-4*sy), textcoords='data',arrowprops=dict(arrowstyle="->", connectionstyle="arc3"),fontsize=18,      )
        c=c+1
 
        #Detemine position edge point (with polarity).
        dx=num*sx; dy=num*sy
        x=x+dx; y=y+dy 
        k=k+1

        #Detemrine maximum to set graph range
        maxin=max([np.abs(x),np.abs(y)])
        if maxin>maximum:
            maximum=maxin    
    q=q+1


#Display grph and plot center point
ax1.plot(0,0, marker='o', color='black',linestyle='-', markersize=5, linewidth=1, zorder=10)
ax1.axes.set_xlim([-maximum-2,maximum+2])
ax1.axes.set_ylim([-maximum-2,maximum+2])
ax1.axis('off')
plt1.show()