# Determining an upper bound for a plot of twin primes

Since this is long and requires a lot of explanation, let me briefly and vaguely state my question at the onset: how would I go about determining an upper bound for the plot pictured near the bottom of my post?

This question is related to a previous question here. It's not required that you read the previous question, but may clarify some of what I'm talking about.

Alterating my statement slightly from what I had in the previous question. My goal is to find some way to show infinitely many twin primes using the following:

If each prime were a bucket filled with at least one unique twin prime, infinite primes (proven) would imply infinite twin primes (conjectured only). Bucket twin primes as follows:

$(6pn-1, 6pn+1)$ where $p$ is a prime, and $n$ is some positive integer less than $p$.

For those with knowledge of Mathematica, I've written the following code that finds the first twin prime for each $p$ by testing values of $n$ starting at 1:

a=1;b=6000000;
Do[p=Prime[pnum];
new=Do[If[And[PrimeQ[6*p*n+1],PrimeQ[6*p*n-1]],Return[n]],{n,1,p}];
Do[If[new>Last[t],{AppendTo[data,{pnum,new}],AppendTo[t,new]}],1],
{pnum,a,b}];


Simply put, this code find a twin prime for the first 6,000,000 primes. It then creates an ordered pair for it of the form (# of prime, $n$ value of first twin).

Running the code, several things are found. First, every bucket through the 6,000,000th prime is filled with a twin prime. Also, each twin prime found is unique. Why? Because as long as a twin is found before $n$ reaches $p$, the factors of $6np$ will always include $6$, $p$, and all other factors less than $p$.

Therefore, to prove the twin prime conjecture, all that would need to be done is prove that for a twin prime must be found for a value of $n$ less than $p$.

Intuitively, this would seem to be the case. Consider with me $p=11$. Lets look for values of $p$ such that neither $6np-1$ nor $6np+1$ is divisible by $5$. For $n=1$, $6np=66$. Since $65$ is divisible by $5$, $n=1$ is a fail. The next fail will be $n=4$, $6np=264$. It can be shown that $6np \pm 1$ is divisible by $5$ for every $n\equiv \pm 1\pmod{5}$. Similarly, $n$ is divisible by $7$ for every $n\equiv \pm 2\pmod{7}$. In other words, only $2$ of every $5$ values of $n$ will be divisible by $5$ following a repeating pattern. The same goes for $7$ and any other prime. This could be used to create a sort of sieving for twin primes generated with each $p$. This takes some thinking through, but ponder on this for a while and I think you'll agree that for large values of $p$, it will become increasing more difficult to "cover" every single value of $n$ that is less than $p$.

And that is exactly what is found when my code above is plotted. Notice, I have the code set to only store an ordered pair if a value of $n$ yielding a first twin is higher than any previous value of $n$ that generated the first twin for some other $p$. The goal is to examine the question, "How large can $n$ possibly get before a twin is created. Notice the plot below:

The plot says this: For every one of the first 6,000,000 primes, there exists an $n$ less than $p$ that generates a twin. Also, notice that although the increasing value of $n$ is steep to begin with, it begins to flatten. Within the first 6,000,000 primes, no value of $n$ ever even reaches 2,000 before a twin is generated, and the values of $n$ appear to continue to plateau! This plot includes a blue line which is a logarithmic fit of the ordered pairs. The plot and fit are generated by the following code:

logfit = NonlinearModelFit[data, j*Log[(k*x)^2 ]+l*x, {j,k,l}, x];
Show[ListPlot[data,PlotRange->All,PlotStyle->{Red,PointSize[Tiny]},AxesLabel->{"prime number","n"},ImageSize->Large],
Plot[logfit[x],{x,1,b}]]


Finally, here is my question: How do I move forward? I'm convinced that all the pieces to prove the twin prime conjecture are within this method. The logical step would seem to be to try to find an upper bound for $n$ in relation to $p$. This is where my knowledge of number theory proves insufficient. Would someone give me what steps I should take toward showing that $n$ must remain below $p$?