From 489369a93c68194b09d3ba132d3af4130a7c8251 Mon Sep 17 00:00:00 2001 From: Alexey Shiklomanov Date: Fri, 2 Jun 2023 14:54:29 -0400 Subject: [PATCH 1/2] Derivative of exponential integral General form: $$ \frac{d}{dx} E_\nu(x) = -E_{\nu - 1}(x) $$ Special case: $$ \frac{d}{dx} E_0(x) = -\frac{e^{-x}}{x} $$ Source: https://en.wikipedia.org/wiki/Exponential_integral#Derivatives --- src/rules.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/rules.jl b/src/rules.jl index cbd4448..7b9b59e 100644 --- a/src/rules.jl +++ b/src/rules.jl @@ -181,6 +181,8 @@ _abs_deriv(x) = sign(x) @define_diffrule SpecialFunctions.ellipe(m) = :( (SpecialFunctions.ellipe($m) - SpecialFunctions.ellipk($m)) / (2 * $m) ) +@define_diffrule SpecialFunctions.expint(x) = :( -exp(-$x) / $x ) + # TODO: # # eta @@ -236,6 +238,10 @@ _abs_deriv(x) = sign(x) @define_diffrule SpecialFunctions.logbeta(a, b) = :( SpecialFunctions.digamma($a) - SpecialFunctions.digamma($a + $b) ), :( SpecialFunctions.digamma($b) - SpecialFunctions.digamma($a + $b) ) +# derivative wrt to `ν` is not implemented +@define_diffrule SpecialFunctions.expint(ν, x) = + :NaN, :( -SpecialFunctions.expint($ν - 1, $x) ) + # derivative wrt to `s` is not implemented @define_diffrule SpecialFunctions.zeta(s, z) = :NaN, :( - $s * SpecialFunctions.zeta($s + 1, $z) ) From fed2f7db8990c4ed1f89abaafc265cdbc8e80ba7 Mon Sep 17 00:00:00 2001 From: Alexey Shiklomanov Date: Fri, 2 Jun 2023 17:00:46 -0400 Subject: [PATCH 2/2] Bump SpecialFunctions compatibility to >=1.1 Exponential integral (`expint`) was only introduced in 1.0... https://github.com/JuliaMath/SpecialFunctions.jl/releases/tag/v1.0.0 ...but with spurious domain errors, which were fixed in 1.1 (at least fixed-enough that this package's tests pass.) https://github.com/JuliaMath/SpecialFunctions.jl/releases/tag/v1.1.0 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 4829f3a..b697659 100644 --- a/Project.toml +++ b/Project.toml @@ -13,7 +13,7 @@ SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" IrrationalConstants = "0.1.1, 0.2" LogExpFunctions = "0.3.2" NaNMath = "0.3, 1" -SpecialFunctions = "0.10, 1.0, 2" +SpecialFunctions = "1.1, 2" julia = "1.3" [extras]