Skip to content

Commit

Permalink
close #68
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaelSlevinsky committed Jul 27, 2023
1 parent 46ec66a commit 1ed19b0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "HypergeometricFunctions"
uuid = "34004b35-14d8-5ef3-9330-4cdb6864b03a"
version = "0.3.21"
version = "0.3.22"

[deps]
DualNumbers = "fa6b7ba4-c1ee-5f82-b5fc-ecf0adba8f74"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://github.com/JuliaMath/HypergeometricFunctions.jl/workflows/CI/badge.svg)](https://github.com/JuliaMath/HypergeometricFunctions.jl/actions?query=workflow%3ACI) [![codecov](https://codecov.io/gh/JuliaMath/HypergeometricFunctions.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaMath/HypergeometricFunctions.jl) [![](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaMath.github.io/HypergeometricFunctions.jl/stable) [![](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaMath.github.io/HypergeometricFunctions.jl/dev)

This package provides an implementation of the generalized hypergeometric function `pFq((α1,…,αp), (β1,…,βq), z)`.
This package provides an implementation of the generalized hypergeometric function `pFq(α, β, z)`.

```julia
julia> using HypergeometricFunctions
Expand Down
8 changes: 4 additions & 4 deletions src/confluent.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The references to special cases are to NIST's DLMF.

"""
Compute Kummer's confluent hypergeometric function `₁F₁(a, b; z)`.
Compute Kummer's confluent hypergeometric function `₁F₁(a, b, z)`.
"""
function _₁F₁(a, b, z; kwds...)
z = float(z)
Expand All @@ -11,7 +11,7 @@ function _₁F₁(a, b, z; kwds...)
if -a ℕ₀ && real(a) real(b)
return _₁F₁maclaurin(a, b, z; kwds...)
else
return throw(DomainError(b, "M(a, b, z) = ₁F₁(a; b; z) is not defined for negative integer b unless a is a nonpositive integer and a ≥ b."))
return throw(DomainError(b, "M(a, b, z) = ₁F₁(a, b, z) is not defined for negative integer b unless a is a nonpositive integer and a ≥ b."))
end
elseif -a ℕ₀
return _₁F₁maclaurin(a, b, z; kwds...)
Expand All @@ -32,12 +32,12 @@ function _₁F₁general(a, b, z; kwds...)
end

"""
Compute Kummer's confluent hypergeometric function `M(a, b, z) = ₁F₁(a, b; z)`.
Compute Kummer's confluent hypergeometric function `M(a, b, z) = ₁F₁(a, b, z)`.
"""
const M = _₁F₁

"""
Compute Tricomi's confluent hypergeometric function `U(a, b, z) ∼ z⁻ᵃ ₂F₀((a, a-b+1), (); -z⁻¹)`.
Compute Tricomi's confluent hypergeometric function `U(a, b, z) ∼ z⁻ᵃ ₂F₀((a, a-b+1), (), -z⁻¹)`.
"""
function U(a, b, z; kwds...)
return z^-a*pFq((a, a-b+1), (), -inv(z); kwds...)
Expand Down
8 changes: 4 additions & 4 deletions src/gauss.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The references to special cases are to Table of Integrals, Series, and Products, § 9.121, followed by NIST's DLMF.

"""
Compute the Gauss hypergeometric function `₂F₁(a, b, c; z)`.
Compute the Gauss hypergeometric function `₂F₁(a, b, c, z)`.
"""
function _₂F₁(a, b, c, z; method::Symbol = :general, kwds...)
z = float(z)
Expand Down Expand Up @@ -58,7 +58,7 @@ function _₂F₁(a, b, c, z; method::Symbol = :general, kwds...)
end

"""
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.
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.
"""
function _₂F₁positive(a, b, c, z; kwds...)
@assert a > 0 && b > 0 && c > 0 && 0 z 1
Expand All @@ -70,7 +70,7 @@ function _₂F₁positive(a, b, c, z; kwds...)
end

"""
Compute the Gauss hypergeometric function `₂F₁(a, b, c; z)` with general parameters a, b, and c.
Compute the Gauss hypergeometric function `₂F₁(a, b, c, z)` with general parameters a, b, and c.
This polyalgorithm is designed based on the paper
> 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](https://doi.org/10.1016/j.cpc.2007.11.007), *Comp. Phys. Commun.*, **178**:535–551, 2008.
Expand Down Expand Up @@ -100,7 +100,7 @@ function _₂F₁general(a, b, c, z; kwds...)
end

"""
Compute the Gauss hypergeometric function `₂F₁(a, b, c; z)` with general parameters a, b, and c.
Compute the Gauss hypergeometric function `₂F₁(a, b, c, z)` with general parameters a, b, and c.
This polyalgorithm is designed based on the review
> J. W. Pearson, S. Olver and M. A. Porter, [Numerical methods for the computation of the confluent and Gauss hypergeometric functions](https://doi.org/10.1007/s11075-016-0173-0), *Numer. Algor.*, **74**:821–866, 2017.
Expand Down
8 changes: 4 additions & 4 deletions src/generalized.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@doc raw"""
pFq(α, β; z)
pFq(α, β, z)
Compute the generalized hypergeometric function, defined by
```math
{}_pF_q(α, β; z) = \sum_{k=0}^\infty \dfrac{(\alpha_1)_k\cdots(\alpha_p)_k}{(\beta_1)_k\cdots(\beta_q)_k}\dfrac{z^k}{k!},
{}_pF_q(α, β, z) = \sum_{k=0}^\infty \dfrac{(\alpha_1)_k\cdots(\alpha_p)_k}{(\beta_1)_k\cdots(\beta_q)_k}\dfrac{z^k}{k!},
```
where the series converges and elsewhere by analytic continuation.
Expand Down Expand Up @@ -79,7 +79,7 @@ end
pFq::AbstractVector, β::AbstractVector, z; kwds...) = pFq(Tuple(α), Tuple(β), z; kwds...)

"""
Compute the generalized hypergeometric function `pFq(α, β; z)` by continued fraction.
Compute the generalized hypergeometric function `pFq(α, β, z)` by continued fraction.
"""
function pFqcontinuedfraction::AbstractVector{S}, β::AbstractVector{U}, z::V) where {S, U, V}
T = promote_type(S, U, V)
Expand All @@ -91,7 +91,7 @@ function pFqcontinuedfraction(α::AbstractVector{S}, β::AbstractVector{U}, z::V
end

"""
Compute the generalized hypergeometric function `₃F₂(a₁, 1, 1, b₁, 2; z)`.
Compute the generalized hypergeometric function `₃F₂(a₁, 1, 1, b₁, 2, z)`.
"""
_₃F₂(a₁, b₁, z; kwds...) = _₃F₂(a₁, 1, 1, b₁, 2, z; kwds...)
"""
Expand Down
8 changes: 5 additions & 3 deletions src/specialfunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,10 @@ function Aone(a, b, c, w, m::Int, ϵ)
end

function Bone(a, b, c, w, m::Int, ϵ)
T = promote_type(typeof(a), typeof(b), typeof(c), typeof(w), typeof(m), typeof(ϵ))
βₙ, γₙ = reconeβ₀(a, b, c, w, m, ϵ)*one(w), reconeγ₀(a, b, c, w, m, ϵ)*w
ret, n = βₙ, 0
while abs(βₙ) > 8abs(ret)*eps() || n 0
while abs(βₙ) > 8abs(ret)*eps(real(T)) || n 0
βₙ = (a+m+n+ϵ)*(b+m+n+ϵ)/((m+n+1+ϵ)*(n+1))*w*βₙ + ( (a+m+n)*(b+m+n)/(m+n+1) - (a+m+n) - (b+m+n) - ϵ + (a+m+n+ϵ)*(b+m+n+ϵ)/(n+1) )*γₙ/((m+n+1+ϵ)*(n+1-ϵ))
ret += βₙ
γₙ *= (a+m+n)*(b+m+n)/((m+n+1)*(n+1-ϵ))*w
Expand Down Expand Up @@ -412,10 +413,11 @@ function AInf(a, b, c, w, m::Int, ϵ)
end

function BInf(a, b, c, win, m::Int, ϵ)
T = promote_type(typeof(a), typeof(b), typeof(c), typeof(win), typeof(m), typeof(ϵ))
w = win
βₙ, γₙ = recInfβ₀(a, b, c, win, m, ϵ)*one(w), recInfγ₀(a, b, c, win, m, ϵ)*w
ret, n = βₙ, 0
while abs(βₙ) > 8abs(ret)*eps() || n 0
while abs(βₙ) > 8abs(ret)*eps(real(T)) || n 0
βₙ = (a+m+n+ϵ)*(1-c+a+m+n+ϵ)/((m+n+1+ϵ)*(n+1))*w*βₙ + ( (a+m+n)*(1-c+a+m+n)/(m+n+1) - (a+m+n) - (1-c+a+m+n) - ϵ + (a+m+n+ϵ)*(1-c+a+m+n+ϵ)/(n+1) )*γₙ/((m+n+1+ϵ)*(n+1-ϵ))
ret += βₙ
γₙ *= (a+m+n)*(1-c+a+m+n)/((m+n+1)*(n+1-ϵ))*w
Expand Down Expand Up @@ -555,7 +557,7 @@ function pFqmaclaurin(a::NTuple{p, S}, b::NTuple{q, U}, z::V; kmax::Int = KMAX)
S₀, S₁ = S₁, S₁+(S₁-S₀)*rₖ
k += 1
end
k < kmax || @warn "Maclaurin approximation to "*pFq2string(Val{p}(), Val{q}())*" reached the maximum degree of "*string(kmax)*"."
k < kmax || @warn "Maclaurin approximation to "*pFq2string(Val(p), Val(q))*" reached the maximum degree of "*string(kmax)*"."
return S₁
end

Expand Down

2 comments on commit 1ed19b0

@MikaelSlevinsky
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/88466

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.22 -m "<description of version>" 1ed19b0dfeb683b7f0a5e3cbdbe8f68d6a0efcba
git push origin v0.3.22

Please sign in to comment.