double f(double wj, double x) {
double r32624253 = wj;
double r32624254 = exp(r32624253);
double r32624255 = r32624253 * r32624254;
double r32624256 = x;
double r32624257 = r32624255 - r32624256;
double r32624258 = r32624254 + r32624255;
double r32624259 = r32624257 / r32624258;
double r32624260 = r32624253 - r32624259;
return r32624260;
}
double f(double wj, double x) {
double r32624261 = wj;
double r32624262 = 6.82905740885949e-09;
bool r32624263 = r32624261 <= r32624262;
double r32624264 = x;
double r32624265 = -2.0;
double r32624266 = fma(r32624264, r32624265, r32624261);
double r32624267 = fma(r32624266, r32624261, r32624264);
double r32624268 = exp(r32624261);
double r32624269 = r32624264 / r32624268;
double r32624270 = r32624261 - r32624269;
double r32624271 = 1.0;
double r32624272 = r32624261 + r32624271;
double r32624273 = r32624270 / r32624272;
double r32624274 = r32624261 - r32624273;
double r32624275 = r32624263 ? r32624267 : r32624274;
return r32624275;
}
wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 6.82905740885949 \cdot 10^{-09}:\\
\;\;\;\;(\left((x \cdot -2 + wj)_*\right) \cdot wj + x)_*\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj - \frac{x}{e^{wj}}}{wj + 1}\\
\end{array}



Bits error versus wj




Bits error versus x
| Original | 13.6 |
|---|---|
| Target | 13.0 |
| Herbie | 1.0 |
if wj < 6.82905740885949e-09Initial program 13.3
Taylor expanded around 0 0.9
Simplified1.0
if 6.82905740885949e-09 < wj Initial program 24.6
rmApplied add-sqr-sqrt33.5
Applied add-cube-cbrt34.0
Applied prod-diff34.0
Simplified33.3
Simplified2.5
Final simplification1.0
herbie shell --seed 2019101 +o rules:numerics
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:herbie-target
(- wj (- (/ wj (+ wj 1)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))