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




Bits error versus wj




Bits error versus x
Results
| Original | 14.0 |
|---|---|
| Target | 13.4 |
| Herbie | 0.1 |
if wj < -2.8835230579834852e-7Initial program 3.8
Simplified3.6
rmApplied *-un-lft-identity_binary643.6
if -2.8835230579834852e-7 < wj < 9.23366065363441782e-7Initial program 13.9
Simplified13.9
Taylor expanded around 0 0.0
Simplified0.0
Taylor expanded around 0 0.0
if 9.23366065363441782e-7 < wj Initial program 26.4
rmApplied div-sub_binary6426.4
Simplified1.8
Simplified1.8
Final simplification0.1
herbie shell --seed 2021175
(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))))))