x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -\infty:\\
\;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + 0.5 \cdot \left(z \cdot z\right)\right)\right)}{t}\\
\mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -1.2237850520638158 \cdot 10^{+31}:\\
\;\;\;\;x - \frac{1}{\frac{t}{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}}\\
\mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -9.808485353193813 \cdot 10^{-254}:\\
\;\;\;\;x - \frac{1}{\frac{t}{y \cdot z} + 0.5 \cdot \left(t - \frac{t}{y}\right)}\\
\mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq -2.3925554644476883 \cdot 10^{-263}:\\
\;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \left(e^{z} \cdot \sqrt[3]{y}\right)\right)}{t}\\
\mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 4.726731912050994 \cdot 10^{-98}:\\
\;\;\;\;x - \frac{1}{\frac{\frac{t}{y}}{z + \left(1 - y\right) \cdot \left(0.5 \cdot \left(z \cdot z\right)\right)}}\\
\mathbf{elif}\;x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t} \leq 5.616777882652408 \cdot 10^{+306}:\\
\;\;\;\;x - \frac{\log \left(\left(1 - y\right) + \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \left(e^{z} \cdot \sqrt[3]{y}\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1 + y \cdot \left(z + 0.5 \cdot \left(z \cdot z\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 (<= (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)) (- INFINITY))
(- x (/ (log (+ 1.0 (* y (+ z (* 0.5 (* z z)))))) t))
(if (<=
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t))
-1.2237850520638158e+31)
(- x (/ 1.0 (/ t (log (+ (- 1.0 y) (* y (exp z)))))))
(if (<=
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t))
-9.808485353193813e-254)
(- x (/ 1.0 (+ (/ t (* y z)) (* 0.5 (- t (/ t y))))))
(if (<=
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t))
-2.3925554644476883e-263)
(-
x
(/
(log (+ (- 1.0 y) (* (* (cbrt y) (cbrt y)) (* (exp z) (cbrt y)))))
t))
(if (<=
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t))
4.726731912050994e-98)
(- x (/ 1.0 (/ (/ t y) (+ z (* (- 1.0 y) (* 0.5 (* z z)))))))
(if (<=
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t))
5.616777882652408e+306)
(-
x
(/
(log
(+ (- 1.0 y) (* (* (cbrt y) (cbrt y)) (* (exp z) (cbrt y)))))
t))
(- x (/ (log (+ 1.0 (* y (+ z (* 0.5 (* z z)))))) 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 ((x - (log((1.0 - y) + (y * exp(z))) / t)) <= -((double) INFINITY)) {
tmp = x - (log(1.0 + (y * (z + (0.5 * (z * z))))) / t);
} else if ((x - (log((1.0 - y) + (y * exp(z))) / t)) <= -1.2237850520638158e+31) {
tmp = x - (1.0 / (t / log((1.0 - y) + (y * exp(z)))));
} else if ((x - (log((1.0 - y) + (y * exp(z))) / t)) <= -9.808485353193813e-254) {
tmp = x - (1.0 / ((t / (y * z)) + (0.5 * (t - (t / y)))));
} else if ((x - (log((1.0 - y) + (y * exp(z))) / t)) <= -2.3925554644476883e-263) {
tmp = x - (log((1.0 - y) + ((cbrt(y) * cbrt(y)) * (exp(z) * cbrt(y)))) / t);
} else if ((x - (log((1.0 - y) + (y * exp(z))) / t)) <= 4.726731912050994e-98) {
tmp = x - (1.0 / ((t / y) / (z + ((1.0 - y) * (0.5 * (z * z))))));
} else if ((x - (log((1.0 - y) + (y * exp(z))) / t)) <= 5.616777882652408e+306) {
tmp = x - (log((1.0 - y) + ((cbrt(y) * cbrt(y)) * (exp(z) * cbrt(y)))) / t);
} else {
tmp = x - (log(1.0 + (y * (z + (0.5 * (z * z))))) / t);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 25.0 |
|---|---|
| Target | 16.4 |
| Herbie | 11.0 |
if (-.f64 x (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t)) < -inf.0 or 5.6167778826524082e306 < (-.f64 x (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t)) Initial program 63.9
Taylor expanded around 0 14.2
Simplified14.2
if -inf.0 < (-.f64 x (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t)) < -1.2237850520638158e31Initial program 2.5
rmApplied clear-num_binary64_96252.5
Simplified2.5
if -1.2237850520638158e31 < (-.f64 x (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t)) < -9.80848535319381343e-254Initial program 15.8
Taylor expanded around 0 23.4
Simplified23.4
rmApplied clear-num_binary64_962523.5
Simplified23.5
Taylor expanded around 0 15.6
Simplified15.6
if -9.80848535319381343e-254 < (-.f64 x (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t)) < -2.3925554644476883e-263 or 4.72673191205099409e-98 < (-.f64 x (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t)) < 5.6167778826524082e306Initial program 5.7
rmApplied add-cube-cbrt_binary64_96615.9
Applied associate-*l*_binary64_95675.9
Simplified5.9
if -2.3925554644476883e-263 < (-.f64 x (/.f64 (log.f64 (+.f64 (-.f64 1 y) (*.f64 y (exp.f64 z)))) t)) < 4.72673191205099409e-98Initial program 26.0
Taylor expanded around 0 25.6
Simplified25.6
rmApplied clear-num_binary64_962525.6
Simplified25.6
rmApplied associate-/r*_binary64_957020.4
Final simplification11.0
herbie shell --seed 2020356
(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)))