wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
\begin{array}{l}
t_0 := \sqrt{1 + wj}\\
\mathsf{fma}\left(\frac{1}{t_0}, \frac{\frac{x}{e^{wj}}}{t_0}, wj \cdot wj - {wj}^{3}\right)
\end{array}
(FPCore (wj x) :precision binary64 (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))
(FPCore (wj x) :precision binary64 (let* ((t_0 (sqrt (+ 1.0 wj)))) (fma (/ 1.0 t_0) (/ (/ x (exp wj)) t_0) (- (* wj wj) (pow wj 3.0)))))
double code(double wj, double x) {
return wj - (((wj * exp(wj)) - x) / (exp(wj) + (wj * exp(wj))));
}
double code(double wj, double x) {
double t_0 = sqrt((1.0 + wj));
return fma((1.0 / t_0), ((x / exp(wj)) / t_0), ((wj * wj) - pow(wj, 3.0)));
}




Bits error versus wj




Bits error versus x
| Original | 13.5 |
|---|---|
| Target | 12.7 |
| Herbie | 1.5 |
Initial program 13.5
Simplified12.7
Applied egg-rr6.8
Taylor expanded in wj around 0 1.5
Simplified1.5
Final simplification1.5
herbie shell --seed 2022130
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:precision binary64
:herbie-target
(- wj (- (/ wj (+ wj 1.0)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))