wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 4.160404689641216852166604763104892916736 \cdot 10^{-9}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + wj\right) - \frac{wj}{wj + 1}\\
\end{array}double f(double wj, double x) {
double r310581 = wj;
double r310582 = exp(r310581);
double r310583 = r310581 * r310582;
double r310584 = x;
double r310585 = r310583 - r310584;
double r310586 = r310582 + r310583;
double r310587 = r310585 / r310586;
double r310588 = r310581 - r310587;
return r310588;
}
double f(double wj, double x) {
double r310589 = wj;
double r310590 = 4.160404689641217e-09;
bool r310591 = r310589 <= r310590;
double r310592 = x;
double r310593 = 2.0;
double r310594 = pow(r310589, r310593);
double r310595 = r310592 + r310594;
double r310596 = r310589 * r310592;
double r310597 = r310593 * r310596;
double r310598 = r310595 - r310597;
double r310599 = exp(r310589);
double r310600 = 1.0;
double r310601 = r310589 + r310600;
double r310602 = r310599 * r310601;
double r310603 = r310592 / r310602;
double r310604 = r310603 + r310589;
double r310605 = r310589 / r310601;
double r310606 = r310604 - r310605;
double r310607 = r310591 ? r310598 : r310606;
return r310607;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.7 |
|---|---|
| Target | 13.1 |
| Herbie | 0.9 |
if wj < 4.160404689641217e-09Initial program 13.4
Simplified13.4
Taylor expanded around 0 0.8
if 4.160404689641217e-09 < wj Initial program 26.7
Simplified2.9
rmApplied div-inv2.9
Applied associate-/l*2.9
Simplified2.9
Final simplification0.9
herbie shell --seed 2020001 +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))))))