wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 1.425827286753258358087311776993266754232 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(wj \cdot x, -2, \mathsf{fma}\left(wj, wj, x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{{wj}^{3} - {\left(\frac{x}{e^{wj}}\right)}^{3}}{\mathsf{fma}\left(wj, wj, \frac{x}{e^{wj}} \cdot \left(wj + \frac{x}{e^{wj}}\right)\right) \cdot \left(1 + wj\right)}\\
\end{array}double f(double wj, double x) {
double r150269 = wj;
double r150270 = exp(r150269);
double r150271 = r150269 * r150270;
double r150272 = x;
double r150273 = r150271 - r150272;
double r150274 = r150270 + r150271;
double r150275 = r150273 / r150274;
double r150276 = r150269 - r150275;
return r150276;
}
double f(double wj, double x) {
double r150277 = wj;
double r150278 = 1.4258272867532584e-07;
bool r150279 = r150277 <= r150278;
double r150280 = x;
double r150281 = r150277 * r150280;
double r150282 = -2.0;
double r150283 = fma(r150277, r150277, r150280);
double r150284 = fma(r150281, r150282, r150283);
double r150285 = 3.0;
double r150286 = pow(r150277, r150285);
double r150287 = exp(r150277);
double r150288 = r150280 / r150287;
double r150289 = pow(r150288, r150285);
double r150290 = r150286 - r150289;
double r150291 = r150277 + r150288;
double r150292 = r150288 * r150291;
double r150293 = fma(r150277, r150277, r150292);
double r150294 = 1.0;
double r150295 = r150294 + r150277;
double r150296 = r150293 * r150295;
double r150297 = r150290 / r150296;
double r150298 = r150277 - r150297;
double r150299 = r150279 ? r150284 : r150298;
return r150299;
}




Bits error versus wj




Bits error versus x
| Original | 14.1 |
|---|---|
| Target | 13.6 |
| Herbie | 1.3 |
if wj < 1.4258272867532584e-07Initial program 13.9
Simplified13.9
Taylor expanded around 0 1.0
Simplified1.0
if 1.4258272867532584e-07 < wj Initial program 24.7
Simplified2.5
rmApplied flip3--15.1
Applied associate-/l/15.3
Simplified15.3
Final simplification1.3
herbie shell --seed 2019303 +o rules:numerics
(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))))))