# Manipulate giving errors when I plot the product of a step function and a continuous function

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]
]


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:

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?
• “ 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. – MarcoB Nov 16 '20 at 14:35
• Hi @MarcoB. OK - but I have no idea how to do that... – Richard Burke-Ward Nov 16 '20 at 14:38
• oops, sorry @MarcoB - saw your comment after I posted.. Same answer – George Varnavides Nov 16 '20 at 14:41
• @GeorgeVarnavides Not a problem! I am glad you put together a proper answer instead. – MarcoB Nov 16 '20 at 17:44

PrimePowerQ only takes exact numbers as arguments.
In[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]].