TransWikia.com

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

Mathematica Asked on June 7, 2021

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?

One Answer

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

Correct answer by George Varnavides on June 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP