Skip to content

Commit e37de8f

Browse files
close #66
1 parent 7488b50 commit e37de8f

File tree

6 files changed

+33
-31
lines changed

6 files changed

+33
-31
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.17"
3+
version = "0.3.18"
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
@@ -19,7 +19,7 @@ julia> pFq((1, ), (2, ), 0.01) # ≡ expm1(0.01)/0.01
1919
1.0050167084168058
2020

2121
julia> pFq((1/3, ), (2/3, ), -1000) # ₁F₁
22-
0.050558053946448994
22+
0.050558053946448855
2323

2424
julia> pFq((1, 2), (4, ), 1) # a well-poised ₂F₁
2525
2.9999999999999996

src/confluent.jl

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# The references to special cases are to NIST's DLMF.
22

33
"""
4-
Compute Kummer's confluent hypergeometric function `M(a, b, z) = ₁F₁(a; b; z)`.
4+
Compute Kummer's confluent hypergeometric function `M(a, b, z) = ₁F₁(a, b; z)`.
55
"""
66
function _₁F₁(a, b, z; kwds...)
77
z = float(z)
@@ -24,30 +24,20 @@ function _₁F₁(a, b, z; kwds...)
2424
end
2525

2626
function _₁F₁general(a, b, z; kwds...)
27-
if abs(z) > 10 # TODO: check this algorithmic parameter cutoff, determine when to use rational algorithms
28-
if isreal(z)
29-
if real(z) 0 # 13.7.1
30-
return gamma(b)/gamma(a)*exp(z)*z^(a-b)*pFq((1-a, b-a), (), inv(z); kwds...)
31-
else # 13.7.1 + 13.2.39
32-
return gamma(b)/gamma(b-a)*(-z)^-a*pFq((a, a-b+1), (), -inv(z); kwds...)
33-
end
34-
else # 13.7.2
35-
return gamma(b)/gamma(a)*exp(z)*z^(a-b)*pFq((1-a, b-a), (), inv(z); kwds...) + gamma(b)/gamma(b-a)*(-z)^-a*pFq((a, a-b+1), (), -inv(z); kwds...)
36-
end
37-
elseif real(z) 0
27+
if real(z) > 0
3828
return _₁F₁maclaurin(a, b, z; kwds...)
39-
else # 13.2.39
40-
return exp(z)*_₁F₁(b-a, b, -z; kwds...)
29+
else
30+
return pFqweniger((a, ), (b, ), z; kwds...)
4131
end
4232
end
4333

4434
"""
45-
Compute Kummer's confluent hypergeometric function `M(a, b, z) = ₁F₁(a; b; z)`.
35+
Compute Kummer's confluent hypergeometric function `M(a, b, z) = ₁F₁(a, b; z)`.
4636
"""
4737
const M = _₁F₁
4838

4939
"""
50-
Compute Tricomi's confluent hypergeometric function `U(a, b, z) ∼ z⁻ᵃ ₂F₀([a, a-b+1]; []; -z⁻¹)`.
40+
Compute Tricomi's confluent hypergeometric function `U(a, b, z) ∼ z⁻ᵃ ₂F₀((a, a-b+1), (); -z⁻¹)`.
5141
"""
5242
function U(a, b, z; kwds...)
5343
return z^-a*pFq((a, a-b+1), (), -inv(z); kwds...)

src/gauss.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# The references to special cases are to Table of Integrals, Series, and Products, § 9.121, followed by NIST's DLMF.
22

33
"""
4-
Compute the Gauss hypergeometric function `₂F₁(a, b; c; z)`.
4+
Compute the Gauss hypergeometric function `₂F₁(a, b, c; z)`.
55
"""
66
function _₂F₁(a, b, c, z; method::Symbol = :general, kwds...)
77
z = float(z)
@@ -56,7 +56,7 @@ function _₂F₁(a, b, c, z; method::Symbol = :general, kwds...)
5656
end
5757

5858
"""
59-
Compute the Gauss hypergeometric function `₂F₁(a, b; c; z)` with positive parameters a, b, and c and argument 0 ≤ z ≤ 1. Useful for statisticians.
59+
Compute the Gauss hypergeometric function `₂F₁(a, b, c; z)` with positive parameters a, b, and c and argument 0 ≤ z ≤ 1. Useful for statisticians.
6060
"""
6161
function _₂F₁positive(a, b, c, z; kwds...)
6262
@assert a > 0 && b > 0 && c > 0 && 0 z 1
@@ -68,7 +68,7 @@ function _₂F₁positive(a, b, c, z; kwds...)
6868
end
6969

