SpecialFunctions.jl icon indicating copy to clipboard operation
SpecialFunctions.jl copied to clipboard

erfcx(BigFloat) misses a connection segment

Open putianyi889 opened this issue 4 years ago • 5 comments

Plots.plot(20000:40000,erfcx.(BigFloat(20000):40000), yaxis=:log)

download

putianyi889 avatar Nov 22 '21 16:11 putianyi889

Rather than a plot, can you just give a single point where it is not giving the expected output?

stevengj avatar Nov 22 '21 16:11 stevengj

NaN begins from 27282 and ends at 32768 (only counted integer values).

julia> erfcx(BigFloat(27281))
2.068067824378598630288975599374805428229073376310733390485590903274295760840468e-05

julia> erfcx(BigFloat(27282))
NaN

julia> erfcx(BigFloat(32768))
NaN

julia> erfcx(BigFloat(32769))
1.721717425875220708758243853735950836098892035259101544766730697542870688938946e-05

putianyi889 avatar Nov 22 '21 16:11 putianyi889

It seems the heuristic in https://github.com/JuliaMath/SpecialFunctions.jl/blob/a1df96daaeae3ec663593a7c2d76f4245725ac5e/src/erf.jl#L52 is wrong and internal overflow occurs also for values less than or equal to 0x1p15 = 32768.

devmotion avatar Feb 06 '22 19:02 devmotion