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 r21403728 = wj;
double r21403729 = exp(r21403728);
double r21403730 = r21403728 * r21403729;
double r21403731 = x;
double r21403732 = r21403730 - r21403731;
double r21403733 = r21403729 + r21403730;
double r21403734 = r21403732 / r21403733;
double r21403735 = r21403728 - r21403734;
return r21403735;
}
double f(double wj, double x) {
double r21403736 = x;
double r21403737 = wj;
double r21403738 = r21403736 * r21403737;
double r21403739 = -2.0;
double r21403740 = fma(r21403737, r21403737, r21403736);
double r21403741 = fma(r21403738, r21403739, r21403740);
return r21403741;
}




Bits error versus wj




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