double f(double wj, double x) {
double r28399293 = wj;
double r28399294 = exp(r28399293);
double r28399295 = r28399293 * r28399294;
double r28399296 = x;
double r28399297 = r28399295 - r28399296;
double r28399298 = r28399294 + r28399295;
double r28399299 = r28399297 / r28399298;
double r28399300 = r28399293 - r28399299;
return r28399300;
}
double f(double wj, double x) {
double r28399301 = wj;
double r28399302 = 6.5296151305606205e-09;
bool r28399303 = r28399301 <= r28399302;
double r28399304 = x;
double r28399305 = -2.0;
double r28399306 = r28399304 * r28399305;
double r28399307 = r28399306 + r28399301;
double r28399308 = r28399301 * r28399307;
double r28399309 = r28399304 + r28399308;
double r28399310 = exp(r28399301);
double r28399311 = r28399304 / r28399310;
double r28399312 = r28399301 - r28399311;
double r28399313 = 1.0;
double r28399314 = r28399301 + r28399313;
double r28399315 = r28399313 / r28399314;
double r28399316 = r28399312 * r28399315;
double r28399317 = r28399301 - r28399316;
double r28399318 = r28399303 ? r28399309 : r28399317;
return r28399318;
}
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 6.5296151305606205 \cdot 10^{-09}:\\
\;\;\;\;x + wj \cdot \left(x \cdot -2 + wj\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \left(wj - \frac{x}{e^{wj}}\right) \cdot \frac{1}{wj + 1}\\
\end{array}



Bits error versus wj




Bits error versus x
| Original | 13.4 |
|---|---|
| Target | 12.8 |
| Herbie | 1.0 |
if wj < 6.5296151305606205e-09Initial program 13.1
Taylor expanded around 0 0.9
Simplified0.9
if 6.5296151305606205e-09 < wj Initial program 24.8
rmApplied distribute-rgt1-in25.0
Applied *-un-lft-identity25.0
Applied times-frac24.9
Simplified3.1
Final simplification1.0
herbie shell --seed 2019102
(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))))))