x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \leq -0.0035490673696887158:\\
\;\;\;\;x - \frac{\log \left(1 - \left(y - y \cdot e^{z}\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\frac{y}{\sqrt[3]{t}} \cdot \frac{z + \left(z \cdot z\right) \cdot \left(0.5 \cdot \left(1 - y\right)\right)}{\sqrt[3]{t}}}{\sqrt[3]{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 -0.0035490673696887158)
(- x (/ (log (- 1.0 (- y (* y (exp z))))) t))
(-
x
(/
(* (/ y (cbrt t)) (/ (+ z (* (* z z) (* 0.5 (- 1.0 y)))) (cbrt t)))
(cbrt 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 <= -0.0035490673696887158) {
tmp = x - (log(1.0 - (y - (y * exp(z)))) / t);
} else {
tmp = x - (((y / cbrt(t)) * ((z + ((z * z) * (0.5 * (1.0 - y)))) / cbrt(t))) / cbrt(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.0 |
| Herbie | 9.2 |
if z < -0.0035490673696887158Initial program 12.0
rmApplied associate-+l-_binary64_1102212.0
if -0.0035490673696887158 < z Initial program 30.7
rmApplied add-cube-cbrt_binary64_1112225.7
Applied associate-*l*_binary64_1102825.7
Simplified25.7
Taylor expanded around 0 14.1
Simplified8.4
rmApplied add-cube-cbrt_binary64_111228.6
Applied associate-/r*_binary64_110318.6
Simplified8.0
Final simplification9.2
herbie shell --seed 2020280
(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)))