|
8 | 8 | ## math constant e |
9 | 9 | @test_throws DomainError lambertw(MathConstants.e, 1) |
10 | 10 | @test_throws DomainError lambertw(MathConstants.e, -1) |
| 11 | +@test_throws DomainError lambertw(.3, 2) |
11 | 12 |
|
12 | 13 | ## integer arguments return floating point types |
13 | 14 | @test @inferred(lambertw(0)) isa AbstractFloat |
@@ -100,36 +101,32 @@ end |
100 | 101 | @test lambertw(BigInt(1)) == big(SpecialFunctions.omega) |
101 | 102 |
|
102 | 103 | ### expansion about branch point |
103 | | - |
104 | | -# not a domain error, but not implemented |
105 | | -@test_throws ArgumentError lambertwbp(1, 1) |
106 | | - |
107 | | -@test_throws DomainError lambertw(.3, 2) |
108 | | - |
109 | | -# Expansions about branch point converges almost to machine precision |
110 | | -# except near the radius of convergence. |
111 | | -# Complex args are not tested here. |
112 | | - |
113 | | -if Int != Int32 |
114 | | - |
115 | | -@testset "double-precision expansion near branch point using BigFloats" begin |
116 | | - setprecision(2048) do |
117 | | - z = BigFloat(10)^(-12) |
118 | | - for _ in 1:300 |
119 | | - innerarg = z - inv(big(MathConstants.e)) |
120 | | - |
121 | | - @test lambertwbp(Float64(z)) ≈ 1 + lambertw(innerarg) atol=5e-16 |
122 | | - @test lambertwbp(Float64(z), -1) ≈ 1 + lambertw(innerarg, -1) atol=5e-16 |
123 | | - z *= 1.1 |
124 | | - if z > 0.23 break end |
125 | | - |
| 104 | +@testset "lambertwbp()" begin |
| 105 | + # not a domain error, but not implemented |
| 106 | + @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) |
| 110 | + |
| 111 | + # Expansions about branch point converges almost to machine precision |
| 112 | + # except near the radius of convergence. |
| 113 | + # Complex args are not tested here. |
| 114 | + |
| 115 | + @testset "double-precision expansion near branch point using BigFloats" begin |
| 116 | + setprecision(2048) do |
| 117 | + z = BigFloat(10)^(-12) |
| 118 | + 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 |
| 121 | + |
| 122 | + z *= 1.1 |
| 123 | + if z > 0.23 break end |
| 124 | + end |
126 | 125 | end |
127 | 126 | end |
128 | | -end |
129 | | - |
130 | | -# test the expansion about branch point for k=-1, |
131 | | -# by comparing to exact BigFloat calculation. |
132 | | -@test @inferred(lambertwbp(1e-20, -1)) ≈ 1 + lambertw(-inv(big(MathConstants.e)) + BigFloat(10)^(-20), -1) atol=1e-16 |
133 | | -@test @inferred(lambertwbp(Complex(.01, .01), -1)) ≈ Complex(-0.2755038208041206, -0.1277888928494641) atol=1e-14 |
134 | 127 |
|
135 | | -end # if Int != Int32 |
| 128 | + # test the expansion about branch point for k=-1, |
| 129 | + # 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(Complex(.01, .01), -1)) ≈ Complex(-0.2755038208041206, -0.1277888928494641) atol=1e-14 |
| 132 | +end |
0 commit comments