wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le -5.670239909763437 \cdot 10^{-09}:\\
\;\;\;\;wj - \frac{wj - \frac{x}{e^{wj}}}{wj + 1}\\
\mathbf{elif}\;wj \le 6.686797031083422 \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 r41688136 = wj;
double r41688137 = exp(r41688136);
double r41688138 = r41688136 * r41688137;
double r41688139 = x;
double r41688140 = r41688138 - r41688139;
double r41688141 = r41688137 + r41688138;
double r41688142 = r41688140 / r41688141;
double r41688143 = r41688136 - r41688142;
return r41688143;
}
double f(double wj, double x) {
double r41688144 = wj;
double r41688145 = -5.670239909763437e-09;
bool r41688146 = r41688144 <= r41688145;
double r41688147 = x;
double r41688148 = exp(r41688144);
double r41688149 = r41688147 / r41688148;
double r41688150 = r41688144 - r41688149;
double r41688151 = 1.0;
double r41688152 = r41688144 + r41688151;
double r41688153 = r41688150 / r41688152;
double r41688154 = r41688144 - r41688153;
double r41688155 = 6.686797031083422e-09;
bool r41688156 = r41688144 <= r41688155;
double r41688157 = -2.0;
double r41688158 = fma(r41688147, r41688157, r41688144);
double r41688159 = fma(r41688158, r41688144, r41688147);
double r41688160 = r41688156 ? r41688159 : r41688154;
double r41688161 = r41688146 ? r41688154 : r41688160;
return r41688161;
}




Bits error versus wj




Bits error versus x
| Original | 13.5 |
|---|---|
| Target | 13.0 |
| Herbie | 0.4 |
if wj < -5.670239909763437e-09 or 6.686797031083422e-09 < wj Initial program 15.1
rmApplied distribute-rgt1-in15.1
Applied *-un-lft-identity15.1
Applied times-frac15.0
Applied add-cube-cbrt15.9
Applied prod-diff15.9
Simplified15.0
Simplified3.8
if -5.670239909763437e-09 < wj < 6.686797031083422e-09Initial program 13.4
Taylor expanded around 0 0.2
Simplified0.2
Final simplification0.4
herbie shell --seed 2019104 +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))))))