Average Error: 14.5 → 2.7
Time: 14.4s
Precision: 64
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1.0\right)}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -1.2737733862924213 \cdot 10^{+20}:\\ \;\;\;\;\frac{\frac{x}{z}}{z} \cdot \frac{y}{z + 1.0}\\ \mathbf{elif}\;x \cdot y \le 5.40479925065171 \cdot 10^{-82}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot y}{\left(z + 1.0\right) \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{y}{z + 1.0}}{z} \cdot \frac{1}{z}\\ \end{array}\]
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1.0\right)}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le -1.2737733862924213 \cdot 10^{+20}:\\
\;\;\;\;\frac{\frac{x}{z}}{z} \cdot \frac{y}{z + 1.0}\\

\mathbf{elif}\;x \cdot y \le 5.40479925065171 \cdot 10^{-82}:\\
\;\;\;\;\frac{\frac{x}{z} \cdot y}{\left(z + 1.0\right) \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{y}{z + 1.0}}{z} \cdot \frac{1}{z}\\

\end{array}
double f(double x, double y, double z) {
        double r17771095 = x;
        double r17771096 = y;
        double r17771097 = r17771095 * r17771096;
        double r17771098 = z;
        double r17771099 = r17771098 * r17771098;
        double r17771100 = 1.0;
        double r17771101 = r17771098 + r17771100;
        double r17771102 = r17771099 * r17771101;
        double r17771103 = r17771097 / r17771102;
        return r17771103;
}

double f(double x, double y, double z) {
        double r17771104 = x;
        double r17771105 = y;
        double r17771106 = r17771104 * r17771105;
        double r17771107 = -1.2737733862924213e+20;
        bool r17771108 = r17771106 <= r17771107;
        double r17771109 = z;
        double r17771110 = r17771104 / r17771109;
        double r17771111 = r17771110 / r17771109;
        double r17771112 = 1.0;
        double r17771113 = r17771109 + r17771112;
        double r17771114 = r17771105 / r17771113;
        double r17771115 = r17771111 * r17771114;
        double r17771116 = 5.40479925065171e-82;
        bool r17771117 = r17771106 <= r17771116;
        double r17771118 = r17771110 * r17771105;
        double r17771119 = r17771113 * r17771109;
        double r17771120 = r17771118 / r17771119;
        double r17771121 = r17771104 * r17771114;
        double r17771122 = r17771121 / r17771109;
        double r17771123 = 1.0;
        double r17771124 = r17771123 / r17771109;
        double r17771125 = r17771122 * r17771124;
        double r17771126 = r17771117 ? r17771120 : r17771125;
        double r17771127 = r17771108 ? r17771115 : r17771126;
        return r17771127;
}

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.5
Target4.0
Herbie2.7
\[\begin{array}{l} \mathbf{if}\;z \lt 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 3 regimes
  2. if (* x y) < -1.2737733862924213e+20

    1. Initial program 19.7

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

      \[\leadsto \color{blue}{\frac{x}{z \cdot z} \cdot \frac{y}{z + 1.0}}\]
    4. Using strategy rm
    5. Applied associate-/r*3.8

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

    if -1.2737733862924213e+20 < (* x y) < 5.40479925065171e-82

    1. Initial program 12.9

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{z} \cdot \left(\frac{x}{z} \cdot \frac{y}{z + 1.0}\right)}\]
    8. Using strategy rm
    9. Applied associate-*r/2.2

      \[\leadsto \frac{1}{z} \cdot \color{blue}{\frac{\frac{x}{z} \cdot y}{z + 1.0}}\]
    10. Applied frac-times2.2

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

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

    if 5.40479925065171e-82 < (* x y)

    1. Initial program 14.0

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{z} \cdot \left(\frac{x}{z} \cdot \frac{y}{z + 1.0}\right)}\]
    8. Using strategy rm
    9. Applied associate-*l/3.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -1.2737733862924213 \cdot 10^{+20}:\\ \;\;\;\;\frac{\frac{x}{z}}{z} \cdot \frac{y}{z + 1.0}\\ \mathbf{elif}\;x \cdot y \le 5.40479925065171 \cdot 10^{-82}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot y}{\left(z + 1.0\right) \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{y}{z + 1.0}}{z} \cdot \frac{1}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019163 
(FPCore (x y z)
  :name "Statistics.Distribution.Beta:$cvariance from math-functions-0.1.5.2"

  :herbie-target
  (if (< z 249.6182814532307) (/ (* y (/ x z)) (+ z (* z z))) (/ (* (/ (/ y z) (+ 1 z)) x) z))

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