wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 7.575706194898737323694237493331283921083 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(wj, wj, x\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{wj + 1}}{e^{wj}} + \left(wj - \frac{wj}{wj + 1}\right)\\
\end{array}double f(double wj, double x) {
double r279994 = wj;
double r279995 = exp(r279994);
double r279996 = r279994 * r279995;
double r279997 = x;
double r279998 = r279996 - r279997;
double r279999 = r279995 + r279996;
double r280000 = r279998 / r279999;
double r280001 = r279994 - r280000;
return r280001;
}
double f(double wj, double x) {
double r280002 = wj;
double r280003 = 7.575706194898737e-11;
bool r280004 = r280002 <= r280003;
double r280005 = x;
double r280006 = fma(r280002, r280002, r280005);
double r280007 = 2.0;
double r280008 = r280002 * r280005;
double r280009 = r280007 * r280008;
double r280010 = r280006 - r280009;
double r280011 = 1.0;
double r280012 = r280002 + r280011;
double r280013 = r280005 / r280012;
double r280014 = exp(r280002);
double r280015 = r280013 / r280014;
double r280016 = r280002 / r280012;
double r280017 = r280002 - r280016;
double r280018 = r280015 + r280017;
double r280019 = r280004 ? r280010 : r280018;
return r280019;
}




Bits error versus wj




Bits error versus x
| Original | 13.7 |
|---|---|
| Target | 13.1 |
| Herbie | 1.0 |
if wj < 7.575706194898737e-11Initial program 13.4
Simplified13.4
Taylor expanded around 0 0.9
Taylor expanded around 0 0.9
Simplified0.9
if 7.575706194898737e-11 < wj Initial program 25.5
Simplified4.0
rmApplied associate--l+3.9
Final simplification1.0
herbie shell --seed 2019353 +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))))))