1
$\begingroup$

Riemann's prime counting function J (link) takes half-values at every jump-discontinuity. So, I define it thus:

Clear["Global`*"]; 
floor[e_] := Quiet[Check[Floor[e], Floor[FullSimplify[e]]]]; 
riemannJ[x_] :=
   With[{δ = 0.01}, 
     Piecewise[{
       {(Sum[(1/α)* PrimePi[(x - δ)^(1/α)],
        {α, 1, floor[Log[x - δ]/Log[2]]}] + Sum[(1/α)*
        PrimePi[(x + δ)^(1/α)], {α, 1, 
        floor[Log[x + δ]/Log[2]]}])/2,
        PrimePowerQ[x]},
       {Sum[(1/α)*PrimePi[x^(1/α)], {α, 1, 
       floor[Log[x]/Log[2]]}],
       True}
   }]];

Viewed as a Plot, the function J[x]*x^(-s - 1) produces a series of continuous lines that are discontinuous from each other at all points where PrimePowerQ[x] = True (plot shown with with s = -2):

Module[{s = -2}, 
 Plot[riemannJ[x]*x^(-s - 1), {x, 1, 10}, GridLines -> Automatic]
]

plot with error: primepower argument is not exact number

I have a couple of problems:

  1. That error message: is Mathematica passing inaccurate values of x to Plot?

  2. I'd like to use Manipulate to chart the curve for different values of s. But the plot now has a pink fill. The code is:

    Manipulate[
     Plot[riemannJ[x]*x^(-s - 1), {x, 1, 10}, GridLines -> Automatic], 
     {{s, -2, Style["Choose s", Larger, Bold]}, -5, 5, 1/2}, 
     ControlType -> Setter]
    

and the output:

output of manipulate with same error and plot with pink background

I assume that this is the same error (as evidenced but the line below the plot), only now it shows the plot in pink.

How do I get around this?

Lastly:

  1. Is there a way to 'join up' the line segments at the points of discontinuity?
$\endgroup$
  • 1
    $\begingroup$ “ is Mathematica passing inaccurate values of x to Plot?” - Plot is passing machine-precision values to your function as it evaluates it in the plotting range you chose. Those values are passed to PrimePowerQ, which complains because its input should be arbitrary-precision. You should sanitize your inputs to riemannJ. $\endgroup$ – MarcoB Nov 16 at 14:35
  • $\begingroup$ Hi @MarcoB. OK - but I have no idea how to do that... $\endgroup$ – Richard Burke-Ward Nov 16 at 14:38
  • $\begingroup$ oops, sorry @MarcoB - saw your comment after I posted.. Same answer $\endgroup$ – George Varnavides Nov 16 at 14:41
  • $\begingroup$ @GeorgeVarnavides Not a problem! I am glad you put together a proper answer instead. $\endgroup$ – MarcoB Nov 16 at 17:44
2
$\begingroup$

PrimePowerQ only takes exact numbers as arguments.

In[1]:= PrimePowerQ[1.2]
During evaluation of In[1]:= PrimePowerQ::exact: Argument 1.2` in PrimePowerQ is not an exact number.
Out[1]= PrimePowerQ[1.2]

Plot is happy to ignore the unevaluated Piecewise calls (which is why you also get the discontinuities).

All three questions are fixed by replacing PrimePowerQ[x] with PrimePowerQ[Rationalize[x,0]].

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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