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}:\\
\;\;\;\;x + wj \cdot \left(wj - 2 \cdot x\right)\\
\end{array}double f(double wj, double x) {
double r468297 = wj;
double r468298 = exp(r468297);
double r468299 = r468297 * r468298;
double r468300 = x;
double r468301 = r468299 - r468300;
double r468302 = r468298 + r468299;
double r468303 = r468301 / r468302;
double r468304 = r468297 - r468303;
return r468304;
}
double f(double wj, double x) {
double r468305 = wj;
double r468306 = -5.00771993997508e-09;
bool r468307 = r468305 <= r468306;
double r468308 = exp(r468305);
double r468309 = r468305 * r468308;
double r468310 = x;
double r468311 = r468309 - r468310;
double r468312 = r468308 + r468309;
double r468313 = r468311 / r468312;
double r468314 = r468305 - r468313;
double r468315 = 2.0;
double r468316 = r468315 * r468310;
double r468317 = r468305 - r468316;
double r468318 = r468305 * r468317;
double r468319 = r468310 + r468318;
double r468320 = r468307 ? r468314 : r468319;
return r468320;
}




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
Simplified1.5
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))))))