\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\begin{array}{l}
\mathbf{if}\;x \cdot y \le 0.0:\\
\;\;\;\;\frac{\frac{x}{z}}{z} \cdot \frac{y}{z + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x \cdot \frac{y}{z + 1}}{z}}{z}\\
\end{array}double code(double x, double y, double z) {
return ((x * y) / ((z * z) * (z + 1.0)));
}
double code(double x, double y, double z) {
double temp;
if (((x * y) <= 0.0)) {
temp = (((x / z) / z) * (y / (z + 1.0)));
} else {
temp = (((x * (y / (z + 1.0))) / z) / z);
}
return temp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 15.0 |
|---|---|
| Target | 4.2 |
| Herbie | 4.4 |
if (* x y) < 0.0Initial program 16.3
rmApplied times-frac12.2
rmApplied associate-/r*6.1
if 0.0 < (* x y) Initial program 13.4
rmApplied times-frac10.9
rmApplied add-cube-cbrt11.4
Applied times-frac7.1
Applied associate-*l*1.4
rmApplied associate-*l/1.4
Applied associate-*r/1.6
Simplified2.1
Final simplification4.4
herbie shell --seed 2020066 +o rules:numerics
(FPCore (x y z)
:name "Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< z 249.6182814532307) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1 z)) x) z))
(/ (* x y) (* (* z z) (+ z 1))))