Skip to content

Commit fc960c6

Browse files
authored
fix erf(x,y) for small arguments (#227)
* fix erf(x,y) for small arguments * bump version * NaN tests
1 parent cbe5346 commit fc960c6

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "SpecialFunctions"
22
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
3-
version = "0.10.1"
3+
version = "0.10.2"
44

55
[deps]
66
OpenSpecFun_jll = "efe28fd5-8261-553b-a9e1-b2916fc3738e"

src/erf.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ See also: [`erfc(x)`](@ref SpecialFunctions.erfc), [`erfcx(x)`](@ref SpecialFunc
6969
erf
7070

7171
function erf(x::Real, y::Real)
72-
if 0 x && 0 y
72+
if abs(x) 1/√2 && abs(y) 1/√2
73+
erf(y) - erf(x)
74+
elseif 0 x && 0 y
7375
erfc(x) - erfc(y)
7476
elseif x 0 && y 0
7577
erfc(-y) - erfc(-x)

test/erf.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,9 @@
137137
@test erf(11, 10) -2.08848758232167861905709161e-45
138138
@test erf(-11, -10) 2.08848758232167861905709161e-45
139139
@test erf(-1, 1) 1.68540158589942973868244127017
140+
@test erf(1e-30, 2e-30) 1.12837916709551257389615890312e-30
141+
@test isnan(erf(NaN, 0))
142+
@test isnan(erf(0, NaN))
143+
@test isnan(erf(NaN, NaN))
140144
end
141145
end

0 commit comments

Comments
 (0)