Is it possible to create a function that gives the inverse of

pP[x_] := Sum[PrimePi[x^(1/k)]/k, {k, 1, Floor[Log2[x]]}]

i.e., a function that plots

{pP@#, #} & /@ Range@(InverseFunction[LogIntegral][100]) // ListLinePlot

but is a function in $n$ that gives the actual value of $\Pi^{-1}(n)$ for any $n?$

  • 1
    $\begingroup$ your pP only returns a set of discrete rational results. What should the inverse be if evaluated for an x not in the set of allowable values? $\endgroup$
    – george2079
    Sep 24, 2015 at 15:18
  • $\begingroup$ @george2079 this is the problem I am facing - intervals should evaluate to the same as the previous value change, but I have no idea how to manage this. $\endgroup$
    – martin
    Sep 24, 2015 at 15:20

1 Answer 1


This is an approximation*:

inv = Interpolation[
            Table[ {pP[x], x}, {x, 1, 400, .01}] , (#1[[1]] == #2[[1]]) & ], 
                 InterpolationOrder -> 0];

Plot[ inv[x], {x, 0, 80}]

enter image description here

The issue now is how to find the exact x where the jumps occur..

*After looking at the results the jumps seem to always occur at integer x, so you can drop the .01 increment to speed things up (and I suppose call it exact )

  • $\begingroup$ nice, thanks :) a little slow on my machine - but I suppose that is unavoidable? - Ah, I see, it is the initial calculation to the desired height that is slow - so this function is essentially an interpolation of a lookup table - great - will have a oplay around with it - thanks again :) $\endgroup$
    – martin
    Sep 24, 2015 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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