Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Lambert W function implementation #371

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
44deb6e
implement Lambert W function
alyst Jan 3, 2022
87b5509
made changes request in PR review
jlapeyre Apr 18, 2018
8bc1814
sync with latest LambertW.jl master
alyst Dec 30, 2021
0f6bce3
lambertw tests: check correct type inference
alyst Dec 31, 2021
46f5b54
lambertw tests: correct approx equality tests
alyst Dec 31, 2021
0894aad
lambertwbp: simplify series coeffs code
alyst Dec 31, 2021
59f1f84
lambertw_root_find: fix diff type
alyst Dec 31, 2021
edf1820
lambertw: simplify handling non-finite vals
alyst Dec 31, 2021
83d79ca
lambertw: use inv(e)
alyst Dec 31, 2021
87f9749
lambertw: annotate function args with types
alyst Dec 31, 2021
d39470c
lambertw: use dispatch to compute diff. branches
alyst Dec 31, 2021
8f0e616
lambertwbp_series(): simplify
alyst Dec 31, 2021
6fc569f
lambertw(): make maxiter a keyword
alyst Dec 31, 2021
739a17c
lambertw: small fixes
alyst Dec 31, 2021
e34e8d9
lambertwbp(): cleanup tests
alyst Dec 31, 2021
4f8b18b
lambertw(): use inve constant in tests
alyst Dec 31, 2021
c90b502
rename omega => LambertW.Omega and update its def
alyst Jan 3, 2022
87d0828
lambertw(): more inference tests
alyst Jan 1, 2022
adf29b4
lambertw: improve test precision
alyst Jan 1, 2022
d277be3
lambertw(): use inve constant
alyst Jan 3, 2022
5b38fec
use Compat to support evalpoly() on Julia 1.3
alyst Jan 3, 2022
afa1d0e
DONTMERGE temporarily define inve here
alyst Jan 3, 2022
b0c63e5
lambertw: test maxiter= and convergence warning
alyst Jan 3, 2022
ed3c825
lambertw: fix jldoctests
alyst Jan 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,35 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Portions of this code are derived from SciPy and are licensed under
the Scipy License:

> Copyright (c) 2001, 2002 Enthought, Inc.
> All rights reserved.

> Copyright (c) 2003-2012 SciPy Developers.
> All rights reserved.

> Redistribution and use in source and binary forms, with or without
> modification, are permitted provided that the following conditions are met:

> a. Redistributions of source code must retain the above copyright notice,
> this list of conditions and the following disclaimer.
> b. Redistributions in binary form must reproduce the above copyright
> notice, this list of conditions and the following disclaimer in the
> documentation and/or other materials provided with the distribution.
> c. Neither the name of Enthought nor the names of the SciPy Developers
> may be used to endorse or promote products derived from this software
> without specific prior written permission.
>
> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
> AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
> OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
> THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "2.2.0"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
IrrationalConstants = "92d709cd-6900-40b7-9082-c6be49f344b6"
LogExpFunctions = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
OpenLibm_jll = "05823500-19ac-5b8b-9628-191a04bc5112"
Expand All @@ -18,6 +19,7 @@ SpecialFunctionsChainRulesCoreExt = "ChainRulesCore"
[compat]
ChainRulesCore = "0.9.44, 0.10, 1"
ChainRulesTestUtils = "0.6.8, 0.7, 1"
Compat = "3.7, 4"
IrrationalConstants = "0.1, 0.2"
LogExpFunctions = "0.3.2"
OpenLibm_jll = "0.7, 0.8"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SpecialFunctions.jl

Special mathematical functions in Julia, including Bessel, Hankel, Airy, error, Dawson, exponential (or sine and cosine) integrals,
eta, zeta, digamma, inverse digamma, trigamma, and polygamma functions.
eta, zeta, Lambert's W, digamma, inverse digamma, trigamma, and polygamma functions.
Most of these functions were formerly part of Base in early versions of Julia.

CI (Linux, macOS, FreeBSD, Windows):
Expand Down
3 changes: 3 additions & 0 deletions docs/src/functions_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,7 @@ SpecialFunctions.beta
SpecialFunctions.logbeta
SpecialFunctions.logabsbeta
SpecialFunctions.logabsbinomial
SpecialFunctions.lambertw
SpecialFunctions.lambertwbp
SpecialFunctions.LambertW.Ω
```
6 changes: 6 additions & 0 deletions docs/src/functions_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,9 @@ Here the *Special Functions* are listed according to the structure of [NIST Digi
|:-------- |:----------- |
| [`eta(x)`](@ref SpecialFunctions.eta) | [Dirichlet eta function](https://en.wikipedia.org/wiki/Dirichlet_eta_function) at `x` |
| [`zeta(x)`](@ref SpecialFunctions.zeta) | [Riemann zeta function](https://en.wikipedia.org/wiki/Riemann_zeta_function) at `x` |

## [Lambert's W Function](https://dlmf.nist.gov/4.13)
| Function | Description |
|:-------- |:----------- |
| [`lambertw(x, [k=0])`](@ref SpecialFunctions.lambertw) | [Lambert's W function](https://en.wikipedia.org/wiki/Lambert_W_function) at `x` for `k`-th branch |
| [`lambertwbp(x, [k=0])`](@ref SpecialFunctions.lambertwbp) | Accurate value of ``1 + W_k(-\frac{1}{\mathrm{e}} + x)`` for small `x` |
11 changes: 10 additions & 1 deletion src/SpecialFunctions.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module SpecialFunctions

using Compat

using IrrationalConstants:
twoπ,
halfπ,
Expand All @@ -13,6 +15,9 @@ using IrrationalConstants:
logπ,
log2π

# FIXME temporary until the fate of inve is decided
Base.@irrational inve 0.367879441171442321595 inv(big(ℯ))

import LogExpFunctions

using OpenLibm_jll
Expand Down Expand Up @@ -77,7 +82,10 @@ export
expintx,
sinint,
cosint,
lbinomial
lbinomial,
lambertw,
lambertwbp,
LambertW

include("bessel.jl")
include("erf.jl")
Expand All @@ -90,6 +98,7 @@ include("gamma.jl")
include("gamma_inc.jl")
include("betanc.jl")
include("beta_inc.jl")
include("lambertw.jl")
if !isdefined(Base, :get_extension)
include("../ext/SpecialFunctionsChainRulesCoreExt.jl")
end
Expand Down
Loading