wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\mathsf{fma}\left(wj, wj - x \cdot 2, x\right)double f(double wj, double x) {
double r188432 = wj;
double r188433 = exp(r188432);
double r188434 = r188432 * r188433;
double r188435 = x;
double r188436 = r188434 - r188435;
double r188437 = r188433 + r188434;
double r188438 = r188436 / r188437;
double r188439 = r188432 - r188438;
return r188439;
}
double f(double wj, double x) {
double r188440 = wj;
double r188441 = x;
double r188442 = 2.0;
double r188443 = r188441 * r188442;
double r188444 = r188440 - r188443;
double r188445 = fma(r188440, r188444, r188441);
return r188445;
}




Bits error versus wj




Bits error versus x
| Original | 13.9 |
|---|---|
| Target | 13.2 |
| Herbie | 2.3 |
Initial program 13.9
Simplified13.2
Taylor expanded around 0 2.2
Taylor expanded around 0 2.2
Simplified2.3
Final simplification2.3
herbie shell --seed 2020025 +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))))))