wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 4.160404689641216852166604763104892916736 \cdot 10^{-9}:\\
\;\;\;\;\left(x + {wj}^{2}\right) - 2 \cdot \left(wj \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{x}{e^{wj} \cdot \left(wj + 1\right)} + wj\right) - \frac{wj}{wj + 1}\\
\end{array}double f(double wj, double x) {
double r408099 = wj;
double r408100 = exp(r408099);
double r408101 = r408099 * r408100;
double r408102 = x;
double r408103 = r408101 - r408102;
double r408104 = r408100 + r408101;
double r408105 = r408103 / r408104;
double r408106 = r408099 - r408105;
return r408106;
}
double f(double wj, double x) {
double r408107 = wj;
double r408108 = 4.160404689641217e-09;
bool r408109 = r408107 <= r408108;
double r408110 = x;
double r408111 = 2.0;
double r408112 = pow(r408107, r408111);
double r408113 = r408110 + r408112;
double r408114 = r408107 * r408110;
double r408115 = r408111 * r408114;
double r408116 = r408113 - r408115;
double r408117 = exp(r408107);
double r408118 = 1.0;
double r408119 = r408107 + r408118;
double r408120 = r408117 * r408119;
double r408121 = r408110 / r408120;
double r408122 = r408121 + r408107;
double r408123 = r408107 / r408119;
double r408124 = r408122 - r408123;
double r408125 = r408109 ? r408116 : r408124;
return r408125;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.7 |
|---|---|
| Target | 13.1 |
| Herbie | 0.9 |
if wj < 4.160404689641217e-09Initial program 13.4
Simplified13.4
Taylor expanded around 0 0.8
if 4.160404689641217e-09 < wj Initial program 26.7
Simplified2.9
rmApplied div-inv2.9
Applied associate-/l*2.9
Simplified2.9
Final simplification0.9
herbie shell --seed 2020001
(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))))))