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{1 - e^{z}}{t}\\
\mathbf{elif}\;z \leq -2.1038187295767012:\\
\;\;\;\;x - \frac{1}{\frac{t}{\log \left(y \cdot e^{z} + \left(1 - y\right)\right)}}\\
\mathbf{elif}\;z \leq 3.6186242306556346 \cdot 10^{-100} \lor \neg \left(z \leq 1.4860099414128433 \cdot 10^{-25}\right):\\
\;\;\;\;x - \frac{y \cdot \left(\left(z + \left(z \cdot z\right) \cdot 0.5\right) + \left({z}^{4} \cdot 0.041666666666666664 + 0.16666666666666666 \cdot {z}^{3}\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1 + z \cdot y\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 (/ (- 1.0 (exp z)) t)))
(if (<= z -2.1038187295767012)
(- x (/ 1.0 (/ t (log (+ (* y (exp z)) (- 1.0 y))))))
(if (or (<= z 3.6186242306556346e-100)
(not (<= z 1.4860099414128433e-25)))
(-
x
(/
(*
y
(+
(+ z (* (* z z) 0.5))
(+
(* (pow z 4.0) 0.041666666666666664)
(* 0.16666666666666666 (pow z 3.0)))))
t))
(- x (/ (log (+ 1.0 (* z y))) 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 * ((1.0 - exp(z)) / t));
} else if (z <= -2.1038187295767012) {
tmp = x - (1.0 / (t / log((y * exp(z)) + (1.0 - y))));
} else if ((z <= 3.6186242306556346e-100) || !(z <= 1.4860099414128433e-25)) {
tmp = x - ((y * ((z + ((z * z) * 0.5)) + ((pow(z, 4.0) * 0.041666666666666664) + (0.16666666666666666 * pow(z, 3.0))))) / t);
} else {
tmp = x - (log(1.0 + (z * y)) / 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 |
| Alternative 1 | |
|---|---|
| Error | 9.4 |
| Cost | 14274 |
| Alternative 2 | |
|---|---|
| Error | 9.4 |
| Cost | 14146 |
| Alternative 3 | |
|---|---|
| Error | 9.6 |
| Cost | 7939 |
| Alternative 4 | |
|---|---|
| Error | 9.5 |
| Cost | 13697 |
| Alternative 5 | |
|---|---|
| Error | 13.0 |
| Cost | 7490 |
| Alternative 6 | |
|---|---|
| Error | 12.0 |
| Cost | 1153 |
| Alternative 7 | |
|---|---|
| Error | 12.1 |
| Cost | 769 |
| Alternative 8 | |
|---|---|
| Error | 18.4 |
| Cost | 64 |
| Alternative 9 | |
|---|---|
| Error | 61.8 |
| Cost | 64 |
| Alternative 10 | |
|---|---|
| Error | 62.0 |
| Cost | 64 |
| Alternative 11 | |
|---|---|
| Error | 61.7 |
| Cost | 64 |

if z < -1.8357328709070124e119Initial program 11.7
Taylor expanded around 0 14.8
Simplified14.8
rmApplied div-inv_binary64_962314.8
rmApplied sub-neg_binary64_961914.8
Simplified14.8
Simplified14.8
if -1.8357328709070124e119 < z < -2.10381872957670124Initial program 11.0
rmApplied clear-num_binary64_962511.0
Simplified11.0
Simplified11.0
if -2.10381872957670124 < z < 3.6186242306556346e-100 or 1.48600994141284333e-25 < z Initial program 31.0
Taylor expanded around 0 16.0
Simplified16.0
Taylor expanded around 0 6.9
Simplified6.9
Simplified6.9
if 3.6186242306556346e-100 < z < 1.48600994141284333e-25Initial program 32.1
Taylor expanded around 0 11.5
Simplified11.5
Simplified11.5
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)))