wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 5.490304900382047 \cdot 10^{-09}:\\
\;\;\;\;\mathsf{fma}\left(wj, wj, x\right) - x \cdot \left(wj + wj\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{1}{wj + 1} \cdot \frac{1}{\frac{e^{wj}}{e^{wj} \cdot wj - x}}\\
\end{array}double f(double wj, double x) {
double r3975564 = wj;
double r3975565 = exp(r3975564);
double r3975566 = r3975564 * r3975565;
double r3975567 = x;
double r3975568 = r3975566 - r3975567;
double r3975569 = r3975565 + r3975566;
double r3975570 = r3975568 / r3975569;
double r3975571 = r3975564 - r3975570;
return r3975571;
}
double f(double wj, double x) {
double r3975572 = wj;
double r3975573 = 5.490304900382047e-09;
bool r3975574 = r3975572 <= r3975573;
double r3975575 = x;
double r3975576 = fma(r3975572, r3975572, r3975575);
double r3975577 = r3975572 + r3975572;
double r3975578 = r3975575 * r3975577;
double r3975579 = r3975576 - r3975578;
double r3975580 = 1.0;
double r3975581 = r3975572 + r3975580;
double r3975582 = r3975580 / r3975581;
double r3975583 = exp(r3975572);
double r3975584 = r3975583 * r3975572;
double r3975585 = r3975584 - r3975575;
double r3975586 = r3975583 / r3975585;
double r3975587 = r3975580 / r3975586;
double r3975588 = r3975582 * r3975587;
double r3975589 = r3975572 - r3975588;
double r3975590 = r3975574 ? r3975579 : r3975589;
return r3975590;
}




Bits error versus wj




Bits error versus x
| Original | 13.9 |
|---|---|
| Target | 13.2 |
| Herbie | 1.6 |
if wj < 5.490304900382047e-09Initial program 13.6
Taylor expanded around 0 0.8
Simplified0.8
if 5.490304900382047e-09 < wj Initial program 25.5
rmApplied clear-num25.6
rmApplied *-un-lft-identity25.6
Applied distribute-rgt1-in25.7
Applied times-frac25.6
Applied *-un-lft-identity25.6
Applied times-frac25.8
Simplified25.8
Final simplification1.6
herbie shell --seed 2019151 +o rules:numerics
(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))))))