wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}
\left(\mathsf{fma}\left(wj, wj, x\right) + x \cdot \mathsf{fma}\left(wj, \mathsf{fma}\left(2.5, wj, -2\right), {wj}^{3} \cdot -2.6666666666666665\right)\right) - {wj}^{3}
(FPCore (wj x) :precision binary64 (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))
(FPCore (wj x) :precision binary64 (- (+ (fma wj wj x) (* x (fma wj (fma 2.5 wj -2.0) (* (pow wj 3.0) -2.6666666666666665)))) (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) {
return (fma(wj, wj, x) + (x * fma(wj, fma(2.5, wj, -2.0), (pow(wj, 3.0) * -2.6666666666666665)))) - pow(wj, 3.0);
}




Bits error versus wj




Bits error versus x
| Original | 13.6 |
|---|---|
| Target | 13.0 |
| Herbie | 1.6 |
Initial program 13.6
Simplified13.0
Taylor expanded in wj around 0 1.7
Simplified1.7
Applied fma-udef_binary641.7
Applied associate--r+_binary641.7
Simplified1.6
Final simplification1.6
herbie shell --seed 2022068
(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))))))