R: Lambert-W Function

lambertW {lamW} | R Documentation

## Lambert-W Function

### Description

The Lambert-W function is defined as the multivalued inverse of the function z = f(W) = W*exp(W). The function has two branches. The principal branch is defined on the interval [-1/e, Infinity) and is always greater than -1. The second branch is defined on the interval [-1/e, 0) and is always less than -1. The real-valued function is not defined for values less than -1/e.

### Usage

    lambertW0(x)
    lambertWm1(x)

### Arguments

`x` | vector of values

### Details

The Lambert-W function is defined for all real x >= -1/e. It has two values in the interval (-1/e, 0). The values strictly greater than -1 are assigned to the “principal” branch, also referred to as W0, and the values strictly less than -1 are assigned to the “secondary” branch, referred to as Wm1. For non-negative x, only the principal branch exists as the other real-valued branch approaches negative infinity as x approaches 0. The algorithms used to calculate the values predominantly follow those in the reference with some simplifications. There are many applications in which the Lambert-W function is useful, such as combinatorics, physics, and hydrology. The interested reader is directed to the references for more detail.

### Value

Both functions return the appropriate values in the intervals for which they are defined. Outside of those intervals, they will return `NaN`, except that `lambertW0(Inf)` will return its limit `Inf` and `lambertWm1(0)` will return its limit -`Inf`.

### Author(s)

Avraham Adler Avraham.Adler@gmail.com

### References

Corless, R. M., Gonnet, G. H., Hare, D. E., Jeffrey, D. J., Knuth, D. E. 1996 "On the Lambert W function", Advances in Computational Mathematics, 5, 329–359, Springer <doi:10.1007/BF02124750>

Veberic, D. 2012 "Lambert W function for applications in physics", Computer Physics Communications, 183(12), 2622–2628. <arXiv:1209.0735>

### See Also

This package provides similar functionality to the `Lambert` functions in the gsl package without having to obtain or install the entire GSL.

### Examples

    lambertW0(exp(1))      ## Should equal 1, as 1 * exp(1) = e.
    lambertW0(0)           ## Should equal 0, as 0 * exp(0) = 0.
    lambertW0(-exp(-1))    ## Should equal -1.
    lambertWm1(-exp(-1))   ## Should also equal -1.
    A <- -2 * exp(-2)
    lambertWm1(A)          ## Should equal -2

[Package lamW version 2.0.0 Index]