0
$\begingroup$

The Ramanujan primes can be easily plotted with the following code

       l = Table[PrimePi[x] - PrimePi[x/2], {x, 10^4}];

       ListLinePlot[1 + Last[Position[l, #]][[1]] & /@ Range[0, 50]]

that is enter image description here

I would like to plot a counting function for the Ramanujan primes, that is a prime counting function for the Ramanujan primes. Is it possible? Any ideas?

$\endgroup$
1
$\begingroup$
Clear["Global`*"]

l = Table[PrimePi[x] - PrimePi[x/2], {x, 10^4}];

ramPrime = 1 + Last[Position[l, #]][[1]] & /@ Range[0, 50];

ramPrimePi[x_] := Count[ramPrime, _?(# <= x &)]

Using Plot

Manipulate[
 Plot[ramPrimePi[x], {x, 0, xmax},
  Ticks -> {If[xmax < 100, ramPrime[[1 ;; 10]], Automatic], Automatic},
  PlotPoints -> {xmax, Automatic}],
 {{xmax, 100}, 25, Ceiling[ramPrime[[-1]], 25], 25, Appearance -> "Labeled"}]

enter image description here

Using ListStepPlot

Manipulate[
 Module[{primes = ramPrime[[1 ;; ramPrimePi[xmax]]]},
  ListStepPlot[
   Transpose@{{0, primes} // Flatten, Range[0, Length@primes]},
   PlotRange -> {{0, xmax}, Automatic},
   Ticks -> {If[xmax < 100, ramPrime[[1 ;; 10]], Automatic], Automatic}]],
 {{xmax, 100}, 25, Ceiling[ramPrime[[-1]], 25], 25, Appearance -> "Labeled"}]

enter image description here

$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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