wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le -6.6836729835936655 \cdot 10^{-09}:\\
\;\;\;\;wj - \left(wj - \frac{x}{e^{wj}}\right) \cdot \frac{1}{1 + wj}\\
\mathbf{elif}\;wj \le 6.3842652986747504 \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}{1 + wj}\\
\end{array}double f(double wj, double x) {
double r55209571 = wj;
double r55209572 = exp(r55209571);
double r55209573 = r55209571 * r55209572;
double r55209574 = x;
double r55209575 = r55209573 - r55209574;
double r55209576 = r55209572 + r55209573;
double r55209577 = r55209575 / r55209576;
double r55209578 = r55209571 - r55209577;
return r55209578;
}
double f(double wj, double x) {
double r55209579 = wj;
double r55209580 = -6.6836729835936655e-09;
bool r55209581 = r55209579 <= r55209580;
double r55209582 = x;
double r55209583 = exp(r55209579);
double r55209584 = r55209582 / r55209583;
double r55209585 = r55209579 - r55209584;
double r55209586 = 1.0;
double r55209587 = r55209586 + r55209579;
double r55209588 = r55209586 / r55209587;
double r55209589 = r55209585 * r55209588;
double r55209590 = r55209579 - r55209589;
double r55209591 = 6.3842652986747504e-09;
bool r55209592 = r55209579 <= r55209591;
double r55209593 = -2.0;
double r55209594 = r55209593 * r55209582;
double r55209595 = r55209594 + r55209579;
double r55209596 = r55209579 * r55209595;
double r55209597 = r55209582 + r55209596;
double r55209598 = r55209592 ? r55209597 : r55209590;
double r55209599 = r55209581 ? r55209590 : r55209598;
return r55209599;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.5 |
|---|---|
| Target | 13.0 |
| Herbie | 0.4 |
if wj < -6.6836729835936655e-09 or 6.3842652986747504e-09 < wj Initial program 15.1
rmApplied distribute-rgt1-in15.2
Applied *-un-lft-identity15.2
Applied times-frac15.1
Simplified3.9
if -6.6836729835936655e-09 < wj < 6.3842652986747504e-09Initial program 13.4
Taylor expanded around 0 0.2
Simplified0.2
Final simplification0.4
herbie shell --seed 2019104
(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))))))