lambert_w 0.4.0

Fast and accurate evaluation of the Lambert W function by the method of T. Fukushima.
Documentation

Static Badge Crates.io Version docs.rs GitHub Actions Workflow Status

lambert_w

Fast evaluation of the real valued parts of the principal and secondary branches of the Lambert W function using the method of Toshio Fukushima to either 24 or 50 bits of accuracy.

This method uses a piecewise minimax rational function approximation with variable transformations.
It is implemented in code as conditional switches on the input value followed by either a square root (and possibly a division) or a logarithm and finished by a series of multiplications and additions by fixed constants and a division.

The functions with 50 bits of accuracy use more switches for a finer split of the domain and more of the final multiplications and additions than the functions with 24 bits of accuracy.

Examples

Compute the value of the Omega constant with the principal branch of the Lambert W function to 50 bits of accuracy:

use lambert_w::lambert_w_0;

use approx::assert_abs_diff_eq;

let Ω = lambert_w_0(1.0);

assert_abs_diff_eq!(Ω, 0.5671432904097838);

or to only 24 bits of accuracy, but with faster execution time:

use lambert_w::sp_lambert_w_0;

use approx::assert_abs_diff_eq;

let Ω = sp_lambert_w_0(1.0);

assert_abs_diff_eq!(Ω, 0.5671432904097838, epsilon = 1e-7);

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.