wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 9.038831895678682838728544720295621228701 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(wj \cdot x, -2, \mathsf{fma}\left(wj, wj, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(wj - 1, \frac{wj - \frac{x}{e^{wj}}}{\mathsf{fma}\left(-wj, wj, 1\right)}, wj\right) + \frac{wj - \frac{x}{e^{wj}}}{\mathsf{fma}\left(-wj, wj, 1\right)} \cdot \left(\left(wj - 1\right) + \left(1 - wj\right)\right)\\
\end{array}double f(double wj, double x) {
double r116243 = wj;
double r116244 = exp(r116243);
double r116245 = r116243 * r116244;
double r116246 = x;
double r116247 = r116245 - r116246;
double r116248 = r116244 + r116245;
double r116249 = r116247 / r116248;
double r116250 = r116243 - r116249;
return r116250;
}
double f(double wj, double x) {
double r116251 = wj;
double r116252 = 9.038831895678683e-09;
bool r116253 = r116251 <= r116252;
double r116254 = x;
double r116255 = r116251 * r116254;
double r116256 = -2.0;
double r116257 = fma(r116251, r116251, r116254);
double r116258 = fma(r116255, r116256, r116257);
double r116259 = 1.0;
double r116260 = r116251 - r116259;
double r116261 = exp(r116251);
double r116262 = r116254 / r116261;
double r116263 = r116251 - r116262;
double r116264 = -r116251;
double r116265 = fma(r116264, r116251, r116259);
double r116266 = r116263 / r116265;
double r116267 = fma(r116260, r116266, r116251);
double r116268 = r116259 - r116251;
double r116269 = r116260 + r116268;
double r116270 = r116266 * r116269;
double r116271 = r116267 + r116270;
double r116272 = r116253 ? r116258 : r116271;
return r116272;
}




Bits error versus wj




Bits error versus x
| Original | 13.9 |
|---|---|
| Target | 13.2 |
| Herbie | 1.0 |
if wj < 9.038831895678683e-09Initial program 13.5
Simplified13.5
Taylor expanded around 0 1.0
Simplified1.0
if 9.038831895678683e-09 < wj Initial program 27.6
Simplified2.3
rmApplied flip-+2.4
Applied associate-/r/2.3
Applied add-sqr-sqrt2.7
Applied prod-diff2.7
Simplified2.3
Simplified2.2
Final simplification1.0
herbie shell --seed 2019325 +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))))))