wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\mathsf{fma}\left(wj, wj - x \cdot 2, x\right) + \left(wj \cdot x\right) \cdot \left(\left(-2\right) + 2\right)double f(double wj, double x) {
double r216722 = wj;
double r216723 = exp(r216722);
double r216724 = r216722 * r216723;
double r216725 = x;
double r216726 = r216724 - r216725;
double r216727 = r216723 + r216724;
double r216728 = r216726 / r216727;
double r216729 = r216722 - r216728;
return r216729;
}
double f(double wj, double x) {
double r216730 = wj;
double r216731 = x;
double r216732 = 2.0;
double r216733 = r216731 * r216732;
double r216734 = r216730 - r216733;
double r216735 = fma(r216730, r216734, r216731);
double r216736 = r216730 * r216731;
double r216737 = -r216732;
double r216738 = r216737 + r216732;
double r216739 = r216736 * r216738;
double r216740 = r216735 + r216739;
return r216740;
}




Bits error versus wj




Bits error versus x
| Original | 13.6 |
|---|---|
| Target | 13.0 |
| Herbie | 2.1 |
Initial program 13.6
Simplified13.0
Taylor expanded around 0 2.1
rmApplied add-sqr-sqrt29.1
Applied prod-diff29.1
Simplified2.1
Simplified2.1
Final simplification2.1
herbie shell --seed 2020021 +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))))))