wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\mathsf{fma}\left(x \cdot wj, -2, \mathsf{fma}\left(wj, wj, x\right)\right)double f(double wj, double x) {
double r9249735 = wj;
double r9249736 = exp(r9249735);
double r9249737 = r9249735 * r9249736;
double r9249738 = x;
double r9249739 = r9249737 - r9249738;
double r9249740 = r9249736 + r9249737;
double r9249741 = r9249739 / r9249740;
double r9249742 = r9249735 - r9249741;
return r9249742;
}
double f(double wj, double x) {
double r9249743 = x;
double r9249744 = wj;
double r9249745 = r9249743 * r9249744;
double r9249746 = -2.0;
double r9249747 = fma(r9249744, r9249744, r9249743);
double r9249748 = fma(r9249745, r9249746, r9249747);
return r9249748;
}




Bits error versus wj




Bits error versus x
| Original | 13.5 |
|---|---|
| Target | 12.8 |
| Herbie | 2.1 |
Initial program 13.5
Taylor expanded around 0 2.1
Simplified2.1
Final simplification2.1
herbie shell --seed 2019163 +o rules:numerics
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:herbie-target
(- wj (- (/ wj (+ wj 1)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))