wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le -5.007719939975079832531441257617230156107 \cdot 10^{-9}:\\
\;\;\;\;wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\\
\mathbf{else}:\\
\;\;\;\;x + wj \cdot \left(wj - 2 \cdot x\right)\\
\end{array}double f(double wj, double x) {
double r140528 = wj;
double r140529 = exp(r140528);
double r140530 = r140528 * r140529;
double r140531 = x;
double r140532 = r140530 - r140531;
double r140533 = r140529 + r140530;
double r140534 = r140532 / r140533;
double r140535 = r140528 - r140534;
return r140535;
}
double f(double wj, double x) {
double r140536 = wj;
double r140537 = -5.00771993997508e-09;
bool r140538 = r140536 <= r140537;
double r140539 = exp(r140536);
double r140540 = r140536 * r140539;
double r140541 = x;
double r140542 = r140540 - r140541;
double r140543 = r140539 + r140540;
double r140544 = r140542 / r140543;
double r140545 = r140536 - r140544;
double r140546 = 2.0;
double r140547 = r140546 * r140541;
double r140548 = r140536 - r140547;
double r140549 = r140536 * r140548;
double r140550 = r140541 + r140549;
double r140551 = r140538 ? r140545 : r140550;
return r140551;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.4 |
|---|---|
| Target | 12.8 |
| Herbie | 1.5 |
if wj < -5.00771993997508e-09Initial program 5.8
if -5.00771993997508e-09 < wj Initial program 13.6
Simplified12.9
Taylor expanded around 0 1.4
Simplified1.5
Final simplification1.5
herbie shell --seed 2019323
(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))))))