Average Error: 14.6 → 2.6
Time: 2.4s
Precision: 64
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -138596582542956773000:\\ \;\;\;\;\frac{\left(x \cdot \frac{y}{z}\right) \cdot \frac{1}{z}}{z + 1}\\ \mathbf{elif}\;x \cdot y \le 9.5201024367058361 \cdot 10^{151}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot y}{\left(z + 1\right) \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{z + 1}{\frac{y}{z}}}\\ \end{array}\]
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le -138596582542956773000:\\
\;\;\;\;\frac{\left(x \cdot \frac{y}{z}\right) \cdot \frac{1}{z}}{z + 1}\\

\mathbf{elif}\;x \cdot y \le 9.5201024367058361 \cdot 10^{151}:\\
\;\;\;\;\frac{\frac{x}{z} \cdot y}{\left(z + 1\right) \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{z + 1}{\frac{y}{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 VAR;
	if (((x * y) <= -1.3859658254295677e+20)) {
		VAR = (((x * (y / z)) * (1.0 / z)) / (z + 1.0));
	} else {
		double VAR_1;
		if (((x * y) <= 9.520102436705836e+151)) {
			VAR_1 = (((x / z) * y) / ((z + 1.0) * z));
		} else {
			VAR_1 = ((x / z) / ((z + 1.0) / (y / z)));
		}
		VAR = VAR_1;
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.6
Target4.0
Herbie2.6
\[\begin{array}{l} \mathbf{if}\;z \lt 249.618281453230708:\\ \;\;\;\;\frac{y \cdot \frac{x}{z}}{z + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{y}{z}}{1 + z} \cdot x}{z}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (* x y) < -1.3859658254295677e+20

    1. Initial program 18.0

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\]
    2. Using strategy rm
    3. Applied associate-/r*13.2

      \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{z \cdot z}}{z + 1}}\]
    4. Using strategy rm
    5. Applied times-frac3.1

      \[\leadsto \frac{\color{blue}{\frac{x}{z} \cdot \frac{y}{z}}}{z + 1}\]
    6. Using strategy rm
    7. Applied div-inv3.1

      \[\leadsto \frac{\frac{x}{z} \cdot \color{blue}{\left(y \cdot \frac{1}{z}\right)}}{z + 1}\]
    8. Applied associate-*r*4.1

      \[\leadsto \frac{\color{blue}{\left(\frac{x}{z} \cdot y\right) \cdot \frac{1}{z}}}{z + 1}\]
    9. Simplified4.2

      \[\leadsto \frac{\color{blue}{\left(x \cdot \frac{y}{z}\right)} \cdot \frac{1}{z}}{z + 1}\]

    if -1.3859658254295677e+20 < (* x y) < 9.520102436705836e+151

    1. Initial program 11.2

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\]
    2. Using strategy rm
    3. Applied associate-/r*10.6

      \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{z \cdot z}}{z + 1}}\]
    4. Using strategy rm
    5. Applied times-frac2.8

      \[\leadsto \frac{\color{blue}{\frac{x}{z} \cdot \frac{y}{z}}}{z + 1}\]
    6. Using strategy rm
    7. Applied associate-*r/2.2

      \[\leadsto \frac{\color{blue}{\frac{\frac{x}{z} \cdot y}{z}}}{z + 1}\]
    8. Applied associate-/l/2.2

      \[\leadsto \color{blue}{\frac{\frac{x}{z} \cdot y}{\left(z + 1\right) \cdot z}}\]

    if 9.520102436705836e+151 < (* x y)

    1. Initial program 33.1

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\]
    2. Using strategy rm
    3. Applied associate-/r*27.1

      \[\leadsto \color{blue}{\frac{\frac{x \cdot y}{z \cdot z}}{z + 1}}\]
    4. Using strategy rm
    5. Applied times-frac2.2

      \[\leadsto \frac{\color{blue}{\frac{x}{z} \cdot \frac{y}{z}}}{z + 1}\]
    6. Applied associate-/l*2.6

      \[\leadsto \color{blue}{\frac{\frac{x}{z}}{\frac{z + 1}{\frac{y}{z}}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -138596582542956773000:\\ \;\;\;\;\frac{\left(x \cdot \frac{y}{z}\right) \cdot \frac{1}{z}}{z + 1}\\ \mathbf{elif}\;x \cdot y \le 9.5201024367058361 \cdot 10^{151}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot y}{\left(z + 1\right) \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{z + 1}{\frac{y}{z}}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020092 +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))))