wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 5.350338768905503620540304297349687434604 \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 r176264 = wj;
double r176265 = exp(r176264);
double r176266 = r176264 * r176265;
double r176267 = x;
double r176268 = r176266 - r176267;
double r176269 = r176265 + r176266;
double r176270 = r176268 / r176269;
double r176271 = r176264 - r176270;
return r176271;
}
double f(double wj, double x) {
double r176272 = wj;
double r176273 = 5.350338768905504e-09;
bool r176274 = r176272 <= r176273;
double r176275 = x;
double r176276 = 2.0;
double r176277 = pow(r176272, r176276);
double r176278 = r176275 + r176277;
double r176279 = r176272 * r176275;
double r176280 = r176276 * r176279;
double r176281 = r176278 - r176280;
double r176282 = exp(r176272);
double r176283 = 1.0;
double r176284 = r176272 + r176283;
double r176285 = r176282 * r176284;
double r176286 = r176275 / r176285;
double r176287 = r176286 + r176272;
double r176288 = r176272 / r176284;
double r176289 = r176287 - r176288;
double r176290 = r176274 ? r176281 : r176289;
return r176290;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.8 |
|---|---|
| Target | 13.1 |
| Herbie | 1.0 |
if wj < 5.350338768905504e-09Initial program 13.5
Simplified13.5
Taylor expanded around 0 0.9
if 5.350338768905504e-09 < wj Initial program 25.3
Simplified2.7
rmApplied div-inv2.7
Applied associate-/l*2.7
Simplified2.7
Final simplification1.0
herbie shell --seed 2019294
(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))))))