wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\mathsf{fma}\left(wj, wj - x \cdot 2, x\right) + \left(wj \cdot x\right) \cdot \left(\left(-2\right) + 2\right)double f(double wj, double x) {
double r778 = wj;
double r779 = exp(r778);
double r780 = r778 * r779;
double r781 = x;
double r782 = r780 - r781;
double r783 = r779 + r780;
double r784 = r782 / r783;
double r785 = r778 - r784;
return r785;
}
double f(double wj, double x) {
double r786 = wj;
double r787 = x;
double r788 = 2.0;
double r789 = r787 * r788;
double r790 = r786 - r789;
double r791 = fma(r786, r790, r787);
double r792 = r786 * r787;
double r793 = -r788;
double r794 = r793 + r788;
double r795 = r792 * r794;
double r796 = r791 + r795;
return r796;
}




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
rmApplied add-sqr-sqrt29.4
Applied prod-diff29.4
Simplified2.3
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))))))