LambertW.LambertW
— Modulemodule LambertW
This module computes the Lambert W function, or product log function, and related quantities.
Functions: lambertw
, lambertwbp
, finv
Constants: omega
, lambertwbranchpoint
LambertW.lambertw
— Functionlambertw(z::Complex{T}, k::V=0) where {T<:Real, V<:Integer}
lambertw(z::T, k::V=0) where {T<:Real, V<:Integer}
Compute the k
th branch of the Lambert W function of z
. If z
is real, k
must be either 0
or -1
. For Real
z
, the domain of the branch k = -1
is [-1/e, 0]
and the domain of the branch k = 0
is [-1/e, Inf]
. For Complex
z
, and all k
, the domain is the complex plane.
julia> lambertw(-1/e, -1)
-1.0
julia> lambertw(-1/e, 0)
-1.0
julia> lambertw(0, 0)
0.0
julia> lambertw(0, -1)
-Inf
julia> lambertw(Complex(-10.0, 3.0), 4)
-0.9274337508660128 + 26.37693445371142im
LambertW.lambertwbp
— Methodlambertwbp(z, k=0)
Compute accurate value of 1 + W(-1/e + z)
, for abs(z)
in [0, 1/e]
for k
either 0
or -1
. This function is faster and more accurate near the branch point -1/e
between k=0
and k=1
. The result is accurate to Float64 precision for abs(z) < 0.32. If k=-1
and imag(z) < 0
, the value on the branch k=1
is returned.
Example
julia> lambertw(-1/e + 1e-18, -1)
-1.0
julia> lambertwbp(1e-18, -1)
-2.331643983409312e-9
# Same result, but 1000 times slower
julia> convert(Float64, (lambertw(-BigFloat(1)/e + BigFloat(10)^(-18), -1) + 1))
-2.331643983409312e-9
lambertwbp
uses a series expansion about the branch point z=-1/e
to avoid loss of precision. The loss of precision in lambertw
is analogous to the loss of precision in computing the sqrt(1-x)
for x
close to 1
.
LambertW.lambertwbranchpoint
— Constant lambertbranchpoint::Irrational
The branchpoint of the branches k = 0
and k = -1
, -1/e
.
Example
julia> import LambertW.lambertwbranchpoint
julia> lambertw(lambertwbranchpoint, 0)
-1.0
julia> lambertw(lambertwbranchpoint, -1)
-1.0
LambertW.omega
— Constantomega
ω
The constant defined by ω exp(ω) = 1
.
Example
julia> ω
ω = 0.5671432904097...
julia> omega
ω = 0.5671432904097...
julia> ω * exp(ω)
1.0
julia> big(omega)
5.67143290409783872999968662210355549753815787186512508135131079223045793086683e-01
LambertW.ω
— Constantomega
ω
The constant defined by ω exp(ω) = 1
.
Example
julia> ω
ω = 0.5671432904097...
julia> omega
ω = 0.5671432904097...
julia> ω * exp(ω)
1.0
julia> big(omega)
5.67143290409783872999968662210355549753815787186512508135131079223045793086683e-01
LambertW.finv
— Methodfinv(::typeof(lambertw)) -> Function
The functional inverse of the Lambert W function.
Example
julia> import LambertW.finv
julia> finv(lambertw)(lambertw(1))
1.0