wj - \frac{wj \cdot e^{wj} - x}{e^{wj} + wj \cdot e^{wj}}\begin{array}{l}
\mathbf{if}\;x \leq -7.962081679886866 \cdot 10^{-17}:\\
\;\;\;\;wj + \frac{\frac{x}{e^{wj}} - wj}{wj \cdot wj - 1} \cdot \left(wj - 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + wj \cdot \left(wj + x \cdot -2\right)\\
\end{array}(FPCore (wj x) :precision binary64 (- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))
(FPCore (wj x) :precision binary64 (if (<= x -7.962081679886866e-17) (+ wj (* (/ (- (/ x (exp wj)) wj) (- (* wj wj) 1.0)) (- wj 1.0))) (+ x (* wj (+ wj (* x -2.0))))))
double code(double wj, double x) {
return ((double) (wj - (((double) (((double) (wj * ((double) exp(wj)))) - x)) / ((double) (((double) exp(wj)) + ((double) (wj * ((double) exp(wj)))))))));
}
double code(double wj, double x) {
double tmp;
if ((x <= -7.962081679886866e-17)) {
tmp = ((double) (wj + ((double) ((((double) ((x / ((double) exp(wj))) - wj)) / ((double) (((double) (wj * wj)) - 1.0))) * ((double) (wj - 1.0))))));
} else {
tmp = ((double) (x + ((double) (wj * ((double) (wj + ((double) (x * -2.0))))))));
}
return tmp;
}




Bits error versus wj




Bits error versus x
Results
| Original | 14.3 |
|---|---|
| Target | 13.8 |
| Herbie | 1.5 |
if x < -7.9620816798868662e-17Initial program 0.6
Simplified0.1
rmApplied flip-+_binary640.1
Applied associate-/r/_binary640.1
Simplified0.1
if -7.9620816798868662e-17 < x Initial program 19.2
Simplified18.7
Taylor expanded around 0 2.0
Simplified2.0
Final simplification1.5
herbie shell --seed 2020210
(FPCore (wj x)
:name "Jmat.Real.lambertw, newton loop step"
:precision binary64
:herbie-target
(- wj (- (/ wj (+ wj 1.0)) (/ x (+ (exp wj) (* wj (exp wj))))))
(- wj (/ (- (* wj (exp wj)) x) (+ (exp wj) (* wj (exp wj))))))