|
1 | 1 | ### domain errors
|
| 2 | +using IrrationalConstants |
2 | 3 |
|
3 | 4 | @test_throws DomainError lambertw(-2.0, 0)
|
4 | 5 | @test_throws DomainError lambertw(-2.0, -1)
|
|
21 | 22 | @test @inferred(lambertw(MathConstants.e, 0)) == 1
|
22 | 23 |
|
23 | 24 | ## 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 |
26 | 27 |
|
27 | 28 | ## convert irrationals to float
|
28 | 29 |
|
|
76 | 77 | # bug fix
|
77 | 78 | # The routine will start at -1/e + eps * im, rather than -1/e + 0im,
|
78 | 79 | # 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 |
80 | 81 |
|
81 | 82 | # lambertw for BigFloat is more precise than Float64. Note
|
82 | 83 | # that 70 digits in test is about 35 digits in W
|
|
104 | 105 | @testset "lambertwbp()" begin
|
105 | 106 | # not a domain error, but not implemented
|
106 | 107 | @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) |
110 | 111 |
|
111 | 112 | # Expansions about branch point converges almost to machine precision
|
112 | 113 | # except near the radius of convergence.
|
|
116 | 117 | setprecision(2048) do
|
117 | 118 | z = BigFloat(10)^(-12)
|
118 | 119 | 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 |
121 | 122 |
|
122 | 123 | z *= 1.1
|
123 | 124 | if z > 0.23 break end
|
|
127 | 128 |
|
128 | 129 | # test the expansion about branch point for k=-1,
|
129 | 130 | # 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 |
131 | 132 | @test @inferred(lambertwbp(Complex(.01, .01), -1)) ≈ Complex(-0.2755038208041206, -0.1277888928494641) atol=1e-14
|
132 | 133 | end
|
0 commit comments