double f(double wj, double x) {
double r55895679 = wj;
double r55895680 = exp(r55895679);
double r55895681 = r55895679 * r55895680;
double r55895682 = x;
double r55895683 = r55895681 - r55895682;
double r55895684 = r55895680 + r55895681;
double r55895685 = r55895683 / r55895684;
double r55895686 = r55895679 - r55895685;
return r55895686;
}
double f(double wj, double x) {
double r55895687 = wj;
double r55895688 = 6.82905740885949e-09;
bool r55895689 = r55895687 <= r55895688;
double r55895690 = x;
double r55895691 = -2.0;
double r55895692 = r55895690 * r55895691;
double r55895693 = r55895692 + r55895687;
double r55895694 = r55895687 * r55895693;
double r55895695 = r55895690 + r55895694;
double r55895696 = exp(r55895687);
double r55895697 = r55895690 / r55895696;
double r55895698 = r55895687 - r55895697;
double r55895699 = 1.0;
double r55895700 = r55895687 + r55895699;
double r55895701 = r55895699 / r55895700;
double r55895702 = r55895698 * r55895701;
double r55895703 = r55895687 - r55895702;
double r55895704 = r55895689 ? r55895695 : r55895703;
return r55895704;
}
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 6.82905740885949 \cdot 10^{-09}:\\
\;\;\;\;x + wj \cdot \left(x \cdot -2 + wj\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \left(wj - \frac{x}{e^{wj}}\right) \cdot \frac{1}{wj + 1}\\
\end{array}



Bits error versus wj




Bits error versus x
| Original | 13.6 |
|---|---|
| Target | 13.0 |
| Herbie | 1.0 |
if wj < 6.82905740885949e-09Initial program 13.3
Taylor expanded around 0 0.9
Simplified1.0
if 6.82905740885949e-09 < wj Initial program 24.6
rmApplied distribute-rgt1-in24.6
Applied *-un-lft-identity24.6
Applied times-frac24.5
Simplified2.4
Final simplification1.0
herbie shell --seed 2019101
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:herbie-target
(- wj (- (/ wj (+ wj 1)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))