wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 7.430298569289362581259585777138099160766 \cdot 10^{-6}:\\
\;\;\;\;\left(\mathsf{fma}\left(wj, wj, {wj}^{4}\right) - {wj}^{3}\right) + \frac{\frac{x}{e^{wj}}}{1 + wj}\\
\mathbf{else}:\\
\;\;\;\;\left(wj - \frac{wj}{1 + wj}\right) + \frac{x \cdot e^{-wj}}{1 + wj}\\
\end{array}double f(double wj, double x) {
double r132686 = wj;
double r132687 = exp(r132686);
double r132688 = r132686 * r132687;
double r132689 = x;
double r132690 = r132688 - r132689;
double r132691 = r132687 + r132688;
double r132692 = r132690 / r132691;
double r132693 = r132686 - r132692;
return r132693;
}
double f(double wj, double x) {
double r132694 = wj;
double r132695 = 7.430298569289363e-06;
bool r132696 = r132694 <= r132695;
double r132697 = 4.0;
double r132698 = pow(r132694, r132697);
double r132699 = fma(r132694, r132694, r132698);
double r132700 = 3.0;
double r132701 = pow(r132694, r132700);
double r132702 = r132699 - r132701;
double r132703 = x;
double r132704 = exp(r132694);
double r132705 = r132703 / r132704;
double r132706 = 1.0;
double r132707 = r132706 + r132694;
double r132708 = r132705 / r132707;
double r132709 = r132702 + r132708;
double r132710 = r132694 / r132707;
double r132711 = r132694 - r132710;
double r132712 = -r132694;
double r132713 = exp(r132712);
double r132714 = r132703 * r132713;
double r132715 = r132714 / r132707;
double r132716 = r132711 + r132715;
double r132717 = r132696 ? r132709 : r132716;
return r132717;
}




Bits error versus wj




Bits error versus x
| Original | 13.6 |
|---|---|
| Target | 12.8 |
| Herbie | 0.3 |
if wj < 7.430298569289363e-06Initial program 13.1
Simplified13.0
rmApplied div-sub13.0
Applied associate--r-7.0
Simplified7.0
Taylor expanded around 0 0.3
Simplified0.3
if 7.430298569289363e-06 < wj Initial program 33.8
Simplified1.6
rmApplied div-sub1.6
Applied associate--r-1.5
Simplified1.5
rmApplied div-inv1.5
Simplified1.5
Final simplification0.3
herbie shell --seed 2019235 +o rules:numerics
(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))))))