wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\left(\mathsf{fma}\left(wj, wj, {wj}^{4}\right) - {wj}^{3}\right) + \frac{x \cdot e^{-wj}}{1 + wj}double f(double wj, double x) {
double r113810 = wj;
double r113811 = exp(r113810);
double r113812 = r113810 * r113811;
double r113813 = x;
double r113814 = r113812 - r113813;
double r113815 = r113811 + r113812;
double r113816 = r113814 / r113815;
double r113817 = r113810 - r113816;
return r113817;
}
double f(double wj, double x) {
double r113818 = wj;
double r113819 = 4.0;
double r113820 = pow(r113818, r113819);
double r113821 = fma(r113818, r113818, r113820);
double r113822 = 3.0;
double r113823 = pow(r113818, r113822);
double r113824 = r113821 - r113823;
double r113825 = x;
double r113826 = -r113818;
double r113827 = exp(r113826);
double r113828 = r113825 * r113827;
double r113829 = 1.0;
double r113830 = r113829 + r113818;
double r113831 = r113828 / r113830;
double r113832 = r113824 + r113831;
return r113832;
}




Bits error versus wj




Bits error versus x
| Original | 13.9 |
|---|---|
| Target | 13.3 |
| Herbie | 1.2 |
Initial program 13.9
Simplified13.3
rmApplied div-sub13.3
Applied associate--r-7.0
Taylor expanded around 0 1.2
Simplified1.2
rmApplied div-inv1.2
Simplified1.2
Final simplification1.2
herbie shell --seed 2019304 +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))))))