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 r269002 = wj;
double r269003 = exp(r269002);
double r269004 = r269002 * r269003;
double r269005 = x;
double r269006 = r269004 - r269005;
double r269007 = r269003 + r269004;
double r269008 = r269006 / r269007;
double r269009 = r269002 - r269008;
return r269009;
}
double f(double wj, double x) {
double r269010 = wj;
double r269011 = 4.160404689641217e-09;
bool r269012 = r269010 <= r269011;
double r269013 = x;
double r269014 = 2.0;
double r269015 = pow(r269010, r269014);
double r269016 = r269013 + r269015;
double r269017 = r269010 * r269013;
double r269018 = r269014 * r269017;
double r269019 = r269016 - r269018;
double r269020 = exp(r269010);
double r269021 = 1.0;
double r269022 = r269010 + r269021;
double r269023 = r269020 * r269022;
double r269024 = r269013 / r269023;
double r269025 = r269024 + r269010;
double r269026 = r269010 / r269022;
double r269027 = r269025 - r269026;
double r269028 = r269012 ? r269019 : r269027;
return r269028;
}




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 +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))))))