7070
"""
71-
Compute the Gauss hypergeometric function `₂F₁(a, b; c; z)` with general parameters a, b, and c.
71+
Compute the Gauss hypergeometric function `₂F₁(a, b, c; z)` with general parameters a, b, and c.
7272
This polyalgorithm is designed based on the paper
7373
7474
N. Michel and M. V. Stoitsov, Fast computation of the Gauss hypergeometric function with all its parameters complex with application to the Pöschl–Teller–Ginocchio potential wave functions, Comp. Phys. Commun., 178:535–551, 2008.
@@ -98,7 +98,7 @@ function _₂F₁general(a, b, c, z; kwds...)
9898
end
9999

100100
"""
101-
Compute the Gauss hypergeometric function `₂F₁(a, b; c; z)` with general parameters a, b, and c.
101+
Compute the Gauss hypergeometric function `₂F₁(a, b, c; z)` with general parameters a, b, and c.
102102
This polyalgorithm is designed based on the review
103103
104104
J. W. Pearson, S. Olver and M. A. Porter, Numerical methos for the computation of the confluent and Gauss hypergeometric functions, arXiv:1407.7786, 2014.

src/generalized.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pFq(α::NTuple{2, Any}, β::NTuple{1}, z; kwds...) = _₂F₁(α[1], α[2], β[1
1515
function pFq::NTuple{p, Any}, β::NTuple{q, Any}, z; kwds...) where {p, q}
1616
z = float(z)
1717
if p q
18-
if real(z) 0
18+
if real(z) > 0
1919
return pFqmaclaurin(α, β, z; kwds...)
2020
else
2121
return pFqweniger(α, β, z; kwds...)
@@ -45,8 +45,11 @@ function pFqcontinuedfraction(α::AbstractVector{S}, β::AbstractVector{U}, z::V
4545
return 1 + z * prod(α) / prod(β) / (1 + K)
4646
end
4747

48+
"""
49+
Compute the generalized hypergeometric function `₃F₂(a₁, 1, 1, b₁, 2; z)`.
50+
"""
51+
_₃F₂(a₁, b₁, z; kwds...) = _₃F₂(a₁, 1, 1, b₁, 2, z; kwds...)
4852
"""
4953
Compute the generalized hypergeometric function `₃F₂(a₁, a₂, a₃, b₁, b₂; z)`.
5054
"""
5155
_₃F₂(a₁, a₂, a₃, b₁, b₂, z; kwds...) = pFq((a₁, a₂, a₃), (b₁, b₂), z; kwds...)
52-
_₃F₂(a₁, b₁, z; kwds...) = _₃F₂(a₁, 1, 1, b₁, 2, z; kwds...)

test/runtests.jl

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,23 +480,32 @@ end
480480
@test M(-2, -3, 0.5) 1.375
481481
@test M(0.5, 1.5, -1000) 0.028024956081989644 # From #46
482482
for (S, T) in ((Float64, BigFloat),)
483+
a = T(8.9)
484+
b = T(0.5)
485+
for x in T(-36):T(2):T(70)
486+
@test M(S(a), S(b), S(x)) S(M(a, b, x)) # From #45
487+
end
488+
a = T(5)/6
489+
b = T(1)/2
490+
for x in T(-5):T(0.25):T(5)
491+
@test M(S(a), S(b), -S(x)^2) S(M(a, b, -x^2)) # From #66
492+
end
483493
b = 1
484-
z = T(1)/3
485-
x = S(z)
494+
x = T(1)/3
486495
for a in S(1):S(0.5):S(7)
487-
@test M(a, b, x) S(M(a, b, z))
496+
@test M(a, b, S(x)) S(M(a, b, x))
488497
end
489498
end
490499
end
491500

492501
@testset "U" begin
493-
# From #55
502+
@test U(1, 1, 1.f0) 0.5963473623231942 # the Euler series
503+
@test U(1, 1, 1) == 0.5963473623231942
494504
for (S, T) in ((Float64, BigFloat),)
495505
b = 0
496-
z = T(1)/3
497-
x = S(z)
506+
x = T(1)/3
498507
for a in S(1):S(0.5):S(7)
499-
@test U(a, b, x) S(U(a, b, z))
508+
@test U(a, b, S(x)) S(U(a, b, x)) # From #55
500509
end
501510
end
502511
end

0 commit comments

Comments
 (0)