Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is the plot of a function $f(x)$ such that: $$ f(x) = \frac {P_ {\lfloor 2 x \rfloor}} {P_ {\lfloor 2 x \rfloor - 1}} $$ where $P_k$ is the $k^{\mathrm{th}}$ Prime Number for x in range [1,300].

Plot Primes

The curves are in the form $1 + \frac {1} {a x^b}$, with $a,b\in\mathbb {R}$ and where I chose arbitrarily $a$ and $b$, $b\simeq 1.22$ in the image above.
Personally, I was very surprised whith what seems very regular shapes occurring again and again along the curves.
Can someone explain this?

I deleted the first post about this, because it seems more like a Mathematica bug than something else, but I cannot find what's wrong. Here is the Mathematica code:

Module[{ a, b, c, xa, xb, plotall, plots0, plots1},
a = Prime[Floor[2*x - 1]];
b = Prime[Floor[2*x]];
xa = 1; xb = 300; c = 1.22;
plots0 = { b/a};
plots1 = {1 + 1/2.21/x^c, 1 + 1/1.1/x^c, 1 + 1/0.725/x^c, 
1 + 1/0.435/x^c, 1 + 1/0.31/x^c, 1 + 1/0.195/x^c, 
1 + 1/0.126/x^c  };
plotall = Join @@ {plots0, plots1};
Panel@Plot[  Tooltip@plotall, {x, xa, xb} , AxesLabel -> {x, y}]

As also suggested, here is the plot of: $$ f (x) = \frac {P_ {\lfloor x \rfloor}} {P_ {\lfloor x \rfloor - 1}} $$

enter image description here

and the interactive Mathematica code:

Module[{a, b, xa, xb, plotall, plots0, plots1},
a = Prime[Floor[x] - 1];
b = Prime[Floor[x]];
xa = 2; xb = 300;
plots0 = { b/a};
plots1 = { 1 + 1/r1/x^c1 };
plotall = Join @@ {plots0, plots1};
Plot[ Tooltip@plotall, {x, xa, xb} , AxesLabel -> {x, y}]
, Style["Global Options", Bold, "Panel"]
, {{r1, 0.83}, 0, 3, Appearance -> "Open"}
, {{c1, 1.25}, 0, 5, Appearance -> "Open"}

Since Julian Aguirre's answer, I just wanted to add the following graph, where the curves are in the form $1+ \frac {7} {4}.\frac {n} {x\text { Log} (x)}$ for $n$ integer in range[1,10]...

enter image description here

share|cite|improve this question
@Clayton, the nth prime number is given by the floor functions $\lfloor 2 x \rfloor$ and $\lfloor 2 x \rfloor - 1$ in the formula. – Eddy Khemiri Oct 30 '13 at 12:38
I think it has a lot to do with the fact that the distance between any two primes is about ln$(p)$ and the size of the primes is getting larger at a much faster rate. This fact would cause your graph to approach 1 because you are essentially taking the ratio of 2 very close numbers. That explains why your graph looks a lot like $\frac{1}{ln(p)}$. – AJ Stas Oct 30 '13 at 12:42
Why not just graph $\frac{P_{\lfloor x\rfloor}}{P_{\lfloor x\rfloor}-1}$? The $2$ is just a scaling factor that adds noise to the function. – Thomas Andrews Oct 30 '13 at 12:43
up vote 2 down vote accepted

What you see is due to the gaps between prime numbers. $$ \frac{P_{2k}}{P_{2k-1}}=1+\frac{P_{2k}-P_{2k-1}}{P_{2k-1}}. $$ The curves you see are formed by primes with gaps $2$, $4$, $6$, \dots

¿What can we say about the curves? Using the Prime Number Theorem, the primes with gap $g$, where $g$ is a positive even number, lie close to the prph of the function $$ f_g(x)=1+\frac{g}{(2\,x-1)\ln(2\,x-1)}. $$ You can see it in the following picture, where points are colores according to the gap: enter image description here

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.