wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(wj, wj, {wj}^{4}\right)}, \sqrt{\mathsf{fma}\left(wj, wj, {wj}^{4}\right)}, -{wj}^{3}\right) + \frac{\frac{x}{e^{wj}}}{1 + wj}double f(double wj, double x) {
double r220745 = wj;
double r220746 = exp(r220745);
double r220747 = r220745 * r220746;
double r220748 = x;
double r220749 = r220747 - r220748;
double r220750 = r220746 + r220747;
double r220751 = r220749 / r220750;
double r220752 = r220745 - r220751;
return r220752;
}
double f(double wj, double x) {
double r220753 = wj;
double r220754 = 4.0;
double r220755 = pow(r220753, r220754);
double r220756 = fma(r220753, r220753, r220755);
double r220757 = sqrt(r220756);
double r220758 = 3.0;
double r220759 = pow(r220753, r220758);
double r220760 = -r220759;
double r220761 = fma(r220757, r220757, r220760);
double r220762 = x;
double r220763 = exp(r220753);
double r220764 = r220762 / r220763;
double r220765 = 1.0;
double r220766 = r220765 + r220753;
double r220767 = r220764 / r220766;
double r220768 = r220761 + r220767;
return r220768;
}




Bits error versus wj




Bits error versus x
| Original | 13.8 |
|---|---|
| Target | 13.3 |
| Herbie | 1.0 |
Initial program 13.8
Simplified13.3
rmApplied div-sub13.3
Applied associate--r-6.9
Taylor expanded around 0 1.0
Simplified1.0
rmApplied add-sqr-sqrt1.0
Applied fma-neg1.0
Final simplification1.0
herbie shell --seed 2020047 +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))))))