Average Error: 14.9 → 2.9
Time: 3.1s
Precision: 64
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\]
\[\begin{array}{l} \mathbf{if}\;z \le 9.9114704058449326 \cdot 10^{-126}:\\ \;\;\;\;1 \cdot \frac{\frac{x}{z} \cdot \frac{1}{\frac{z + 1}{y}}}{z}\\ \mathbf{elif}\;z \le 4.04384918477349025 \cdot 10^{68}:\\ \;\;\;\;1 \cdot \frac{x \cdot y}{z \cdot \left(z \cdot \left(z + 1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{\left(\frac{x}{z} \cdot y\right) \cdot \frac{1}{z + 1}}{z}\\ \end{array}\]
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\begin{array}{l}
\mathbf{if}\;z \le 9.9114704058449326 \cdot 10^{-126}:\\
\;\;\;\;1 \cdot \frac{\frac{x}{z} \cdot \frac{1}{\frac{z + 1}{y}}}{z}\\

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

\mathbf{else}:\\
\;\;\;\;1 \cdot \frac{\left(\frac{x}{z} \cdot y\right) \cdot \frac{1}{z + 1}}{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 ((z <= 9.911470405844933e-126)) {
		temp = (1.0 * (((x / z) * (1.0 / ((z + 1.0) / y))) / z));
	} else {
		double temp_1;
		if ((z <= 4.0438491847734902e+68)) {
			temp_1 = (1.0 * ((x * y) / (z * (z * (z + 1.0)))));
		} else {
			temp_1 = (1.0 * ((((x / z) * y) * (1.0 / (z + 1.0))) / z));
		}
		temp = temp_1;
	}
	return temp;
}

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.9
Target4.2
Herbie2.9
\[\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 z < 9.911470405844933e-126

    1. Initial program 19.4

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\]
    2. Using strategy rm
    3. Applied times-frac16.0

      \[\leadsto \color{blue}{\frac{x}{z \cdot z} \cdot \frac{y}{z + 1}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity16.0

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{z \cdot z} \cdot \frac{y}{z + 1}\]
    6. Applied times-frac8.0

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

      \[\leadsto \color{blue}{\frac{1}{z} \cdot \left(\frac{x}{z} \cdot \frac{y}{z + 1}\right)}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity3.2

      \[\leadsto \frac{1}{\color{blue}{1 \cdot z}} \cdot \left(\frac{x}{z} \cdot \frac{y}{z + 1}\right)\]
    10. Applied *-un-lft-identity3.2

      \[\leadsto \frac{\color{blue}{1 \cdot 1}}{1 \cdot z} \cdot \left(\frac{x}{z} \cdot \frac{y}{z + 1}\right)\]
    11. Applied times-frac3.2

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

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

      \[\leadsto \frac{1}{1} \cdot \color{blue}{\frac{\frac{x}{z} \cdot \frac{y}{z + 1}}{z}}\]
    14. Using strategy rm
    15. Applied clear-num3.2

      \[\leadsto \frac{1}{1} \cdot \frac{\frac{x}{z} \cdot \color{blue}{\frac{1}{\frac{z + 1}{y}}}}{z}\]

    if 9.911470405844933e-126 < z < 4.0438491847734902e+68

    1. Initial program 4.5

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\]
    2. Using strategy rm
    3. Applied times-frac4.8

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

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{z \cdot z} \cdot \frac{y}{z + 1}\]
    6. Applied times-frac4.9

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

      \[\leadsto \color{blue}{\frac{1}{z} \cdot \left(\frac{x}{z} \cdot \frac{y}{z + 1}\right)}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity4.4

      \[\leadsto \frac{1}{\color{blue}{1 \cdot z}} \cdot \left(\frac{x}{z} \cdot \frac{y}{z + 1}\right)\]
    10. Applied *-un-lft-identity4.4

      \[\leadsto \frac{\color{blue}{1 \cdot 1}}{1 \cdot z} \cdot \left(\frac{x}{z} \cdot \frac{y}{z + 1}\right)\]
    11. Applied times-frac4.4

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

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

      \[\leadsto \frac{1}{1} \cdot \color{blue}{\frac{\frac{x}{z} \cdot \frac{y}{z + 1}}{z}}\]
    14. Using strategy rm
    15. Applied frac-times4.5

      \[\leadsto \frac{1}{1} \cdot \frac{\color{blue}{\frac{x \cdot y}{z \cdot \left(z + 1\right)}}}{z}\]
    16. Applied associate-/l/4.5

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

    if 4.0438491847734902e+68 < z

    1. Initial program 12.1

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\]
    2. Using strategy rm
    3. Applied times-frac4.9

      \[\leadsto \color{blue}{\frac{x}{z \cdot z} \cdot \frac{y}{z + 1}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity4.9

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{z \cdot z} \cdot \frac{y}{z + 1}\]
    6. Applied times-frac1.9

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

      \[\leadsto \color{blue}{\frac{1}{z} \cdot \left(\frac{x}{z} \cdot \frac{y}{z + 1}\right)}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity0.7

      \[\leadsto \frac{1}{\color{blue}{1 \cdot z}} \cdot \left(\frac{x}{z} \cdot \frac{y}{z + 1}\right)\]
    10. Applied *-un-lft-identity0.7

      \[\leadsto \frac{\color{blue}{1 \cdot 1}}{1 \cdot z} \cdot \left(\frac{x}{z} \cdot \frac{y}{z + 1}\right)\]
    11. Applied times-frac0.7

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

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

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

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

      \[\leadsto \frac{1}{1} \cdot \frac{\color{blue}{\left(\frac{x}{z} \cdot y\right) \cdot \frac{1}{z + 1}}}{z}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.9

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

Reproduce

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