Average Error: 14.6 → 3.1
Time: 7.0s
Precision: binary64
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
\[\begin{array}{l} \mathbf{if}\;\left(z \cdot z\right) \cdot \left(z + 1\right) \leq 4.926228586799335 \cdot 10^{+297}:\\ \;\;\;\;\begin{array}{l} t_0 := \sqrt[3]{\mathsf{fma}\left(z, z, z\right)}\\ \left(x \cdot \frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{t_0 \cdot t_0}\right) \cdot \frac{\frac{\sqrt[3]{y}}{t_0}}{z} \end{array}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_1 := \mathsf{hypot}\left(z, \sqrt{z}\right)\\ \frac{\frac{y}{t_1} \cdot \frac{x}{t_1}}{z} \end{array}\\ \end{array} \]
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\begin{array}{l}
\mathbf{if}\;\left(z \cdot z\right) \cdot \left(z + 1\right) \leq 4.926228586799335 \cdot 10^{+297}:\\
\;\;\;\;\begin{array}{l}
t_0 := \sqrt[3]{\mathsf{fma}\left(z, z, z\right)}\\
\left(x \cdot \frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{t_0 \cdot t_0}\right) \cdot \frac{\frac{\sqrt[3]{y}}{t_0}}{z}
\end{array}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := \mathsf{hypot}\left(z, \sqrt{z}\right)\\
\frac{\frac{y}{t_1} \cdot \frac{x}{t_1}}{z}
\end{array}\\


