wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 9.422333290444803599555997767386189556404 \cdot 10^{-9}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) - \frac{1}{\sqrt{wj + 1}} \cdot \frac{wj}{\sqrt{wj + 1}}\\
\end{array}double f(double wj, double x) {
double r173565 = wj;
double r173566 = exp(r173565);
double r173567 = r173565 * r173566;
double r173568 = x;
double r173569 = r173567 - r173568;
double r173570 = r173566 + r173567;
double r173571 = r173569 / r173570;
double r173572 = r173565 - r173571;
return r173572;
}
double f(double wj, double x) {
double r173573 = wj;
double r173574 = 9.422333290444804e-09;
bool r173575 = r173573 <= r173574;
double r173576 = x;
double r173577 = 2.0;
double r173578 = pow(r173573, r173577);
double r173579 = r173576 + r173578;
double r173580 = r173573 * r173576;
double r173581 = r173577 * r173580;
double r173582 = r173579 - r173581;
double r173583 = 1.0;
double r173584 = r173573 + r173583;
double r173585 = r173576 / r173584;
double r173586 = exp(r173573);
double r173587 = r173585 / r173586;
double r173588 = r173587 + r173573;
double r173589 = sqrt(r173584);
double r173590 = r173583 / r173589;
double r173591 = r173573 / r173589;
double r173592 = r173590 * r173591;
double r173593 = r173588 - r173592;
double r173594 = r173575 ? r173582 : r173593;
return r173594;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.3 |
|---|---|
| Target | 12.6 |
| Herbie | 1.0 |
if wj < 9.422333290444804e-09Initial program 12.9
Simplified12.9
Taylor expanded around 0 1.0
if 9.422333290444804e-09 < wj Initial program 28.2
Simplified2.8
rmApplied add-sqr-sqrt3.0
Applied *-un-lft-identity3.0
Applied times-frac3.1
Final simplification1.0
herbie shell --seed 2019298
(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))))))