Skip to content

Commit 251d422

Browse files
case out Kummer
1 parent d904ae6 commit 251d422

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "HypergeometricFunctions"
22
uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a"
3-
version = "0.3.6"
3+
version = "0.3.7"
44

55
[deps]
66
DualNumbers = "fa6b7ba4-c1ee-5f82-b5fc-ecf0adba8f74"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
A Julia package for calculating hypergeometric functions
66

7-
This package implements the generalized hypergeometric function `pFq([a1,…,am], [b1,…,bn], z)`. In particular, the Gauss hypergeometric function is available as `_₂F₁(a, b, c, z)`, and also `_₃F₂([a1, a2, a3], [b1, b2], z)`.
7+
This package implements the generalized hypergeometric function `pFq([a1,…,am], [b1,…,bn], z)`. In particular, the Gauss hypergeometric function is available as `_₂F₁(a, b, c, z)`, Kummer's confluent hypergeometric function is available as `_₁F₁(a, b, z)` and `HypergeometricFunctions.M(a, b, z)`, as well as `_₃F₂([a1, a2, a3], [b1, b2], z)`.

src/HypergeometricFunctions.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ module HypergeometricFunctions
77

88
using DualNumbers, LinearAlgebra, SpecialFunctions
99

10-
export _₂F₁, _₃F₂, pFq
10+
export _₁F₁, _₂F₁, _₃F₂, pFq
1111

1212
include("specialfunctions.jl")
1313
include("gauss.jl")
14+
include("kummer.jl")
1415
include("generalized.jl")
1516
include("drummond.jl")
1617
include("weniger.jl")

src/generalized.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ function pFq(α::AbstractVector, β::AbstractVector, z; kwds...)
1010
return exp(z)
1111
elseif length(α) == 1 && length(β) == 0
1212
return exp(-α[1]*log1p(-z))
13+
elseif length(α) == 1 && length(β) == 1
14+
return _₁F₁(α[1], β[1], float(z))
1315
elseif length(α) == 2 && length(β) == 1
1416
return _₂F₁(α[1], α[2], β[1], float(z))
1517
elseif abs(z) ρ

src/kummer.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""
2+
Compute Kummer's confluent hypergeometric function `₁F₁(a; b; z)`.
3+
"""
4+
function _₁F₁(a, b, z)
5+
if real(z) 0
6+
return _₁F₁maclaurin(a, b, z)
7+
else
8+
return exp(z)*_₁F₁(b-a, b, -z)
9+
end
10+
end
11+
12+
const M = _₁F₁

src/specialfunctions.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function unsafe_gamma(x::BigFloat)
147147
return z
148148
end
149149
unsafe_gamma(z::Dual) = (r = realpart(z);w = unsafe_gamma(r); dual(w, w*digamma(r)*dualpart(z)))
150-
unsafe_gamma(z) = gamma(z)
150+
unsafe_gamma(z) = gamma(z)
151151
"""
152152
@lanczosratio(z, ϵ, c₀, c...)
153153
@@ -492,6 +492,17 @@ function _₂F₁taylor(a::Number, b::Number, c::Number, z::Number)
492492
return S₁
493493
end
494494

495+
function _₁F₁maclaurin(a::Number, b::Number, z::Number)
496+
T = float(promote_type(typeof(a), typeof(b), typeof(z)))
497+
S₀, S₁, j = one(T), one(T)+a*z/b, 1
498+
while errcheck(S₀, S₁, 10eps(real(T))) || j 1
499+
rⱼ = (a+j)/((b+j)*(j+1))
500+
S₀, S₁ = S₁, S₁+(S₁-S₀)*rⱼ*z
501+
j += 1
502+
end
503+
return S₁
504+
end
505+
495506
function _₃F₂maclaurin(a₁, a₂, a₃, b₁, b₂, z)
496507
T = float(promote_type(typeof(a₁), typeof(a₂), typeof(a₃), typeof(b₁), typeof(b₂), typeof(z)))
497508
S₀, S₁, j = one(T), one(T)+(a₁*a₂*a₃*z)/(b₁*b₂), 1

0 commit comments

Comments
 (0)