wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le -8.775235746042734 \cdot 10^{-09}:\\
\;\;\;\;wj - \frac{\left(wj - 1\right) \cdot \frac{e^{wj} \cdot wj - x}{wj \cdot wj + -1}}{e^{wj}}\\
\mathbf{else}:\\
\;\;\;\;\left(x - \left(wj + wj\right) \cdot x\right) + wj \cdot wj\\
\end{array}double f(double wj, double x) {
double r9468456 = wj;
double r9468457 = exp(r9468456);
double r9468458 = r9468456 * r9468457;
double r9468459 = x;
double r9468460 = r9468458 - r9468459;
double r9468461 = r9468457 + r9468458;
double r9468462 = r9468460 / r9468461;
double r9468463 = r9468456 - r9468462;
return r9468463;
}
double f(double wj, double x) {
double r9468464 = wj;
double r9468465 = -8.775235746042734e-09;
bool r9468466 = r9468464 <= r9468465;
double r9468467 = 1.0;
double r9468468 = r9468464 - r9468467;
double r9468469 = exp(r9468464);
double r9468470 = r9468469 * r9468464;
double r9468471 = x;
double r9468472 = r9468470 - r9468471;
double r9468473 = r9468464 * r9468464;
double r9468474 = -1.0;
double r9468475 = r9468473 + r9468474;
double r9468476 = r9468472 / r9468475;
double r9468477 = r9468468 * r9468476;
double r9468478 = r9468477 / r9468469;
double r9468479 = r9468464 - r9468478;
double r9468480 = r9468464 + r9468464;
double r9468481 = r9468480 * r9468471;
double r9468482 = r9468471 - r9468481;
double r9468483 = r9468482 + r9468473;
double r9468484 = r9468466 ? r9468479 : r9468483;
return r9468484;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.7 |
|---|---|
| Target | 13.0 |
| Herbie | 1.6 |
if wj < -8.775235746042734e-09Initial program 5.8
rmApplied distribute-rgt1-in5.8
Applied associate-/r*5.8
rmApplied flip-+5.9
Applied associate-/r/6.1
Simplified6.1
if -8.775235746042734e-09 < wj Initial program 13.9
Taylor expanded around 0 1.5
Simplified1.5
Final simplification1.6
herbie shell --seed 2019143
(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))))))