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 r421081 = wj;
double r421082 = exp(r421081);
double r421083 = r421081 * r421082;
double r421084 = x;
double r421085 = r421083 - r421084;
double r421086 = r421082 + r421083;
double r421087 = r421085 / r421086;
double r421088 = r421081 - r421087;
return r421088;
}
double f(double wj, double x) {
double r421089 = wj;
double r421090 = -5.00771993997508e-09;
bool r421091 = r421089 <= r421090;
double r421092 = exp(r421089);
double r421093 = r421089 * r421092;
double r421094 = x;
double r421095 = r421093 - r421094;
double r421096 = r421092 + r421093;
double r421097 = r421095 / r421096;
double r421098 = r421089 - r421097;
double r421099 = 2.0;
double r421100 = r421099 * r421094;
double r421101 = r421089 - r421100;
double r421102 = r421089 * r421101;
double r421103 = r421094 + r421102;
double r421104 = r421091 ? r421098 : r421103;
return r421104;
}




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))))))