Average Error: 15.3 → 4.2
Time: 5.1s
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 2.4348500591964066 \cdot 10^{+210}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{x}{\mathsf{fma}\left(z, z, z\right)}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_0 := \mathsf{hypot}\left(z, \sqrt{z}\right)\\ \frac{1}{t_0} \cdot \left(\frac{y}{t_0} \cdot \frac{x}{z}\right) \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 2.4348500591964066 \cdot 10^{+210}:\\
\;\;\;\;\frac{y}{z} \cdot \frac{x}{\mathsf{fma}\left(z, z, z\right)}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_0 := \mathsf{hypot}\left(z, \sqrt{z}\right)\\
\frac{1}{t_0} \cdot \left(\frac{y}{t_0} \cdot \frac{x}{z}\right)
\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)) 2.4348500591964066e+210)
   (* (/ y z) (/ x (fma z z z)))
   (let* ((t_0 (hypot z (sqrt z)))) (* (/ 1.0 t_0) (* (/ y t_0) (/ x 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)) <= 2.4348500591964066e+210) {
		tmp = (y / z) * (x / fma(z, z, z));
	} else {
		double t_0 = hypot(z, sqrt(z));
		tmp = (1.0 / t_0) * ((y / t_0) * (x / z));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original15.3
Target4.3
Herbie4.2
\[\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)) < 2.43485005919640658e210

    1. Initial program 16.2

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \frac{y}{\mathsf{fma}\left(z, z, z\right)}}{z}} \]
    4. Applied associate-/l*_binary649.6

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{\frac{y}{\mathsf{fma}\left(z, z, z\right)}}}} \]
    5. Applied associate-/r/_binary649.6

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

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

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

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

    if 2.43485005919640658e210 < (*.f64 (*.f64 z z) (+.f64 z 1))

    1. Initial program 12.8

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \frac{y}{\mathsf{fma}\left(z, z, z\right)}}{z}} \]
    4. Applied associate-/l*_binary646.1

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{\frac{y}{\mathsf{fma}\left(z, z, z\right)}}}} \]
    5. Applied add-sqr-sqrt_binary646.1

      \[\leadsto \frac{x}{\frac{z}{\frac{y}{\color{blue}{\sqrt{\mathsf{fma}\left(z, z, z\right)} \cdot \sqrt{\mathsf{fma}\left(z, z, z\right)}}}}} \]
    6. Applied *-un-lft-identity_binary646.1

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

      \[\leadsto \frac{x}{\frac{z}{\color{blue}{\frac{1}{\sqrt{\mathsf{fma}\left(z, z, z\right)}} \cdot \frac{y}{\sqrt{\mathsf{fma}\left(z, z, z\right)}}}}} \]
    8. Applied *-un-lft-identity_binary646.1

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

      \[\leadsto \frac{x}{\color{blue}{\frac{1}{\frac{1}{\sqrt{\mathsf{fma}\left(z, z, z\right)}}} \cdot \frac{z}{\frac{y}{\sqrt{\mathsf{fma}\left(z, z, z\right)}}}}} \]
    10. Applied *-un-lft-identity_binary646.1

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\frac{1}{\frac{1}{\sqrt{\mathsf{fma}\left(z, z, z\right)}}} \cdot \frac{z}{\frac{y}{\sqrt{\mathsf{fma}\left(z, z, z\right)}}}} \]
    11. Applied times-frac_binary645.0

      \[\leadsto \color{blue}{\frac{1}{\frac{1}{\frac{1}{\sqrt{\mathsf{fma}\left(z, z, z\right)}}}} \cdot \frac{x}{\frac{z}{\frac{y}{\sqrt{\mathsf{fma}\left(z, z, z\right)}}}}} \]
    12. Simplified5.0

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

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

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

Reproduce

herbie shell --seed 2022088 
(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))))