Skip to content

Commit 5ed8df8

Browse files
committed
lambertw: use inv(e)
1 parent 20e5d32 commit 5ed8df8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lambertw.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ end
5757
function lambertw_branch_zero(x::T, maxits) where T<:Real
5858
isfinite(x) || return x
5959
one_t = one(T)
60-
oneoe = -one_t / convert(T, MathConstants.e) # The branch point
60+
oneoe = -inv(convert(T, MathConstants.e)) # The branch point
6161
x == oneoe && return -one_t
6262
oneoe < x || throw(DomainError(x))
6363
itwo_t = 1 / convert(T, 2)
@@ -73,7 +73,7 @@ end
7373

7474
# Real x, k = -1
7575
function lambertw_branch_one(x::T, maxits) where T<:Real
76-
oneoe = -one(T) / convert(T, MathConstants.e)
76+
oneoe = -inv(convert(T, MathConstants.e))
7777
x == oneoe && return -one(T) # W approaches -1 as x -> -1/e from above
7878
oneoe < x || throw(DomainError(x)) # branch domain exludes x < -1/e
7979
x == zero(T) && return -convert(T, Inf) # W decreases w/o bound as x -> 0 from below
@@ -89,7 +89,7 @@ function _lambertw(z::Complex{T}, k, maxits) where T<:Real
8989
one_t = one(T)
9090
local w::Complex{T}
9191
pointseven = 7//10
92-
if abs(z) <= one_t/convert(T, MathConstants.e)
92+
if abs(z) <= inv(convert(T, MathConstants.e))
9393
if z == 0
9494
k == 0 && return z
9595
return complex(-convert(T, Inf), zero(T))

0 commit comments

Comments
 (0)