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 r7416021 = wj;
double r7416022 = exp(r7416021);
double r7416023 = r7416021 * r7416022;
double r7416024 = x;
double r7416025 = r7416023 - r7416024;
double r7416026 = r7416022 + r7416023;
double r7416027 = r7416025 / r7416026;
double r7416028 = r7416021 - r7416027;
return r7416028;
}
double f(double wj, double x) {
double r7416029 = x;
double r7416030 = wj;
double r7416031 = r7416029 * r7416030;
double r7416032 = -2.0;
double r7416033 = fma(r7416030, r7416030, r7416029);
double r7416034 = fma(r7416031, r7416032, r7416033);
return r7416034;
}




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.0)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))