\end{array}
(FPCore (x y z) :precision binary64 (/ (* x y) (* (* z z) (+ z 1.0))))
(FPCore (x y z)
 :precision binary64
 (if (<= (* (* z z) (+ z 1.0)) 4.926228586799335e+297)
   (let* ((t_0 (cbrt (fma z z z))))
     (* (* x (/ (* (cbrt y) (cbrt y)) (* t_0 t_0))) (/ (/ (cbrt y) t_0) z)))
   (let* ((t_1 (hypot z (sqrt z)))) (/ (* (/ y t_1) (/ x t_1)) z))))
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 tmp;
	if (((z * z) * (z + 1.0)) <= 4.926228586799335e+297) {
		double t_0_1 = cbrt(fma(z, z, z));
		tmp = (x * ((cbrt(y) * cbrt(y)) / (t_0_1 * t_0_1))) * ((cbrt(y) / t_0_1) / z);
	} else {
		double t_1 = hypot(z, sqrt(z));
		tmp = ((y / t_1) * (x / t_1)) / z;
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original14.6
Target4.2
Herbie3.1
\[\begin{array}{l} \mathbf{if}\;z < 249.6182814532307:\\ \;\;\;\;\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 2 regimes
  2. if (*.f64 (*.f64 z z) (+.f64 z 1)) < 4.92622858679933495e297

    1. Initial program 15.0

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Simplified8.9

      \[\leadsto \color{blue}{x \cdot \frac{\frac{y}{\mathsf{fma}\left(z, z, z\right)}}{z}} \]
    3. Applied *-un-lft-identity_binary648.9

      \[\leadsto x \cdot \frac{\frac{y}{\mathsf{fma}\left(z, z, z\right)}}{\color{blue}{1 \cdot z}} \]
    4. Applied add-cube-cbrt_binary649.4

      \[\leadsto x \cdot \frac{\frac{y}{\color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(z, z, z\right)} \cdot \sqrt[3]{\mathsf{fma}\left(z, z, z\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(z, z, z\right)}}}}{1 \cdot z} \]
    5. Applied add-cube-cbrt_binary649.5

      \[\leadsto x \cdot \frac{\frac{\color{blue}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}}}{\left(\sqrt[3]{\mathsf{fma}\left(z, z, z\right)} \cdot \sqrt[3]{\mathsf{fma}\left(z, z, z\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(z, z, z\right)}}}{1 \cdot z} \]
    6. Applied times-frac_binary649.5

      \[\leadsto x \cdot \frac{\color{blue}{\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{\mathsf{fma}\left(z, z, z\right)} \cdot \sqrt[3]{\mathsf{fma}\left(z, z, z\right)}} \cdot \frac{\sqrt[3]{y}}{\sqrt[3]{\mathsf{fma}\left(z, z, z\right)}}}}{1 \cdot z} \]
    7. Applied times-frac_binary649.5

      \[\leadsto x \cdot \color{blue}{\left(\frac{\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{\mathsf{fma}\left(z, z, z\right)} \cdot \sqrt[3]{\mathsf{fma}\left(z, z, z\right)}}}{1} \cdot \frac{\frac{\sqrt[3]{y}}{\sqrt[3]{\mathsf{fma}\left(z, z, z\right)}}}{z}\right)} \]
    8. Applied associate-*r*_binary643.9

      \[\leadsto \color{blue}{\left(x \cdot \frac{\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{\mathsf{fma}\left(z, z, z\right)} \cdot \sqrt[3]{\mathsf{fma}\left(z, z, z\right)}}}{1}\right) \cdot \frac{\frac{\sqrt[3]{y}}{\sqrt[3]{\mathsf{fma}\left(z, z, z\right)}}}{z}} \]
    9. Simplified3.9

      \[\leadsto \color{blue}{\left(x \cdot \frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{\mathsf{fma}\left(z, z, z\right)} \cdot \sqrt[3]{\mathsf{fma}\left(z, z, z\right)}}\right)} \cdot \frac{\frac{\sqrt[3]{y}}{\sqrt[3]{\mathsf{fma}\left(z, z, z\right)}}}{z} \]

    if 4.92622858679933495e297 < (*.f64 (*.f64 z z) (+.f64 z 1))

    1. Initial program 13.3

      \[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)} \]
    2. Simplified5.8

      \[\leadsto \color{blue}{x \cdot \frac{\frac{y}{\mathsf{fma}\left(z, z, z\right)}}{z}} \]
    3. Applied associate-*r/_binary645.0

      \[\leadsto \color{blue}{\frac{x \cdot \frac{y}{\mathsf{fma}\left(z, z, z\right)}}{z}} \]
    4. Taylor expanded in x around 0 9.8

      \[\leadsto \frac{\color{blue}{\frac{y \cdot x}{{z}^{2} + z}}}{z} \]
    5. Simplified9.8

      \[\leadsto \frac{\color{blue}{\frac{y \cdot x}{\mathsf{fma}\left(z, z, z\right)}}}{z} \]
    6. Applied add-sqr-sqrt_binary649.8

      \[\leadsto \frac{\frac{y \cdot x}{\color{blue}{\sqrt{\mathsf{fma}\left(z, z, z\right)} \cdot \sqrt{\mathsf{fma}\left(z, z, z\right)}}}}{z} \]
    7. Applied times-frac_binary644.5

      \[\leadsto \frac{\color{blue}{\frac{y}{\sqrt{\mathsf{fma}\left(z, z, z\right)}} \cdot \frac{x}{\sqrt{\mathsf{fma}\left(z, z, z\right)}}}}{z} \]
    8. Simplified4.5

      \[\leadsto \frac{\color{blue}{\frac{y}{\mathsf{hypot}\left(z, \sqrt{z}\right)}} \cdot \frac{x}{\sqrt{\mathsf{fma}\left(z, z, z\right)}}}{z} \]
    9. Simplified0.3

      \[\leadsto \frac{\frac{y}{\mathsf{hypot}\left(z, \sqrt{z}\right)} \cdot \color{blue}{\frac{x}{\mathsf{hypot}\left(z, \sqrt{z}\right)}}}{z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(z \cdot z\right) \cdot \left(z + 1\right) \leq 4.926228586799335 \cdot 10^{+297}:\\ \;\;\;\;\left(x \cdot \frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{\mathsf{fma}\left(z, z, z\right)} \cdot \sqrt[3]{\mathsf{fma}\left(z, z, z\right)}}\right) \cdot \frac{\frac{\sqrt[3]{y}}{\sqrt[3]{\mathsf{fma}\left(z, z, z\right)}}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{\mathsf{hypot}\left(z, \sqrt{z}\right)} \cdot \frac{x}{\mathsf{hypot}\left(z, \sqrt{z}\right)}}{z}\\ \end{array} \]

Reproduce

herbie shell --seed 2022077 
(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.0 z)) x) z))

  (/ (* x y) (* (* z z) (+ z 1.0))))