Skip to main content

lambert_w0

Function lambert_w0 

Source
pub fn lambert_w0(z: f64) -> f64
Expand description

The principal branch of the Lambert W function computed to 50 bits of accuracy on 64-bit floats with Fukushima’s method1.

§Examples

§Basic usage
use lambert_w::lambert_w0;
use approx::assert_abs_diff_eq;

let Ω = lambert_w0(1.0);

assert_abs_diff_eq!(Ω, 0.567143290409783873);
§Special cases

For inputs of -1/e and 0 the function returns exactly -1 and 0 respectively, while an infinite input gives INFINITY:

use lambert_w::{lambert_w0, NEG_INV_E};

assert_eq!(lambert_w0(NEG_INV_E), -1.0);
assert_eq!(lambert_w0(0.0), 0.0);
assert_eq!(lambert_w0(f64::INFINITY), f64::INFINITY);

Inputs smaller than -1/e, as well as inputs of NAN, result in NAN:

use lambert_w::{lambert_w0, NEG_INV_E};

assert!(lambert_w0(NEG_INV_E.next_down()).is_nan());
assert!(lambert_w0(f64::NAN).is_nan());

§Reference


  1. Toshio Fukushima. Precise and fast computation of Lambert W function by piecewise minimax rational function approximation with variable transformation. DOI: 10.13140/RG.2.2.30264.37128. November 2020.