wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;wj \le 8.10407274317618 \cdot 10^{-09}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(x, -2, wj\right)\right), wj, x\right)\\
\mathbf{else}:\\
\;\;\;\;wj - \frac{wj - \frac{x}{e^{wj}}}{wj + 1}\\
\end{array}double f(double wj, double x) {
double r49540945 = wj;
double r49540946 = exp(r49540945);
double r49540947 = r49540945 * r49540946;
double r49540948 = x;
double r49540949 = r49540947 - r49540948;
double r49540950 = r49540946 + r49540947;
double r49540951 = r49540949 / r49540950;
double r49540952 = r49540945 - r49540951;
return r49540952;
}
double f(double wj, double x) {
double r49540953 = wj;
double r49540954 = 8.10407274317618e-09;
bool r49540955 = r49540953 <= r49540954;
double r49540956 = x;
double r49540957 = -2.0;
double r49540958 = fma(r49540956, r49540957, r49540953);
double r49540959 = fma(r49540958, r49540953, r49540956);
double r49540960 = exp(r49540953);
double r49540961 = r49540956 / r49540960;
double r49540962 = r49540953 - r49540961;
double r49540963 = 1.0;
double r49540964 = r49540953 + r49540963;
double r49540965 = r49540962 / r49540964;
double r49540966 = r49540953 - r49540965;
double r49540967 = r49540955 ? r49540959 : r49540966;
return r49540967;
}




Bits error versus wj




Bits error versus x
| Original | 13.3 |
|---|---|
| Target | 12.7 |
| Herbie | 1.0 |
if wj < 8.10407274317618e-09Initial program 13.0
Taylor expanded around 0 0.9
Simplified1.0
if 8.10407274317618e-09 < wj Initial program 23.9
rmApplied distribute-rgt1-in24.0
Applied *-un-lft-identity24.0
Applied times-frac23.9
Applied add-cube-cbrt24.7
Applied prod-diff24.7
Simplified23.9
Simplified2.8
Final simplification1.0
herbie shell --seed 2019121 +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))))))