wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 4.306602228527943150027854119990031549921 \cdot 10^{-16}:\\
\;\;\;\;x + \left({wj}^{2} - x \cdot \left(2 \cdot wj\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\frac{x}{e^{wj}} - wj}{{wj}^{3} + 1} + wj\right) + \left(wj \cdot wj - wj\right) \cdot \frac{\frac{x}{e^{wj}} - wj}{{wj}^{3} + 1}\\
\end{array}double f(double wj, double x) {
double r121620 = wj;
double r121621 = exp(r121620);
double r121622 = r121620 * r121621;
double r121623 = x;
double r121624 = r121622 - r121623;
double r121625 = r121621 + r121622;
double r121626 = r121624 / r121625;
double r121627 = r121620 - r121626;
return r121627;
}
double f(double wj, double x) {
double r121628 = wj;
double r121629 = 4.306602228527943e-16;
bool r121630 = r121628 <= r121629;
double r121631 = x;
double r121632 = 2.0;
double r121633 = pow(r121628, r121632);
double r121634 = r121632 * r121628;
double r121635 = r121631 * r121634;
double r121636 = r121633 - r121635;
double r121637 = r121631 + r121636;
double r121638 = exp(r121628);
double r121639 = r121631 / r121638;
double r121640 = r121639 - r121628;
double r121641 = 3.0;
double r121642 = pow(r121628, r121641);
double r121643 = 1.0;
double r121644 = r121642 + r121643;
double r121645 = r121640 / r121644;
double r121646 = r121645 + r121628;
double r121647 = r121628 * r121628;
double r121648 = r121647 - r121628;
double r121649 = r121648 * r121645;
double r121650 = r121646 + r121649;
double r121651 = r121630 ? r121637 : r121650;
return r121651;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.9 |
|---|---|
| Target | 13.2 |
| Herbie | 0.8 |
if wj < 4.306602228527943e-16Initial program 13.5
Simplified13.5
Taylor expanded around 0 0.7
Simplified0.7
if 4.306602228527943e-16 < wj Initial program 22.5
Simplified6.0
rmApplied flip3-+6.0
Applied associate-/r/6.0
Simplified6.0
rmApplied distribute-lft-in5.9
Applied associate-+r+1.8
Simplified1.8
Final simplification0.8
herbie shell --seed 2019196
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:herbie-target
(- wj (- (/ wj (+ wj 1.0)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))