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}:\\
\;\;\;\;1 \cdot \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 r185699 = wj;
double r185700 = exp(r185699);
double r185701 = r185699 * r185700;
double r185702 = x;
double r185703 = r185701 - r185702;
double r185704 = r185700 + r185701;
double r185705 = r185703 / r185704;
double r185706 = r185699 - r185705;
return r185706;
}
double f(double wj, double x) {
double r185707 = wj;
double r185708 = 7.575706194898737e-11;
bool r185709 = r185707 <= r185708;
double r185710 = 1.0;
double r185711 = x;
double r185712 = fma(r185707, r185707, r185711);
double r185713 = r185710 * r185712;
double r185714 = 2.0;
double r185715 = r185707 * r185711;
double r185716 = r185714 * r185715;
double r185717 = r185713 - r185716;
double r185718 = r185707 + r185710;
double r185719 = r185711 / r185718;
double r185720 = exp(r185707);
double r185721 = r185719 / r185720;
double r185722 = r185707 / r185718;
double r185723 = r185707 - r185722;
double r185724 = r185721 + r185723;
double r185725 = r185709 ? r185717 : r185724;
return r185725;
}




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
rmApplied *-un-lft-identity0.9
Applied *-un-lft-identity0.9
Applied distribute-lft-out0.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))))))