Skip to content

Commit bb9eeb7

Browse files
committed
added Logarithmic integral function
1 parent 31e3c1a commit bb9eeb7

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

docs/src/functions_list.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ ncF
7878
expint
7979
expinti
8080
expintx
81+
li
8182
sinint
8283
cosint
8384
```

docs/src/functions_overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Here the *Special Functions* are listed according to the structure of [NIST Digi
3939
| [`expintx(x)`](@ref SpecialFunctions.expintx) | scaled [exponential integral](https://en.wikipedia.org/wiki/Exponential_integral) ``e^z \operatorname{E}_\nu(z)`` |
4040
| [`sinint(x)`](@ref SpecialFunctions.sinint) | [sine integral](https://en.wikipedia.org/wiki/Trigonometric_integral#Sine_integral) ``\operatorname{Si}(x)`` |
4141
| [`cosint(x)`](@ref SpecialFunctions.cosint) | [cosine integral](https://en.wikipedia.org/wiki/Trigonometric_integral#Cosine_integral) ``\operatorname{Ci}(x)`` |
42+
| [`li(x)`](@ref SpecialFunctions.li) | [logarithmic integral function](https://en.wikipedia.org/wiki/Logarithmic_integral_function) ``\operatorname{li}(x)`` |
4243

4344

4445
## Error Functions, Dawson’s and Fresnel Integrals

src/SpecialFunctions.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export
9090
expintx,
9191
sinint,
9292
cosint,
93+
li,
9394
lbinomial
9495

9596
include("bessel.jl")

src/expint.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,3 +610,32 @@ function expinti(x::BigFloat)
610610
ccall((:mpfr_eint, :libmpfr), Int32, (Ref{BigFloat}, Ref{BigFloat}, Base.MPFR.MPFRRoundingMode), z, x, Base.MPFR.ROUNDING_MODE[])
611611
return z
612612
end
613+
614+
##############################################################################
615+
# Logarithmic integral function li
616+
617+
@doc raw"""
618+
expinti(x::Real)
619+
620+
Computes the Logarithmic integral function
621+
```math
622+
\operatorname{li}(x) = \int_{0}^x \frac{1}{\ln{t}} \mathrm{d}t,
623+
```
624+
which is equivalent to ``\operatorname{Ei}(\ln{x})`` where
625+
``\operatorname{Ei}`` is the `expinti` function.
626+
627+
External links: [Wikipedia](https://en.wikipedia.org/wiki/Logarithmic_integral_function)
628+
"""
629+
function li(x::Real)
630+
if x < 0
631+
throw(DomainError(x, "negative argument, convert to complex first"))
632+
elseif x == 0
633+
return 0
634+
elseif x == 1
635+
return -Inf
636+
elseif x == Inf
637+
return Inf
638+
else
639+
return expinti(log(x))
640+
end
641+
end

0 commit comments

Comments
 (0)