File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,11 @@ export
27
27
logπ, # log(π)
28
28
log2π, # log(2π)
29
29
log4π, # log(4π)
30
- invℯ # 1 / ℯ
30
+ invℯ, # 1 / ℯ
31
+
32
+ LambertW_Ω # Ω exp(Ω) = 1
31
33
32
34
include (" stats.jl" )
35
+ include (" lambertw_omega.jl" )
33
36
34
37
end # module
Original file line number Diff line number Diff line change
1
+ # lazy-initialized LambertW Omega at 256-bit precision
2
+ const LambertW_Omega_BigFloat256 = Ref {BigFloat} ()
3
+
4
+ # compute BigFloat Omega constant at arbitrary precision
5
+ function compute_LambertW_Omega ()
6
+ # initialize Omega_BigFloat256
7
+ isassigned (LambertW_Omega_BigFloat256) ||
8
+ (LambertW_Omega_BigFloat256[] = BigFloat (" 0.5671432904097838729999686622103555497538157871865125081351310792230457930866845666932194" ))
9
+ o = LambertW_Omega_BigFloat256[] # initial value
10
+ precision (BigFloat) <= 256 && return o
11
+ # iteratively improve the precision of the constant
12
+ myeps = eps (BigFloat)
13
+ for _ in 1 : 100
14
+ o_ = (1 + o) / (1 + exp (o))
15
+ abs (o - o_) <= myeps && break
16
+ o = o_
17
+ end
18
+ return o
19
+ end
20
+
21
+ @irrational LambertW_Ω 0.567143290409783872999968662210355 compute_LambertW_Omega ()
22
+
23
+ """
24
+ Lambert's Omega (Ω) constant, such that Ω exp(Ω) = 1.
25
+
26
+ W(1) = Ω, where W(t) is the *Lambert's W function*
27
+
28
+ # See
29
+ https://en.wikipedia.org/wiki/Omega_constant
30
+ """
31
+ LambertW_Ω
32
+
Original file line number Diff line number Diff line change 43
43
@testset " 1/e" begin
44
44
@test isapprox (invℯ, exp (- 1 ))
45
45
end
46
+
47
+ @testset " LambertW_Omega" begin
48
+ @test isapprox (LambertW_Ω * exp (LambertW_Ω), 1 )
49
+ setprecision (BigFloat, 2048 ) do
50
+ o = big (LambertW_Ω)
51
+ @test isapprox (o * exp (o), 1 , atol= eps (BigFloat))
52
+ end
53
+ end
You can’t perform that action at this time.
0 commit comments