# Exploring the Graphs of a Prime Number Integer Sequence: Seeking Insights

I am an engineering student and when I was doing some work on data visualisation I stumbled across an integer sequence after watching a video about sequences that produce interesting graphs. I submitted the sequence to the On-Line Encyclopedia of Integer Sequences A328225.

The sequence is as follows: a(1) = 1, a(n) = a(n-1) - prime(prime(n)) - prime(n-1) if this produces a positive integer not yet in the sequence, otherwise a(n) = a(n-1) + prime(prime(n)) - prime(n-1).

This sequence produces the following graph (up to n = 1000, n = 10000 and n = 6e6 respectively)

Graph of sequence up to n = 1e3

Graph of sequence up to n = 1e4

Graph of sequence up to n = 6e6

I'm would love to get a understanding of the underlying principles that give rise to the curves observed in the graphs. Additionally, I'm intrigued by the apparent upper limit observed along the y-axis.

I would greatly appreciate any insights, explanations, or conjectures regarding the origins of these curves and the factors contributing to the observed limits. Furthermore, any suggestions on how to further explore or analyse this sequence would be immensely valuable.

Here is a text file up to n = 1e6 if anyone wants to have a play around with the sequence. If anyone would like any additional information/resources from me, feel free to ask.

This is not an answer, per se, but rather a comment that requires a couple of figures. I ran your Matlab code out to $$m=10^9$$ with just over five million primes (computation time was 4086 s). I'm seeing patterns in the structure that are much more complex than those you are seeing with the 10,000 primes. The first image below shows the complete field, albeit in log-log coordinates. The second image shows a detail of the structure in the vicinity of $$n=10^6$$. This behavior is present along the entire domain of $$n$$. To me, it's reminiscent of chaotic behavior. This prompted me to create the third figure below, whose purpose is to show the irregular spacing of the primes along a straight line; some tight clusters, some open spaces. The last figure show similar behavior with the Ulam spiral. This is beyond my ken, but the point is that there may be an underlying structure.

• This is really interesting. Thanks for the analysis. I wondered if you had any thoughts on the limit in the y-axis for most of the points and why there are some points above that limit.
– Con
Commented Mar 18 at 15:09
• First of all, thanks for you comment. I'm often disappointed that newcomers don't make the effort to acknowledge contributors. Now, as to your question, I have no explanation for the outliers at the top of the figure anymore than I can explain the vast empty spaces in the elliptical contoured regions. Commented Mar 18 at 15:39
• I am currenly running the code to m = 10e6 to have a play around with. I am not sure why I am so intrigued with this sequence. Every so often, it will just pop into my head. Now I just need to work on my Maths skills to figure it out. :)
– Con
Commented Mar 18 at 15:51
• Good, post here if you find out anything. I'm following this thread. Commented Mar 18 at 22:02

I have another comment for you that requires images. I'm afraid you'll spend a lot of time and energy on the impossible. I'm going to demonstrate dust spirals that is, a collection of dots generated by a sequence that the eye perceives to have patterns, but which are essentially random. (Reference: Spiral: from Theodorus to Chaos, Philip J. Davis, A.K. Peters, Ltd., 1993.) The point is that you may be searching in your recurrence for something that is not there.

Consider the sequence

$$z_{n+1}=az_n+b\frac{z_n}{|z_n|},\quad z_1=1$$

where $$a,b$$ are random complex numbers on the unit circle, e.g. $$a=e^{i2\pi\cdot \text{rand}}$$. The first figure below shows the dust spiral for the first 5000 iterations of the recurrence for the $$a,b$$ values shown in the title. The sweeping curves and spirals suggest a highly ordered result. But, in fact, it's not. A continuous plot of $$z$$ shows a entirely different story.

This should warn you that such patterns are well known but may be beyond understanding. To quote John von Neumann, "In mathematics you don't understand things. You just get used to them."

• I think you might be right. That is the second time I have heard that John von Neumann quote in as many weeks. The patterns could make a nice piece of artwork, if nothing else. I have added another graph to the question (up to n = 6e6) and a text file with the first million points just to make it easier for anyone else to have a play with the data.
– Con
Commented Mar 22 at 15:44