# Inverse functions - how are they calculated?

Mathematica is able to calculate InverseFunction[LogIntegral] and InverseFunction[RiemannR] (and many other inverse functions). How are these calculated? (I can see how LogIntegral and RiemannR are calculated if I go to the details section of the docs, but can't find a ref. for inverse functions.)

Note: I have tried looking at Series[LogIntegral[n], {n, 2, 3}], and InverseSeries[Series[LogIntegral[n], {n, 2, 3}]], but can't see clearly how this helps.

• I believe it uses numerical inversion in some cases. InverseFunction[LogIntegral] gives a Root object in v9 which suggests it uses the technology described here. May 21, 2014 at 14:17
• Great - thank you :) May 21, 2014 at 14:24

You could look at

Trace[InverseFunction[LogIntegral], TraceInternal -> True]
Trace[InverseFunction[RiemannR], TraceInternal -> True]


they both give huge outputs. Maybe try to filter out some patterns to limit the output. Especially part of evaluation having to do with messages would be nice to filter out.

• Hmmmm, having looked at these, I am none the wiser I am afraid!! May 21, 2014 at 14:21
• @martin yes, I must agree it looks quite hopeless. May 21, 2014 at 14:45

Series on RiemannR[x] does not have "good" Taylor expansion. Mathematica uses

Sum[MoebiusMu[n] LogIntegral[x^(1/n)]/n,{n,1,Infinity}]


which is also Ramanujan's series

RiemannR[x]-1 =Sum[Log[x]^n/(n n! Zeta[n+1]),{n,1,Infinity}]


A Classic Taylor expansion is numerically not stabile. You can to obtain at e.g. 2

Series[RiemannR[n], {n, 2, 5}] // Normal


which numerically is

1.54100901618713188328850378663 +
0.492873059153156128131756166775 (-2 + n) -
0.0357109244118073885987311878275 (-2 + n)^2 +
0.00842427070823529131964822281131 (-2 + n)^3 -
0.00256717021764032582595064954549 (-2 + n)^4 +
0.000885898743654821946805390294121 (-2 + n)^5


Generally Mathematica do not count directly RiemannR or RiemannR[-2] but we can obtain these values by following trick:

Evaluate complex RiemannR[-2+I x] and count real part for very small x but problem is numerically not stabile because in 0 is cusp (singularity)

The reversed Ramanujan series should contain Sum[c[n] Exp[x]^n,{n,0,Infinity}] where c[n] are constants.

Finally the reversed function RiemannR[x]-1 as a Taylor series is

1+(Zeta)y+ 0.42722 y^2- 0.114811 y^3 +0.04736 y^4

• Welcome to Mathematica! I have edited a bit of your answer, but perhaps you can more directly address the question (I think this is where you got the downvote). Do you mean inverse function when you talk about the "reversed" function? Perhaps edit the text here to make this clearer. Apr 6, 2022 at 4:35