x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \leq -1.8357328709070124 \cdot 10^{+119}:\\
\;\;\;\;x - y \cdot \frac{e^{z} - 1}{t}\\
\mathbf{elif}\;z \leq -2.1038187295767012:\\
\;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}}\\
\mathbf{elif}\;z \leq 3.6186242306556346 \cdot 10^{-100}:\\
\;\;\;\;x - \frac{0.041666666666666664 \cdot \left(y \cdot {z}^{4}\right) + \left(0.16666666666666666 \cdot \left(y \cdot {z}^{3}\right) + \left(z \cdot y + 0.5 \cdot \left(y \cdot {z}^{2}\right)\right)\right)}{t}\\
\mathbf{elif}\;z \leq 1.4860099414128433 \cdot 10^{-25}:\\
\;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot \left(\left(z + 0.5 \cdot \left(z \cdot z\right)\right) + \left(0.041666666666666664 \cdot {z}^{4} + 0.16666666666666666 \cdot {z}^{3}\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 (<= z -1.8357328709070124e+119)
(- x (* y (/ (- (exp z) 1.0) t)))
(if (<= z -2.1038187295767012)
(- x (/ 1.0 (/ t (log (+ (- 1.0 y) (* y (exp z)))))))
(if (<= z 3.6186242306556346e-100)
(-
x
(/
(+
(* 0.041666666666666664 (* y (pow z 4.0)))
(+
(* 0.16666666666666666 (* y (pow z 3.0)))
(+ (* z y) (* 0.5 (* y (pow z 2.0))))))
t))
(if (<= z 1.4860099414128433e-25)
(- x (/ (log (+ 1.0 (* z y))) t))
(-
x
(/
(*
y
(+
(+ z (* 0.5 (* z z)))
(+
(* 0.041666666666666664 (pow z 4.0))
(* 0.16666666666666666 (pow z 3.0)))))
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 (z <= -1.8357328709070124e+119) {
tmp = x - (y * ((exp(z) - 1.0) / t));
} else if (z <= -2.1038187295767012) {
tmp = x - (1.0 / (t / log((1.0 - y) + (y * exp(z)))));
} else if (z <= 3.6186242306556346e-100) {
tmp = x - (((0.041666666666666664 * (y * pow(z, 4.0))) + ((0.16666666666666666 * (y * pow(z, 3.0))) + ((z * y) + (0.5 * (y * pow(z, 2.0)))))) / t);
} else if (z <= 1.4860099414128433e-25) {
tmp = x - (log(1.0 + (z * y)) / t);
} else {
tmp = x - ((y * ((z + (0.5 * (z * z))) + ((0.041666666666666664 * pow(z, 4.0)) + (0.16666666666666666 * pow(z, 3.0))))) / t);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.4 |
|---|---|
| Target | 16.8 |
| Herbie | 9.1 |
if z < -1.8357328709070124e119Initial program 11.7
Taylor expanded around 0 14.8
Simplified14.8
rmApplied *-un-lft-identity_binary64_894414.8
Applied *-un-lft-identity_binary64_894414.8
Applied distribute-rgt-out--_binary64_889814.8
Applied times-frac_binary64_895014.8
if -1.8357328709070124e119 < z < -2.10381872957670124Initial program 11.0
rmApplied clear-num_binary64_894311.0
if -2.10381872957670124 < z < 3.6186242306556346e-100Initial program 30.9
Taylor expanded around 0 15.4
Simplified15.4
Taylor expanded around 0 6.1
if 3.6186242306556346e-100 < z < 1.48600994141284333e-25Initial program 32.1
Taylor expanded around 0 11.5
Simplified11.5
if 1.48600994141284333e-25 < z Initial program 31.6
Taylor expanded around 0 26.7
Simplified26.6
Taylor expanded around 0 19.8
Simplified19.7
Final simplification9.1
herbie shell --seed 2021044
(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)))