Giter VIP home page Giter VIP logo

lambert_w's Introduction

lambert_w

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

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 works by splitting the domain of the function into subdomains, and on each subdomain it uses a rational function evaluated on a simple transformation of the input to describe the function.
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 then a series of multiplications and additions by fixed constants and finished with a division.

The functions with 50 bits of accuracy use higher degree polynomials in the rational functions, and thus more of the multiplications and additions by constants.

#![no_std] compatible.

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_w0;

let Ω = lambert_w0(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_w0;

let Ω = sp_lambert_w0(1.0);

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

Evaluate the secondary branch of the Lambert W function at -ln(2)/2 to 50 and 24 bits of accuracy:

use lambert_w::{lambert_wm1, sp_lambert_wm1};

let z = -f64::ln(2.0) / 2.0;

let mln4_50b = lambert_wm1(z);
let mln4_24b = sp_lambert_wm1(z);


assert_abs_diff_eq!(mln4_50b, -f64::ln(4.0));
assert_abs_diff_eq!(mln4_24b, -f64::ln(4.0), epsilon = 1e-9);

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.

lambert_w's People

Contributors

jsorngard avatar

Stargazers

Kvn Wu avatar Zan Pan avatar  avatar Tae-Geun Kim avatar Nick Angelou avatar

Watchers

 avatar

Forkers

novacrazy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.