wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le -5.007719939975079832531441257617230156107 \cdot 10^{-9}:\\
\;\;\;\;wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\\
\mathbf{else}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\end{array}double f(double wj, double x) {
double r176111 = wj;
double r176112 = exp(r176111);
double r176113 = r176111 * r176112;
double r176114 = x;
double r176115 = r176113 - r176114;
double r176116 = r176112 + r176113;
double r176117 = r176115 / r176116;
double r176118 = r176111 - r176117;
return r176118;
}
double f(double wj, double x) {
double r176119 = wj;
double r176120 = -5.00771993997508e-09;
bool r176121 = r176119 <= r176120;
double r176122 = exp(r176119);
double r176123 = r176119 * r176122;
double r176124 = x;
double r176125 = r176123 - r176124;
double r176126 = r176122 + r176123;
double r176127 = r176125 / r176126;
double r176128 = r176119 - r176127;
double r176129 = 2.0;
double r176130 = pow(r176119, r176129);
double r176131 = r176124 + r176130;
double r176132 = r176119 * r176124;
double r176133 = r176129 * r176132;
double r176134 = r176131 - r176133;
double r176135 = r176121 ? r176128 : r176134;
return r176135;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.4 |
|---|---|
| Target | 12.8 |
| Herbie | 1.5 |
if wj < -5.00771993997508e-09Initial program 5.8
if -5.00771993997508e-09 < wj Initial program 13.6
Simplified12.9
Taylor expanded around 0 1.4
Final simplification1.5
herbie shell --seed 2019323
(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))))))