wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 9.130902437626314746148313908347127210163 \cdot 10^{-9}:\\
\;\;\;\;x + wj \cdot \left(wj - x \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;\left(wj - \frac{wj}{wj + 1}\right) + \frac{\frac{x}{e^{wj}}}{wj + 1}\\
\end{array}double f(double wj, double x) {
double r175589 = wj;
double r175590 = exp(r175589);
double r175591 = r175589 * r175590;
double r175592 = x;
double r175593 = r175591 - r175592;
double r175594 = r175590 + r175591;
double r175595 = r175593 / r175594;
double r175596 = r175589 - r175595;
return r175596;
}
double f(double wj, double x) {
double r175597 = wj;
double r175598 = 9.130902437626315e-09;
bool r175599 = r175597 <= r175598;
double r175600 = x;
double r175601 = 2.0;
double r175602 = r175600 * r175601;
double r175603 = r175597 - r175602;
double r175604 = r175597 * r175603;
double r175605 = r175600 + r175604;
double r175606 = 1.0;
double r175607 = r175597 + r175606;
double r175608 = r175597 / r175607;
double r175609 = r175597 - r175608;
double r175610 = exp(r175597);
double r175611 = r175600 / r175610;
double r175612 = r175611 / r175607;
double r175613 = r175609 + r175612;
double r175614 = r175599 ? r175605 : r175613;
return r175614;
}




Bits error versus wj




Bits error versus x
Results
| Original | 14.1 |
|---|---|
| Target | 13.6 |
| Herbie | 1.0 |
if wj < 9.130902437626315e-09Initial program 13.9
Simplified13.9
Taylor expanded around 0 1.0
Simplified1.0
if 9.130902437626315e-09 < wj Initial program 23.0
Simplified3.1
rmApplied div-sub3.1
Applied associate--r-3.1
Final simplification1.0
herbie shell --seed 2019303
(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))))))