LogIntegral¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
LogIntegral[z]
gives the logarithmic integral li(z), the principal value of Integral_0^z dt/ln t, equal to ExpIntegralEi[Log[z]], with a branch cut on (-Infinity, 1). LogIntegral[0] = 0, LogIntegral[1] = -Infinity,
LogIntegral[Infinity] = Infinity. Real and complex inputs evaluate
Notes
numerically at machine or arbitrary (MPFR) precision; D\[LogIntegral\[z\], z\] = 1/Log\[z\]. Listable.Examples (4)¶
Every input below was run against the current Mathilda build and its output recorded.
Applications (4)¶
In[1]:= N[LogIntegral[2], 40]
Out[1]= 1.0451637801174927848445888891946131365227
In[2]:= D[LogIntegral[z], z]
Out[2]= 1/Log[z]
In[3]:= N[LogIntegral[10^6], 30]
Out[3]= 78627.54915946218191986291074769
In[4]:= N[LogIntegral[1000], 20]
Out[4]= 177.609657990152226688
Algorithm¶
Mathilda -- the logarithmic integral li.
li has a branch cut along (-Infinity, +1); the principal value is taken on the cut. The implementation rests on the identity
where Ei is ExpIntegralEi and Log is the principal logarithm. This lets us reuse ExpIntegralEi's fully-tested numeric stack (mpfr_eint / the real and complex convergent series with cancellation guard bits) without duplicating any of it, and the principal Log automatically supplies the +-i Pi jump that places the branch cut on (-Infinity, +1).
Evaluation is layered so each kind of argument takes the cheapest route:
exact special values -> 0, -Infinity, Infinity, Indeterminate
numeric (inexact) z -> evaluate ExpIntegralEi[Log[z]]
everything else -> stays symbolic (return NULL)
Exact non-special numbers (e.g. LogIntegral[2], LogIntegral[1/2]) stay symbolic, matching the Wolfram Language; only inexact input or an explicit N[...] (which rewrites the argument to an MPFR number) evaluates numerically.
Attributes: Listable, NumericFunction, Protected.
Implementation notes¶
- Exact special values:
LogIntegral[0] = 0,LogIntegral[1] = -Infinity,LogIntegral[Infinity] = Infinity;ComplexInfinityandIndeterminatemap toIndeterminate. - Exact non-special arguments stay symbolic (
LogIntegral[2],LogIntegral[1/2]); numeric values follow from aReal/MPFR argument or fromN. - Numeric evaluation (machine and arbitrary precision) routes through
ExpIntegralEi[Log[z]]: - Real z > 1 (
Log z > 0) → MPFRmpfr_eint, correctly rounded and fast even at very high precision:LogIntegral[20.] = 9.9053,LogIntegral[2.] = 1.04516,N[LogIntegral[2], 50] = 1.0451637801174927848445888891946131365226155781512. - Real 0 < z < 1 (
Log z < 0) → the on-cut convergent series, returning a real principal value:LogIntegral[0.5] = -0.378671,LogIntegral[1.2] = -0.933787. - Complex (and real z < 0, whose principal
Logis complex) → the complex series with guard bits, so machine-precision complex results are fully accurate, e.g.LogIntegral[2. + I] = 1.41126 + 1.22471 I,N[Re[LogIntegral[2 + I]], 30] = 1.41125904201780100568439320706. - Derivative:
D[LogIntegral[z], z] = 1/Log[z](chain rule applies, e.g.D[LogIntegral[x^2], x] = (2 x)/Log[x^2]); the Taylor series at a regular point follows from the genericD-based fallback. - Wrong arity emits
LogIntegral::argxand stays unevaluated.
Attributes: Listable, NumericFunction, Protected.
References¶
See also: ExpIntegralEi, Log, N, D
- Source:
src/info.c - Specification:
docs/spec/builtins/special-functions.md - Tests:
tests/test_cherry_li.c - Tests:
tests/test_cherry_sigma.c - Tests:
tests/test_compile.c - Tests:
tests/test_integrate_risch_transcendental.c
Notes & additional examples¶
Notes¶
LogIntegral[z] is the logarithmic integral li(z), the principal value of Integral_0^z dt/Log[t], equal to ExpIntegralEi[Log[z]], with a branch cut on (-Infinity, 1). Its derivative is 1/Log[z]. li(x) is the leading term of the prime-counting approximation PrimePi[x] ~ li(x); for example li(10^6) is about 78627.5, close to PrimePi[10^6] = 78498. Real and complex inputs evaluate numerically at machine or arbitrary (MPFR) precision. LogIntegral[1] = -Infinity. Listable.