x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;y \leq -2.5849067727820856 \cdot 10^{-36}:\\
\;\;\;\;x - \frac{\log \left(1 - \left(y - y \cdot e^{z}\right)\right)}{t}\\
\mathbf{elif}\;y \leq -2.093658234288246 \cdot 10^{-131}:\\
\;\;\;\;x - \left(\frac{y \cdot z}{t} + 0.5 \cdot \left(\frac{z \cdot z}{t} \cdot \left(y - y \cdot y\right)\right)\right)\\
\mathbf{elif}\;y \leq 6.199663690275312 \cdot 10^{-24}:\\
\;\;\;\;x - \frac{e^{\log \log \left(y \cdot e^{z} + \left(1 - y\right)\right)}}{t}\\
\mathbf{elif}\;y \leq 1.3278686628389493 \cdot 10^{+114}:\\
\;\;\;\;x - \left(\frac{y \cdot z}{t} + 0.5 \cdot \left(\frac{z \cdot z}{t} \cdot \left(y - y \cdot y\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(\sqrt[3]{1 + y \cdot \left(z + \left(z \cdot z\right) \cdot \left(0.5 + z \cdot 0.16666666666666666\right)\right)}\right) + 2 \cdot \log \left(\sqrt[3]{1 + y \cdot \left(z + \left(z \cdot z\right) \cdot \left(0.5 + z \cdot 0.16666666666666666\right)\right)}\right)}{t}\\
\end{array}(FPCore (x y z t) :precision binary64 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
(FPCore (x y z t)
:precision binary64
(if (<= y -2.5849067727820856e-36)
(- x (/ (log (- 1.0 (- y (* y (exp z))))) t))
(if (<= y -2.093658234288246e-131)
(- x (+ (/ (* y z) t) (* 0.5 (* (/ (* z z) t) (- y (* y y))))))
(if (<= y 6.199663690275312e-24)
(- x (/ (exp (log (log (+ (* y (exp z)) (- 1.0 y))))) t))
(if (<= y 1.3278686628389493e+114)
(- x (+ (/ (* y z) t) (* 0.5 (* (/ (* z z) t) (- y (* y y))))))
(-
x
(/
(+
(log
(cbrt
(+
1.0
(* y (+ z (* (* z z) (+ 0.5 (* z 0.16666666666666666))))))))
(*
2.0
(log
(cbrt
(+
1.0
(* y (+ z (* (* z z) (+ 0.5 (* z 0.16666666666666666))))))))))
t)))))))double code(double x, double y, double z, double t) {
return x - (log((1.0 - y) + (y * exp(z))) / t);
}
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.5849067727820856e-36) {
tmp = x - (log(1.0 - (y - (y * exp(z)))) / t);
} else if (y <= -2.093658234288246e-131) {
tmp = x - (((y * z) / t) + (0.5 * (((z * z) / t) * (y - (y * y)))));
} else if (y <= 6.199663690275312e-24) {
tmp = x - (exp(log(log((y * exp(z)) + (1.0 - y)))) / t);
} else if (y <= 1.3278686628389493e+114) {
tmp = x - (((y * z) / t) + (0.5 * (((z * z) / t) * (y - (y * y)))));
} else {
tmp = x - ((log(cbrt(1.0 + (y * (z + ((z * z) * (0.5 + (z * 0.16666666666666666))))))) + (2.0 * log(cbrt(1.0 + (y * (z + ((z * z) * (0.5 + (z * 0.16666666666666666))))))))) / t);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.1 |
|---|---|
| Target | 16.3 |
| Herbie | 12.3 |
if y < -2.58490677278208557e-36Initial program 33.3
rmApplied associate-+l-_binary6415.3
if -2.58490677278208557e-36 < y < -2.093658234288246e-131 or 6.1996636902753117e-24 < y < 1.32786866283894932e114Initial program 31.2
Taylor expanded around 0 12.2
Simplified12.3
if -2.093658234288246e-131 < y < 6.1996636902753117e-24Initial program 10.4
rmApplied add-exp-log_binary6410.4
if 1.32786866283894932e114 < y Initial program 61.3
rmApplied associate-+l-_binary6427.6
Taylor expanded around 0 11.6
Simplified11.6
rmApplied add-cube-cbrt_binary6411.7
Applied log-prod_binary6411.8
Simplified11.8
Simplified11.8
Final simplification12.3
herbie shell --seed 2020232
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
:precision binary64
:herbie-target
(if (< z -2.8874623088207947e+119) (- (- x (/ (/ (- 0.5) (* y t)) (* z z))) (* (/ (- 0.5) (* y t)) (/ (/ 2.0 z) (* z z)))) (- x (/ (log (+ 1.0 (* z y))) t)))
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))