wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 5.620068417277854487526887316151819051768 \cdot 10^{-9}:\\
\;\;\;\;x + wj \cdot \left(wj - x \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj - \frac{x}{e^{wj}}}{{wj}^{2} - 1} \cdot \left(wj - 1\right)\\
\end{array}double f(double wj, double x) {
double r174279 = wj;
double r174280 = exp(r174279);
double r174281 = r174279 * r174280;
double r174282 = x;
double r174283 = r174281 - r174282;
double r174284 = r174280 + r174281;
double r174285 = r174283 / r174284;
double r174286 = r174279 - r174285;
return r174286;
}
double f(double wj, double x) {
double r174287 = wj;
double r174288 = 5.6200684172778545e-09;
bool r174289 = r174287 <= r174288;
double r174290 = x;
double r174291 = 2.0;
double r174292 = r174290 * r174291;
double r174293 = r174287 - r174292;
double r174294 = r174287 * r174293;
double r174295 = r174290 + r174294;
double r174296 = exp(r174287);
double r174297 = r174290 / r174296;
double r174298 = r174287 - r174297;
double r174299 = pow(r174287, r174291);
double r174300 = 1.0;
double r174301 = r174299 - r174300;
double r174302 = r174298 / r174301;
double r174303 = r174287 - r174300;
double r174304 = r174302 * r174303;
double r174305 = r174287 - r174304;
double r174306 = r174289 ? r174295 : r174305;
return r174306;
}




Bits error versus wj




Bits error versus x
Results
| Original | 14.1 |
|---|---|
| Target | 13.6 |
| Herbie | 1.0 |
if wj < 5.6200684172778545e-09Initial program 13.9
Simplified13.9
Taylor expanded around 0 1.0
Simplified1.0
if 5.6200684172778545e-09 < wj Initial program 23.0
Simplified3.1
rmApplied flip-+3.2
Applied associate-/r/3.1
Simplified3.1
Final simplification1.0
herbie shell --seed 2019303
(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))))))