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 r405540 = wj;
double r405541 = exp(r405540);
double r405542 = r405540 * r405541;
double r405543 = x;
double r405544 = r405542 - r405543;
double r405545 = r405541 + r405542;
double r405546 = r405544 / r405545;
double r405547 = r405540 - r405546;
return r405547;
}
double f(double wj, double x) {
double r405548 = wj;
double r405549 = 4.160404689641217e-09;
bool r405550 = r405548 <= r405549;
double r405551 = x;
double r405552 = 2.0;
double r405553 = pow(r405548, r405552);
double r405554 = r405551 + r405553;
double r405555 = r405548 * r405551;
double r405556 = r405552 * r405555;
double r405557 = r405554 - r405556;
double r405558 = exp(r405548);
double r405559 = 1.0;
double r405560 = r405548 + r405559;
double r405561 = r405558 * r405560;
double r405562 = r405551 / r405561;
double r405563 = r405562 + r405548;
double r405564 = r405548 / r405560;
double r405565 = r405563 - r405564;
double r405566 = r405550 ? r405557 : r405565;
return r405566;
}




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
(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))))))