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




Bits error versus wj




Bits error versus x
| Original | 13.5 |
|---|---|
| Target | 12.9 |
| Herbie | 1.2 |
Initial program 13.5
Simplified12.9
Applied *-un-lft-identity_binary6412.9
Applied *-un-lft-identity_binary6412.9
Applied distribute-lft-out_binary6412.9
Simplified6.8
Taylor expanded in wj around 0 1.2
Simplified1.2
Final simplification1.2
herbie shell --seed 2021357
(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))))))