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 r9581016 = wj;
double r9581017 = exp(r9581016);
double r9581018 = r9581016 * r9581017;
double r9581019 = x;
double r9581020 = r9581018 - r9581019;
double r9581021 = r9581017 + r9581018;
double r9581022 = r9581020 / r9581021;
double r9581023 = r9581016 - r9581022;
return r9581023;
}
double f(double wj, double x) {
double r9581024 = x;
double r9581025 = wj;
double r9581026 = r9581024 * r9581025;
double r9581027 = -2.0;
double r9581028 = fma(r9581025, r9581025, r9581024);
double r9581029 = fma(r9581026, r9581027, r9581028);
return r9581029;
}




Bits error versus wj




Bits error versus x
| Original | 13.2 |
|---|---|
| Target | 12.6 |
| Herbie | 2.0 |
Initial program 13.2
Taylor expanded around 0 2.0
Simplified2.0
Final simplification2.0
herbie shell --seed 2019165 +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))))))