JuliaMath / HypergeometricFunctions.jl

A Julia package for calculating hypergeometric functions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

When α=-1, the calculation precision of `drummond1F1` is insufficient

cnkjw opened this issue · comments

commented

Comparison with GSL results is as follows:

using GSL, HypergeometricFunctions, Random
for α = -1:2, β = 1:2
    z = rand()
    v1 = GSL.sf_hyperg_1F1(α, β, z)
    v2 = HypergeometricFunctions.drummond1F1(α, β, z)
    println(string("α=", α, ", β=", β, ", z=", z, ", GSL: ", v1, ", This Package: ", v2))
end

Results:

α=-1, β=1, z=0.5206639914627536, GSL: 0.4793360085372465, This Package: 1.0
α=-1, β=2, z=0.7687687859342793, GSL: 0.6156156070328604, This Package: 1.0
α=0, β=1, z=0.5008476664663666, GSL: 1.0, This Package: 1.0
α=0, β=2, z=0.5334620204375811, GSL: 1.0, This Package: 1.0
α=1, β=1, z=0.8936251832518598, GSL: 2.4439734630515666, This Package: 2.443973463051566
α=1, β=2, z=0.2143718180788492, GSL: 1.1152738492474166, This Package: 1.1152738492474172
α=2, β=1, z=0.9362142466180694, GSL: 4.937943228150445, This Package: 4.9379432281504485
α=2, β=2, z=0.5491205981667622, GSL: 1.7317294619931187, This Package: 1.7317294619931187

Yes, it looks like it's exiting one step early for an upper parameter a negative integer. Thanks for the bug report!

This is fixed on master:

julia> using HypergeometricFunctions

julia> α = -1
-1

julia> β = 1
1

julia> z = 0.5206639914627536
0.5206639914627536

julia> HypergeometricFunctions.drummond1F1(α, β, z)
0.4793360085372464

julia> β = 2
2

julia> z = 0.7687687859342793
0.7687687859342793

julia> HypergeometricFunctions.drummond1F1(α, β, z)
0.6156156070328603

julia> HypergeometricFunctions.drummond1F1(-15, 3, 0.5)
-0.05706166404604559

julia> wolfram = -0.05706166404604563442269060981661039045103782109695586197

julia> 

Please note, this code is experimental and is based on ongoing research.

commented

Thanks!