[Paper Review] Having Fun with Lambert W(x) Function
This paper presents a high-accuracy C++ implementation of the Lambert W function, leveraging branch-point expansions, asymptotic series, rational fits, and iterative refinement via Fritsch's method. It achieves machine-precision accuracy across both real branches, with key applications in physics, particularly in reconstructing signals from the Pierre Auger Observatory using the Moyal and Gaisser-Hillas functions.
This short note presents the Lambert W(x) function and its possible application in the framework of physics related to the Pierre Auger Observatory. The actual numerical implementation in C++ consists of Halley's and Fritsch's iteration with branch-point expansion, asymptotic series and rational fits as initial approximations.
Motivation & Objective
- To develop a numerically robust and efficient C++ implementation of the Lambert W function for scientific computing.
- To enable accurate inversion of the Moyal and Gaisser-Hillas functions used in cosmic-ray air shower reconstruction at the Pierre Auger Observatory.
- To combine multiple analytical approximations (branch-point, asymptotic, rational) with iterative refinement for optimal accuracy across the entire domain.
- To evaluate and compare the performance of Halley’s and Fritsch’s iteration methods in achieving machine-precision results.
- To provide a production-ready, open-source implementation with documented accuracy and performance characteristics.
Proposed method
- Uses branch-point expansions (up to 9th order) near the branch point at $-e^{-1}$ for both $W_0(x)$ and $W_{-1}(x)$, derived from series expansions.
- Employs asymptotic series $A_0(x)$ for large $x$ and rational approximations $Q_0^{[1]}, Q_0^{[2]}$ and $Q_{-1}(x)$ for intermediate ranges.
- Applies Fritsch’s iterative method as the final refinement step, which outperforms Halley’s method in convergence and accuracy across the domain.
- Combines piecewise approximations tailored to different intervals of $x$ to maximize accuracy: $[-e^{-1}, -0.32358]$ for $W_0$, and $[-e^{-1}, 0]$ for $W_{-1}$.
- Uses a recursive continued logarithmic form $R_{-1}^{[n]}(x)$ as an initial approximation for $W_{-1}(x)$ in the negative range near zero.
- Quantifies accuracy via $\Delta(x) = -\log_{10}|\widetilde{W}(x) - W(x)|$, measuring decimal places of correctness.
Experimental results
Research questions
- RQ1How can the Lambert W function be accurately and efficiently computed across its entire real domain, including near the branch point and in asymptotic regions?
- RQ2Which iterative method—Halley’s or Fritsch’s—produces superior convergence and accuracy when refining piecewise rational or series approximations?
- RQ3To what extent can the inverse of the Moyal and Gaisser-Hillas functions be expressed in terms of the Lambert W function, and how does this enable physical signal reconstruction?
- RQ4What is the optimal combination of initial approximations (series, rational, recursive) to achieve high-precision results with minimal iterations?
- RQ5Can a single, unified C++ implementation achieve machine-precision accuracy across both branches of the Lambert W function with minimal computational overhead?
Key findings
- The piecewise approximation $\widetilde{W}_0(x)$ achieves at least 5 decimal places of accuracy in $[-e^{-1}, 7]$ and at least 3 decimal places across the full domain.
- The Fritsch iteration achieves machine-precision accuracy (15+ decimal places) in a single step for all $x \in [-e^{-1}, 110]$, except for a small interval $[9, 110]$ where Halley’s method requires an extra iteration.
- For $W_{-1}(x)$, the combined approximation $\widetilde{W}_{-1}(x)$ is accurate to at least 5 decimal places over the entire interval $[-e^{-1}, 0]$.
- Fritsch’s iteration produces results accurate to at least 13 decimal places across the $W_{-1}(x)$ domain, outperforming Halley’s method in both speed and precision.
- The final C++ implementation uses only one step of Fritsch’s iteration after the piecewise rational/series approximation, ensuring high performance and accuracy.
- The implementation is available as open-source at https://github.com/DarkoVeberic/LambertW, with full documentation and accuracy benchmarks.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.