Skip to content

Commit

Permalink
fix erf(x,y) for small arguments (#227)
Browse files Browse the repository at this point in the history
* fix erf(x,y) for small arguments

* bump version

* NaN tests
  • Loading branch information
cossio authored May 14, 2020
1 parent cbe5346 commit fc960c6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "SpecialFunctions"
uuid = "276daf66-3868-5448-9aa4-cd146d93841b"
version = "0.10.1"
version = "0.10.2"

[deps]
OpenSpecFun_jll = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
Expand Down
4 changes: 3 additions & 1 deletion src/erf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ See also: [`erfc(x)`](@ref SpecialFunctions.erfc), [`erfcx(x)`](@ref SpecialFunc
erf

function erf(x::Real, y::Real)
if 0 x && 0 y
if abs(x) 1/√2 && abs(y) 1/√2
erf(y) - erf(x)
elseif 0 x && 0 y
erfc(x) - erfc(y)
elseif x 0 && y 0
erfc(-y) - erfc(-x)
Expand Down
4 changes: 4 additions & 0 deletions test/erf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,9 @@
@test erf(11, 10) -2.08848758232167861905709161e-45
@test erf(-11, -10) 2.08848758232167861905709161e-45
@test erf(-1, 1) 1.68540158589942973868244127017
@test erf(1e-30, 2e-30) 1.12837916709551257389615890312e-30
@test isnan(erf(NaN, 0))
@test isnan(erf(0, NaN))
@test isnan(erf(NaN, NaN))
end
end

2 comments on commit fc960c6

@ararslan
Copy link
Member

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/14762

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.10.2 -m "<description of version>" fc960c66e56d230a83999d8fa76c2c5bba28441c
git push origin v0.10.2

Please sign in to comment.