Patashu / break_eternity.js

A Javascript numerical library to represent numbers as large as 10^^1e308 and as small as 10^-10^^1e308. Sequel to break_infinity.js, designed for incremental games.
MIT License
122 stars 46 forks source link

implement lambertw (prereq for sroot, invgamma/invfactorial and infinite height tetration) #6

Closed Patashu closed 5 years ago

Patashu commented 5 years ago

this is the inverse of factorial.

https://en.wikipedia.org/wiki/Lambert_W_function

This would also let us implement infinite height tetration: https://en.wikipedia.org/wiki/Tetration#Infinite_heights

if I'm reading it right, it's necessary for super-root (one of the inverse tetration operators) too. https://en.wikipedia.org/wiki/Tetration#Inverse_operations

Patashu commented 5 years ago

example implementations:

jlapeyre in Julia: https://github.com/jlapeyre/LambertW.jl/blob/master/src/LambertW.jl

SciPy in Python: https://github.com/scipy/scipy/blob/v1.2.1/scipy/special/lambertw.py#L6-L107 -> https://github.com/scipy/scipy/blob/8dba340293fe20e62e173bdf2c10ae208286692f/scipy/special/lambertw.pxd -> https://github.com/scipy/scipy/blob/8dba340293fe20e62e173bdf2c10ae208286692f/scipy/special/_evalpoly.pxd

Boost in C++: https://www.boost.org/doc/libs/develop/libs/math/doc/html/math_toolkit/lambert_w.html -> https://www.boost.org/doc/libs/develop/boost/math/special_functions/lambert_w.hpp

The scipy implementation looks good.

Also note that at layer 3 and up, all we need to do is remove one layer - so we only need to handle layer 0, 1 and 2 cases.