wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 4.160404689641216852166604763104892916736 \cdot 10^{-9}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + wj\right) - \frac{wj}{wj + 1}\\
\end{array}double f(double wj, double x) {
double r166618 = wj;
double r166619 = exp(r166618);
double r166620 = r166618 * r166619;
double r166621 = x;
double r166622 = r166620 - r166621;
double r166623 = r166619 + r166620;
double r166624 = r166622 / r166623;
double r166625 = r166618 - r166624;
return r166625;
}
double f(double wj, double x) {
double r166626 = wj;
double r166627 = 4.160404689641217e-09;
bool r166628 = r166626 <= r166627;
double r166629 = x;
double r166630 = 2.0;
double r166631 = pow(r166626, r166630);
double r166632 = r166629 + r166631;
double r166633 = r166626 * r166629;
double r166634 = r166630 * r166633;
double r166635 = r166632 - r166634;
double r166636 = exp(r166626);
double r166637 = 1.0;
double r166638 = r166626 + r166637;
double r166639 = r166636 * r166638;
double r166640 = r166629 / r166639;
double r166641 = r166640 + r166626;
double r166642 = r166626 / r166638;
double r166643 = r166641 - r166642;
double r166644 = r166628 ? r166635 : r166643;
return r166644;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.7 |
|---|---|
| Target | 13.1 |
| Herbie | 0.9 |
if wj < 4.160404689641217e-09Initial program 13.4
Simplified13.4
Taylor expanded around 0 0.8
if 4.160404689641217e-09 < wj Initial program 26.7
Simplified2.9
rmApplied div-inv2.9
Applied associate-/l*2.9
Simplified2.9
Final simplification0.9
herbie shell --seed 2020001
(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))))))