wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}x + wj \cdot \left(wj + x \cdot -2\right)
(FPCore (wj x) :precision binary64 (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))
(FPCore (wj x) :precision binary64 (+ x (* wj (+ wj (* x -2.0)))))
double code(double wj, double x) {
return ((double) (wj - (((double) (((double) (wj * ((double) exp(wj)))) - x)) / ((double) (((double) exp(wj)) + ((double) (wj * ((double) exp(wj)))))))));
}
double code(double wj, double x) {
return ((double) (x + ((double) (wj * ((double) (wj + ((double) (x * -2.0))))))));
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.9 |
|---|---|
| Target | 13.4 |
| Herbie | 2.1 |
Initial program 13.9
Simplified13.4
Taylor expanded around 0 2.0
Simplified2.1
Final simplification2.1
herbie shell --seed 2020198
(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))))))