I wanted the inverse logarithmic intgral, so I typed


and received the expected symbolic answer. But when I try to integrate it or even evaluate it it fails. Is there some way to sweet-talk Mathematica into computing this function?

Edit: I was asked for how it fails, here's an example.

NIntegrate[n/(InverseFunction[LogIntegral][n])^2, {n, 10^7, 10^9}]


NIntegrate::inumr : The integrand (...) has evaluated to non-numerical values for all sampling points in the region with boundaries {{10000000,1000000000}}.

  • $\begingroup$ You haven't explained how evaluation "fails". It just works nicely, e.g. InverseFunction[LogIntegral][4] yields Root[{-4 + LogIntegral[#1] &, 5.60927669305089035535879233715}]. When integrating one should expect that in general there is no closed form exprssion, however e.g.NIntegrate[InverseFunction[LogIntegra l][x], {x, 2, 10}] yields quite resonably 82.0804. Perhaps you should remember Inverting a function in a certain region $\endgroup$
    – Artes
    Dec 4, 2014 at 18:54
  • $\begingroup$ @Artes: With an NIntegrate::inumr error. I've edited in code. $\endgroup$
    – Charles
    Dec 4, 2014 at 19:17
  • $\begingroup$ In[138]:= f[x_?NumberQ] := y /. FindRoot[LogIntegral[y] == x, {y, 2}]; NIntegrate[n/(f[n])^2, {n, 10^7, 10^9}] Out[139]= 1.249875*10^17 $\endgroup$ Dec 4, 2014 at 19:24
  • $\begingroup$ @DanielLichtblau: That's not a sensible answer, though. The li^{-1}(x) > x (in fact ~ x log x), so the integral should be less than the integral of 1/x over the same region, which is about 4.6. $\endgroup$
    – Charles
    Dec 4, 2014 at 19:33
  • $\begingroup$ (The true answer should be about 0.01125, or 19 orders of magnitude smaller.) $\endgroup$
    – Charles
    Dec 4, 2014 at 19:34

2 Answers 2


This seems usable at least for moderately large x. one could use cutoffs and different start values if this is not useful in smaller ranges.

f[x_?NumberQ] := 
 y /. FindRoot[LogIntegral[y] == x, {y, x*Log[x]}, 
   WorkingPrecision -> 20, PrecisionGoal -> 12]

Two examples:


(* Out[55]= 4.6565831394119416907*10^202 *)

NIntegrate[n/(f[n])^2, {n, 10^7, 10^200}, MinRecursion -> 5, 
 MaxRecursion -> 20]

During evaluation of In[60]:= NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small. >>

(* Out[60]= 0.0519673879642 *)
  • $\begingroup$ Works great, thanks! I tweaked the WorkingPrecision and PrecisionGoal upward and all was good. $\endgroup$
    – Charles
    Dec 4, 2014 at 21:50
  • $\begingroup$ I edited to fix that PrecisionGoal (realized I was specifying it all wrong. It happens.) $\endgroup$ Dec 4, 2014 at 22:16
  • $\begingroup$ As a minor point, x_?NumericQ would be better than x_?NumberQ so that the function will accept numeric constants such as Pi or E. $\endgroup$
    – Bob Hanlon
    Dec 4, 2014 at 22:54
  • 1
    $\begingroup$ @Charles FWIW, for the particular integral in your question, substituting n = LogIntegral[y] yields this easier to evaluate expression: NIntegrate[LogIntegral[y]/(Log[y] y^2), {y, f[10^7], f[10^9]}], where f is the numeric inverse of LogIntegral in Daniel's answer. $\endgroup$
    – Michael E2
    Dec 5, 2014 at 21:02

A bit of an aside, but a little variable substitution helps that integral quite a lot.

  f[x_?NumberQ] := 
    y /. FindRoot[LogIntegral[y] == x, {y, x*Log[x]}, 
         WorkingPrecision -> 20, PrecisionGoal -> 12]
  Log[10] NIntegrate[(10^n/f[10^n])^2 , {n, 7, 200}, 
       MinRecursion -> 5, MaxRecursion -> 20] 


(~10x faster w/ no warnings about convergence )


Your Answer

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

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