wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 7.410564643269004 \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}double f(double wj, double x) {
double r26918078 = wj;
double r26918079 = exp(r26918078);
double r26918080 = r26918078 * r26918079;
double r26918081 = x;
double r26918082 = r26918080 - r26918081;
double r26918083 = r26918079 + r26918080;
double r26918084 = r26918082 / r26918083;
double r26918085 = r26918078 - r26918084;
return r26918085;
}
double f(double wj, double x) {
double r26918086 = wj;
double r26918087 = 7.410564643269004e-09;
bool r26918088 = r26918086 <= r26918087;
double r26918089 = x;
double r26918090 = -2.0;
double r26918091 = fma(r26918089, r26918090, r26918086);
double r26918092 = fma(r26918091, r26918086, r26918089);
double r26918093 = exp(r26918086);
double r26918094 = r26918089 / r26918093;
double r26918095 = r26918086 - r26918094;
double r26918096 = 1.0;
double r26918097 = r26918086 + r26918096;
double r26918098 = r26918095 / r26918097;
double r26918099 = r26918086 - r26918098;
double r26918100 = r26918088 ? r26918092 : r26918099;
return r26918100;
}




Bits error versus wj




Bits error versus x
| Original | 14.0 |
|---|---|
| Target | 13.4 |
| Herbie | 0.9 |
if wj < 7.410564643269004e-09Initial program 13.7
Taylor expanded around 0 0.9
Simplified0.9
if 7.410564643269004e-09 < wj Initial program 22.1
rmApplied add-cube-cbrt22.9
Applied add-cube-cbrt23.2
Applied prod-diff23.2
Simplified22.2
Simplified2.5
Final simplification0.9
herbie shell --seed 2019112 +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))))))