wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 9.508407581583140375763293699815092985261 \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 r318875 = wj;
double r318876 = exp(r318875);
double r318877 = r318875 * r318876;
double r318878 = x;
double r318879 = r318877 - r318878;
double r318880 = r318876 + r318877;
double r318881 = r318879 / r318880;
double r318882 = r318875 - r318881;
return r318882;
}
double f(double wj, double x) {
double r318883 = wj;
double r318884 = 9.50840758158314e-09;
bool r318885 = r318883 <= r318884;
double r318886 = x;
double r318887 = 2.0;
double r318888 = pow(r318883, r318887);
double r318889 = r318886 + r318888;
double r318890 = r318883 * r318886;
double r318891 = r318887 * r318890;
double r318892 = r318889 - r318891;
double r318893 = exp(r318883);
double r318894 = 1.0;
double r318895 = r318883 + r318894;
double r318896 = r318893 * r318895;
double r318897 = r318886 / r318896;
double r318898 = r318897 + r318883;
double r318899 = r318883 / r318895;
double r318900 = r318898 - r318899;
double r318901 = r318885 ? r318892 : r318900;
return r318901;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.9 |
|---|---|
| Target | 13.3 |
| Herbie | 1.1 |
if wj < 9.50840758158314e-09Initial program 13.6
Simplified13.6
Taylor expanded around 0 1.0
if 9.50840758158314e-09 < wj Initial program 24.1
Simplified2.6
rmApplied div-inv2.6
Applied associate-/l*2.6
Simplified2.6
Final simplification1.1
herbie shell --seed 2019318
(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))))))