wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le -4.580237846772234 \cdot 10^{-09}:\\
\;\;\;\;wj - \frac{\frac{e^{wj} \cdot wj - x}{wj + 1}}{e^{wj}}\\
\mathbf{elif}\;wj \le 6.696494124738262 \cdot 10^{-09}:\\
\;\;\;\;x + wj \cdot \left(-2 \cdot x + wj\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \left(wj - \frac{x}{e^{wj}}\right) \cdot \frac{1}{wj + 1}\\
\end{array}double f(double wj, double x) {
double r50761319 = wj;
double r50761320 = exp(r50761319);
double r50761321 = r50761319 * r50761320;
double r50761322 = x;
double r50761323 = r50761321 - r50761322;
double r50761324 = r50761320 + r50761321;
double r50761325 = r50761323 / r50761324;
double r50761326 = r50761319 - r50761325;
return r50761326;
}
double f(double wj, double x) {
double r50761327 = wj;
double r50761328 = -4.580237846772234e-09;
bool r50761329 = r50761327 <= r50761328;
double r50761330 = exp(r50761327);
double r50761331 = r50761330 * r50761327;
double r50761332 = x;
double r50761333 = r50761331 - r50761332;
double r50761334 = 1.0;
double r50761335 = r50761327 + r50761334;
double r50761336 = r50761333 / r50761335;
double r50761337 = r50761336 / r50761330;
double r50761338 = r50761327 - r50761337;
double r50761339 = 6.696494124738262e-09;
bool r50761340 = r50761327 <= r50761339;
double r50761341 = -2.0;
double r50761342 = r50761341 * r50761332;
double r50761343 = r50761342 + r50761327;
double r50761344 = r50761327 * r50761343;
double r50761345 = r50761332 + r50761344;
double r50761346 = r50761332 / r50761330;
double r50761347 = r50761327 - r50761346;
double r50761348 = r50761334 / r50761335;
double r50761349 = r50761347 * r50761348;
double r50761350 = r50761327 - r50761349;
double r50761351 = r50761340 ? r50761345 : r50761350;
double r50761352 = r50761329 ? r50761338 : r50761351;
return r50761352;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.8 |
|---|---|
| Target | 13.0 |
| Herbie | 0.3 |
if wj < -4.580237846772234e-09Initial program 4.7
rmApplied distribute-rgt1-in4.6
Applied associate-/r*4.6
if -4.580237846772234e-09 < wj < 6.696494124738262e-09Initial program 13.5
Taylor expanded around 0 0.1
Simplified0.2
if 6.696494124738262e-09 < wj Initial program 29.5
rmApplied distribute-rgt1-in29.6
Applied *-un-lft-identity29.6
Applied times-frac29.5
Simplified3.1
Final simplification0.3
herbie shell --seed 2019120
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:herbie-target
(- wj (- (/ wj (+ wj 1)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))