Skip to content

Commit 52091cd

Browse files
committed
lambertw(): use inve constant in tests
1 parent 601582c commit 52091cd

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

test/lambertw.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
### domain errors
2+
using IrrationalConstants
23

34
@test_throws DomainError lambertw(-2.0, 0)
45
@test_throws DomainError lambertw(-2.0, -1)
@@ -21,8 +22,8 @@
2122
@test @inferred(lambertw(MathConstants.e, 0)) == 1
2223

2324
## value at branch point where real branches meet
24-
@test lambertw(-inv(MathConstants.e), 0) == lambertw(-inv(MathConstants.e), -1) == -1
25-
@test typeof(lambertw(-inv(MathConstants.e), 0)) == typeof(lambertw(-inv(MathConstants.e), -1)) <: AbstractFloat
25+
@test lambertw(-inve, 0) == lambertw(-inve, -1) == -1
26+
@test typeof(lambertw(-inve, 0)) == typeof(lambertw(-inve, -1)) <: AbstractFloat
2627

2728
## convert irrationals to float
2829

@@ -76,7 +77,7 @@ end
7677
# bug fix
7778
# The routine will start at -1/e + eps * im, rather than -1/e + 0im,
7879
# otherwise root finding will fail
79-
@test lambertw(-inv(MathConstants.e) + 0im, -1) -1 atol=1e-7
80+
@test lambertw(-inve + 0im, -1) -1 atol=1e-7
8081

8182
# lambertw for BigFloat is more precise than Float64. Note
8283
# that 70 digits in test is about 35 digits in W
@@ -104,9 +105,9 @@ end
104105
@testset "lambertwbp()" begin
105106
# not a domain error, but not implemented
106107
@test_throws ArgumentError lambertwbp(1, 1)
107-
@test_throws ArgumentError lambertwbp(inv(MathConstants.e) + 1e-5, 2)
108-
@test_throws DomainError lambertwbp(inv(MathConstants.e) + 1e-5, 0)
109-
@test_throws DomainError lambertwbp(inv(MathConstants.e) + 1e-5, -1)
108+
@test_throws ArgumentError lambertwbp(inve + 1e-5, 2)
109+
@test_throws DomainError lambertwbp(inve + 1e-5, 0)
110+
@test_throws DomainError lambertwbp(inve + 1e-5, -1)
110111

111112
# Expansions about branch point converges almost to machine precision
112113
# except near the radius of convergence.
@@ -116,8 +117,8 @@ end
116117
setprecision(2048) do
117118
z = BigFloat(10)^(-12)
118119
for _ in 1:300
119-
@test lambertwbp(Float64(z)) 1 + lambertw(z - inv(big(MathConstants.e))) atol=5e-16
120-
@test lambertwbp(Float64(z), -1) 1 + lambertw(z - inv(big(MathConstants.e)), -1) atol=5e-16
120+
@test lambertwbp(Float64(z)) 1 + lambertw(z - big(inve)) atol=5e-16
121+
@test lambertwbp(Float64(z), -1) 1 + lambertw(z - big(inve), -1) atol=5e-15
121122

122123
z *= 1.1
123124
if z > 0.23 break end
@@ -127,6 +128,6 @@ end
127128

128129
# test the expansion about branch point for k=-1,
129130
# by comparing to exact BigFloat calculation.
130-
@test @inferred(lambertwbp(1e-20, -1)) 1 + lambertw(-inv(big(MathConstants.e)) + BigFloat(10)^(-20), -1) atol=1e-16
131+
@test @inferred(lambertwbp(1e-20, -1)) 1 + lambertw(-big(inve) + BigFloat(10)^(-20), -1) atol=1e-16
131132
@test @inferred(lambertwbp(Complex(.01, .01), -1)) Complex(-0.2755038208041206, -0.1277888928494641) atol=1e-14
132133
end

0 commit comments

Comments
 (0)