wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 6.728609179253453840938316012033545976401 \cdot 10^{-9}:\\
\;\;\;\;\left(x + wj \cdot wj\right) + \left(x \cdot wj\right) \cdot -2\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{e^{wj}} - wj}{1 - wj \cdot wj} \cdot \left(1 - wj\right) + wj\\
\end{array}double f(double wj, double x) {
double r300628 = wj;
double r300629 = exp(r300628);
double r300630 = r300628 * r300629;
double r300631 = x;
double r300632 = r300630 - r300631;
double r300633 = r300629 + r300630;
double r300634 = r300632 / r300633;
double r300635 = r300628 - r300634;
return r300635;
}
double f(double wj, double x) {
double r300636 = wj;
double r300637 = 6.728609179253454e-09;
bool r300638 = r300636 <= r300637;
double r300639 = x;
double r300640 = r300636 * r300636;
double r300641 = r300639 + r300640;
double r300642 = r300639 * r300636;
double r300643 = -2.0;
double r300644 = r300642 * r300643;
double r300645 = r300641 + r300644;
double r300646 = exp(r300636);
double r300647 = r300639 / r300646;
double r300648 = r300647 - r300636;
double r300649 = 1.0;
double r300650 = r300649 - r300640;
double r300651 = r300648 / r300650;
double r300652 = r300649 - r300636;
double r300653 = r300651 * r300652;
double r300654 = r300653 + r300636;
double r300655 = r300638 ? r300645 : r300654;
return r300655;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.7 |
|---|---|
| Target | 13.1 |
| Herbie | 0.9 |
if wj < 6.728609179253454e-09Initial program 13.4
Simplified13.4
Taylor expanded around 0 0.8
Simplified0.8
if 6.728609179253454e-09 < wj Initial program 24.5
Simplified2.9
rmApplied flip-+2.9
Applied associate-/r/2.9
Simplified2.9
Final simplification0.9
herbie shell --seed 2019179
(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))))))