wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 2.1610528876044702 \cdot 10^{-5}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) \cdot \left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) - \frac{wj}{wj + 1} \cdot \frac{wj}{wj + 1}}{\left(\frac{\frac{x}{wj + 1}}{e^{wj}} + wj\right) + \frac{wj}{wj + 1}}\\
\end{array}double f(double wj, double x) {
double r269619 = wj;
double r269620 = exp(r269619);
double r269621 = r269619 * r269620;
double r269622 = x;
double r269623 = r269621 - r269622;
double r269624 = r269620 + r269621;
double r269625 = r269623 / r269624;
double r269626 = r269619 - r269625;
return r269626;
}
double f(double wj, double x) {
double r269627 = wj;
double r269628 = 2.1610528876044702e-05;
bool r269629 = r269627 <= r269628;
double r269630 = x;
double r269631 = 2.0;
double r269632 = pow(r269627, r269631);
double r269633 = r269630 + r269632;
double r269634 = r269627 * r269630;
double r269635 = r269631 * r269634;
double r269636 = r269633 - r269635;
double r269637 = 1.0;
double r269638 = r269627 + r269637;
double r269639 = r269630 / r269638;
double r269640 = exp(r269627);
double r269641 = r269639 / r269640;
double r269642 = r269641 + r269627;
double r269643 = r269642 * r269642;
double r269644 = r269627 / r269638;
double r269645 = r269644 * r269644;
double r269646 = r269643 - r269645;
double r269647 = r269642 + r269644;
double r269648 = r269646 / r269647;
double r269649 = r269629 ? r269636 : r269648;
return r269649;
}




Bits error versus wj




Bits error versus x
Results
| Original | 14.0 |
|---|---|
| Target | 13.4 |
| Herbie | 1.1 |
if wj < 2.1610528876044702e-05Initial program 13.7
Simplified13.7
Taylor expanded around 0 0.9
if 2.1610528876044702e-05 < wj Initial program 27.8
Simplified1.6
rmApplied flip--9.9
Final simplification1.1
herbie shell --seed 2020020
(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))))))