Expand description
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 cumulative multiplies and additions by fixed constants.
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::accurate::lambert_w_0;
let Ω = lambert_w_0(1.0).unwrap();
assert_abs_diff_eq!(Ω, 0.5671432904097838);or to only 24 bits of accuracy, but with faster execution time:
use lambert_w::fast::lambert_w_0;
let Ω = lambert_w_0(1.0).unwrap();
assert_abs_diff_eq!(Ω, 0.5671432904097838, epsilon = 1e-7);The macro is from the approx crate, and is used in the documentation examples of this crate.
It passes the assertion if the two supplied values are the same to within floating point error, or within an optional epsilon.
§Feature flags
You can disable one of these feature flags to potentially save a little bit of binary size.
50bits (enabled by default): enables the more accurate function versions with 50 bits of accuracy.
24bits (enabled by default): enables the faster function versions with 24 bits of accuracy.
It is a compile error to disable both features.