TITLE: Interesting pattern in plot involving prime numbers
QUESTION [6 upvotes]: If we plot $f(n) = \dfrac{n+1}{p_{n+1}} - \dfrac{n}{p_n}, n \in \mathbb{N} $, we get an interesting pattern.

Questions:

Why it looks like there's different lines on plot?

Why they have such shape?

How those lines can be approximated?

Why there's like peak at $n \approx 500$?

Why points in lines become sparcer as they are closer to the bottom?

REPLY [4 votes]: Note that
$$f(n)={1\over p_{n+1}}-n\left({1\over p_n}-{1\over p_{n+1}}\right)={1\over p_{n+1}}-{ng_n\over p_np_{n+1}}\approx{1\over n\ln n+g_n}\left(1-{g_n\over\ln n}\right)$$
where $g_n=p_{n+1}-p_n$ and we've used the crude asymptotic approximation $p_n\approx n\ln n$. So very roughly, we are looking at the family of curves
$$f_k(x)={1\over x\ln x+2k}\left(1-{2k\over\ln x}\right)$$
with $k=1,2,3,\ldots$.  These curves behave qualitatively much like what the OP has observed; their quantitative disagreement -- the curve with $2k=6$ has a peak value of approximately $.00002$ at $x\approx873$, instead of $.00005$ near $500$ -- is due to the crudeness of the approximation $p_n\approx n\ln n$. Using the better approximation mentioned in jjagmath's answer, $p_n\approx n(\ln n+\ln\ln n-1)$, one gets a curve (for $2k=6$) with a peak of approximately $.00004$ at $x\approx431$, which comes closer to the OP's values.
In answer to the OP's final bullet-point question, the sparsity of the lower lines stems, heuristically, from the fact that large prime gaps (i.e., large values of $2k$) take a while to kick in and remain relatively rare among the first $10{,}000$ primes.