Attend the Women in ML Symposium on December 7 Register now


Computes Lambert W of z element-wise.

The Lambert W function is the inverse of z = u * exp(u), i. e., it is the function that satisfies u = W(z) * exp(W(z)). The solution cannot be expressed as a composition of elementary functions and is thus part of the special functions in mathematics. See

In general it is a complex-valued function with multiple branches. The k=0 branch is known as the principal branch of the Lambert W function and is implemented here. See also scipy.special.lambertw.

This code returns only the real part of the image of the Lambert W function.


Corless, R.M., Gonnet, G.H., Hare, D.E.G. et al. On the LambertW function. Adv Comput Math 5, 329-359 (1996) doi:10.1007/BF02124750

z A Tensor with type float32 or float64.
name A name for the operation (optional).

lambertw The Lambert W function evaluated at z. A Tensor with same shape and same dtype as z.