wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}} \le 3.783506544229532 \cdot 10^{-19}:\\
\;\;\;\;x + \left(wj + -2 \cdot x\right) \cdot wj\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{1}{1 + wj} \cdot \left(wj - \frac{x}{e^{wj}}\right)\\
\end{array}double f(double wj, double x) {
double r55892276 = wj;
double r55892277 = exp(r55892276);
double r55892278 = r55892276 * r55892277;
double r55892279 = x;
double r55892280 = r55892278 - r55892279;
double r55892281 = r55892277 + r55892278;
double r55892282 = r55892280 / r55892281;
double r55892283 = r55892276 - r55892282;
return r55892283;
}
double f(double wj, double x) {
double r55892284 = wj;
double r55892285 = exp(r55892284);
double r55892286 = r55892284 * r55892285;
double r55892287 = x;
double r55892288 = r55892286 - r55892287;
double r55892289 = r55892285 + r55892286;
double r55892290 = r55892288 / r55892289;
double r55892291 = r55892284 - r55892290;
double r55892292 = 3.783506544229532e-19;
bool r55892293 = r55892291 <= r55892292;
double r55892294 = -2.0;
double r55892295 = r55892294 * r55892287;
double r55892296 = r55892284 + r55892295;
double r55892297 = r55892296 * r55892284;
double r55892298 = r55892287 + r55892297;
double r55892299 = 1.0;
double r55892300 = r55892299 + r55892284;
double r55892301 = r55892299 / r55892300;
double r55892302 = r55892287 / r55892285;
double r55892303 = r55892284 - r55892302;
double r55892304 = r55892301 * r55892303;
double r55892305 = r55892284 - r55892304;
double r55892306 = r55892293 ? r55892298 : r55892305;
return r55892306;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.2 |
|---|---|
| Target | 12.7 |
| Herbie | 0.8 |
if (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))) < 3.783506544229532e-19Initial program 17.4
Taylor expanded around 0 0.7
Simplified0.8
if 3.783506544229532e-19 < (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))) Initial program 2.5
rmApplied distribute-rgt1-in2.5
Applied *-un-lft-identity2.5
Applied times-frac2.5
Simplified0.8
Final simplification0.8
herbie shell --seed 2019119
(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))))))