x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \leq -1.5821215835774233 \cdot 10^{+26}:\\
\;\;\;\;x + \log \left(1 + \left(y \cdot e^{z} - y\right)\right) \cdot \frac{-1}{t}\\
\mathbf{elif}\;z \leq 5.038099887940745 \cdot 10^{-195}:\\
\;\;\;\;x - \left(1 \cdot \left(\frac{\sqrt[3]{z}}{\sqrt[3]{t}} \cdot \left(\frac{\sqrt[3]{z}}{\sqrt[3]{t}} \cdot \left(y \cdot \frac{\sqrt[3]{z}}{\sqrt[3]{t}}\right)\right)\right) + \left(\frac{\log 1}{t} + 0.5 \cdot \left(y \cdot \frac{z}{\frac{t}{z}}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \log \left(1 + y \cdot \left(0.16666666666666666 \cdot {z}^{3} + \left(z + z \cdot \left(z \cdot 0.5\right)\right)\right)\right) \cdot \frac{-1}{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.5821215835774233e+26)
(+ x (* (log (+ 1.0 (- (* y (exp z)) y))) (/ -1.0 t)))
(if (<= z 5.038099887940745e-195)
(-
x
(+
(*
1.0
(*
(/ (cbrt z) (cbrt t))
(* (/ (cbrt z) (cbrt t)) (* y (/ (cbrt z) (cbrt t))))))
(+ (/ (log 1.0) t) (* 0.5 (* y (/ z (/ t z)))))))
(+
x
(*
(log
(+
1.0
(* y (+ (* 0.16666666666666666 (pow z 3.0)) (+ z (* z (* z 0.5)))))))
(/ -1.0 t))))))double code(double x, double y, double z, double t) {
return ((double) (x - (((double) log(((double) (((double) (1.0 - y)) + ((double) (y * ((double) exp(z)))))))) / t)));
}
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.5821215835774233e+26)) {
tmp = ((double) (x + ((double) (((double) log(((double) (1.0 + ((double) (((double) (y * ((double) exp(z)))) - y)))))) * (-1.0 / t)))));
} else {
double tmp_1;
if ((z <= 5.038099887940745e-195)) {
tmp_1 = ((double) (x - ((double) (((double) (1.0 * ((double) ((((double) cbrt(z)) / ((double) cbrt(t))) * ((double) ((((double) cbrt(z)) / ((double) cbrt(t))) * ((double) (y * (((double) cbrt(z)) / ((double) cbrt(t))))))))))) + ((double) ((((double) log(1.0)) / t) + ((double) (0.5 * ((double) (y * (z / (t / z))))))))))));
} else {
tmp_1 = ((double) (x + ((double) (((double) log(((double) (1.0 + ((double) (y * ((double) (((double) (0.16666666666666666 * ((double) pow(z, 3.0)))) + ((double) (z + ((double) (z * ((double) (z * 0.5)))))))))))))) * (-1.0 / t)))));
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 24.8 |
|---|---|
| Target | 16.0 |
| Herbie | 8.9 |
if z < -1.5821215835774233e26Initial program Error: 12.0 bits
SimplifiedError: 12.0 bits
rmApplied div-invError: 12.0 bits
if -1.5821215835774233e26 < z < 5.0380998879407453e-195Initial program Error: 29.8 bits
SimplifiedError: 14.8 bits
Taylor expanded around 0 Error: 7.0 bits
SimplifiedError: 6.5 bits
rmApplied add-cube-cbrtError: 6.6 bits
Applied add-cube-cbrtError: 6.7 bits
Applied times-fracError: 6.7 bits
Applied associate-*r*Error: 6.3 bits
SimplifiedError: 6.3 bits
rmApplied associate-*r*Error: 6.3 bits
if 5.0380998879407453e-195 < z Initial program Error: 29.2 bits
SimplifiedError: 17.5 bits
rmApplied div-invError: 17.5 bits
Taylor expanded around 0 Error: 11.0 bits
SimplifiedError: 11.0 bits
Final simplificationError: 8.9 bits
herbie shell --seed 2020203
(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)))