wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;x \le 2.885737033851384 \cdot 10^{-79}:\\
\;\;\;\;x + wj \cdot \left(wj - 2 \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj - \frac{x}{e^{wj}}}{wj \cdot \left(wj \cdot wj\right) + 1} \cdot \left(\left(wj \cdot wj - wj\right) + 1\right)\\
\end{array}double f(double wj, double x) {
double r8974172 = wj;
double r8974173 = exp(r8974172);
double r8974174 = r8974172 * r8974173;
double r8974175 = x;
double r8974176 = r8974174 - r8974175;
double r8974177 = r8974173 + r8974174;
double r8974178 = r8974176 / r8974177;
double r8974179 = r8974172 - r8974178;
return r8974179;
}
double f(double wj, double x) {
double r8974180 = x;
double r8974181 = 2.885737033851384e-79;
bool r8974182 = r8974180 <= r8974181;
double r8974183 = wj;
double r8974184 = 2.0;
double r8974185 = r8974184 * r8974180;
double r8974186 = r8974183 - r8974185;
double r8974187 = r8974183 * r8974186;
double r8974188 = r8974180 + r8974187;
double r8974189 = exp(r8974183);
double r8974190 = r8974180 / r8974189;
double r8974191 = r8974183 - r8974190;
double r8974192 = r8974183 * r8974183;
double r8974193 = r8974183 * r8974192;
double r8974194 = 1.0;
double r8974195 = r8974193 + r8974194;
double r8974196 = r8974191 / r8974195;
double r8974197 = r8974192 - r8974183;
double r8974198 = r8974197 + r8974194;
double r8974199 = r8974196 * r8974198;
double r8974200 = r8974183 - r8974199;
double r8974201 = r8974182 ? r8974188 : r8974200;
return r8974201;
}




Bits error versus wj




Bits error versus x
Results
| Original | 13.8 |
|---|---|
| Target | 13.2 |
| Herbie | 1.8 |
if x < 2.885737033851384e-79Initial program 19.2
Taylor expanded around 0 2.1
Simplified2.1
if 2.885737033851384e-79 < x Initial program 1.7
rmApplied *-un-lft-identity1.7
Applied distribute-rgt-out1.7
Applied associate-/r*1.7
Taylor expanded around -inf 1.1
rmApplied flip3-+1.1
Applied associate-/r/1.1
Simplified1.1
Final simplification1.8
herbie shell --seed 2019132
(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))))))