wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 4.3996584940110106 \cdot 10^{-09}:\\
\;\;\;\;x + wj \cdot \left(x \cdot -2 + wj\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj - \frac{x}{e^{wj}}}{1 + wj}\\
\end{array}double f(double wj, double x) {
double r50520451 = wj;
double r50520452 = exp(r50520451);
double r50520453 = r50520451 * r50520452;
double r50520454 = x;
double r50520455 = r50520453 - r50520454;
double r50520456 = r50520452 + r50520453;
double r50520457 = r50520455 / r50520456;
double r50520458 = r50520451 - r50520457;
return r50520458;
}
double f(double wj, double x) {
double r50520459 = wj;
double r50520460 = 4.3996584940110106e-09;
bool r50520461 = r50520459 <= r50520460;
double r50520462 = x;
double r50520463 = -2.0;
double r50520464 = r50520462 * r50520463;
double r50520465 = r50520464 + r50520459;
double r50520466 = r50520459 * r50520465;
double r50520467 = r50520462 + r50520466;
double r50520468 = exp(r50520459);
double r50520469 = r50520462 / r50520468;
double r50520470 = r50520459 - r50520469;
double r50520471 = 1.0;
double r50520472 = r50520471 + r50520459;
double r50520473 = r50520470 / r50520472;
double r50520474 = r50520459 - r50520473;
double r50520475 = r50520461 ? r50520467 : r50520474;
return r50520475;
}




Bits error versus wj




Bits error versus x
Results
| Original | 14.0 |
|---|---|
| Target | 13.4 |
| Herbie | 0.9 |
if wj < 4.3996584940110106e-09Initial program 13.7
Taylor expanded around 0 0.8
Simplified0.8
if 4.3996584940110106e-09 < wj Initial program 25.5
rmApplied *-un-lft-identity25.5
Applied distribute-rgt-out25.6
Applied associate-/r*25.6
Simplified2.3
Final simplification0.9
herbie shell --seed 2019128
(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))))))