wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 1.9744252120415485 \cdot 10^{-9}:\\
\;\;\;\;1 \cdot \mathsf{fma}\left(wj, wj, x\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\frac{x}{{wj}^{3} + 1}}{\sqrt{e^{wj}}} \cdot \frac{wj \cdot wj + \left(1 - wj \cdot 1\right)}{\sqrt{e^{wj}}} + wj\right) - \frac{wj}{wj + 1}\\
\end{array}double f(double wj, double x) {
double r147619 = wj;
double r147620 = exp(r147619);
double r147621 = r147619 * r147620;
double r147622 = x;
double r147623 = r147621 - r147622;
double r147624 = r147620 + r147621;
double r147625 = r147623 / r147624;
double r147626 = r147619 - r147625;
return r147626;
}
double f(double wj, double x) {
double r147627 = wj;
double r147628 = 1.9744252120415485e-09;
bool r147629 = r147627 <= r147628;
double r147630 = 1.0;
double r147631 = x;
double r147632 = fma(r147627, r147627, r147631);
double r147633 = r147630 * r147632;
double r147634 = 2.0;
double r147635 = r147627 * r147631;
double r147636 = r147634 * r147635;
double r147637 = r147633 - r147636;
double r147638 = 3.0;
double r147639 = pow(r147627, r147638);
double r147640 = r147639 + r147630;
double r147641 = r147631 / r147640;
double r147642 = exp(r147627);
double r147643 = sqrt(r147642);
double r147644 = r147641 / r147643;
double r147645 = r147627 * r147627;
double r147646 = r147627 * r147630;
double r147647 = r147630 - r147646;
double r147648 = r147645 + r147647;
double r147649 = r147648 / r147643;
double r147650 = r147644 * r147649;
double r147651 = r147650 + r147627;
double r147652 = r147627 + r147630;
double r147653 = r147627 / r147652;
double r147654 = r147651 - r147653;
double r147655 = r147629 ? r147637 : r147654;
return r147655;
}




Bits error versus wj




Bits error versus x
| Original | 13.6 |
|---|---|
| Target | 13.0 |
| Herbie | 1.0 |
if wj < 1.9744252120415485e-09Initial program 13.3
Simplified13.3
Taylor expanded around 0 0.9
rmApplied *-un-lft-identity0.9
Applied *-un-lft-identity0.9
Applied distribute-lft-out0.9
Simplified0.9
if 1.9744252120415485e-09 < wj Initial program 22.7
Simplified3.6
rmApplied add-sqr-sqrt3.7
Applied flip3-+3.8
Applied associate-/r/3.7
Applied times-frac3.7
Simplified3.7
Simplified3.7
Final simplification1.0
herbie shell --seed 2020003 +o rules:numerics
(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))))))