wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\mathsf{fma}\left(\sqrt{{wj}^{4} + {wj}^{2}}, \sqrt{{wj}^{4} + {wj}^{2}}, -{wj}^{3}\right) + \frac{x}{e^{wj} + wj \cdot e^{wj}}double code(double wj, double x) {
return (wj - (((wj * exp(wj)) - x) / (exp(wj) + (wj * exp(wj)))));
}
double code(double wj, double x) {
return (fma(sqrt((pow(wj, 4.0) + pow(wj, 2.0))), sqrt((pow(wj, 4.0) + pow(wj, 2.0))), -pow(wj, 3.0)) + (x / (exp(wj) + (wj * exp(wj)))));
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.7 |
|---|---|
| Target | 13.2 |
| Herbie | 1.1 |
Initial program 13.7
rmApplied div-sub13.7
Applied associate--r-7.4
Simplified7.4
Taylor expanded around 0 1.1
rmApplied add-sqr-sqrt1.1
Applied fma-neg1.1
Final simplification1.1
herbie shell --seed 2020106 +o rules:numerics
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:precision binary64
:herbie-target
(- wj (- (/ wj (+ wj 1)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))