Average Error: 14.9 → 2.8
Time: 3.0s
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} \lor \neg \left(z \le 2.7466160741339841 \cdot 10^{68}\right):\\ \;\;\;\;\frac{\sqrt{1}}{1} \cdot \frac{\frac{x}{z} \cdot \frac{1}{\frac{z + 1}{y}}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z \cdot \left(z \cdot \left(z + 1\right)\right)}\\ \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} \lor \neg \left(z \le 2.7466160741339841 \cdot 10^{68}\right):\\
\;\;\;\;\frac{\sqrt{1}}{1} \cdot \frac{\frac{x}{z} \cdot \frac{1}{\frac{z + 1}{y}}}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z \cdot \left(z \cdot \left(z + 1\right)\right)}\\

\end{array}
double f(double x, double y, double z) {
        double r326853 = x;
        double r326854 = y;
        double r326855 = r326853 * r326854;
        double r326856 = z;
        double r326857 = r326856 * r326856;
        double r326858 = 1.0;
        double r326859 = r326856 + r326858;
        double r326860 = r326857 * r326859;
        double r326861 = r326855 / r326860;
        return r326861;
}

double f(double x, double y, double z) {
        double r326862 = z;
        double r326863 = 9.911470405844933e-126;
        bool r326864 = r326862 <= r326863;
        double r326865 = 2.746616074133984e+68;
        bool r326866 = r326862 <= r326865;
        double r326867 = !r326866;
        bool r326868 = r326864 || r326867;
        double r326869 = 1.0;
        double r326870 = sqrt(r326869);
        double r326871 = r326870 / r326869;
        double r326872 = x;
        double r326873 = r326872 / r326862;
        double r326874 = 1.0;
        double r326875 = r326862 + r326874;
        double r326876 = y;
        double r326877 = r326875 / r326876;
        double r326878 = r326869 / r326877;
        double r326879 = r326873 * r326878;
        double r326880 = r326879 / r326862;
        double r326881 = r326871 * r326880;
        double r326882 = r326872 * r326876;
        double r326883 = r326862 * r326875;
        double r326884 = r326862 * r326883;
        double r326885 = r326882 / r326884;
        double r326886 = r326868 ? r326881 : r326885;
        return r326886;
}

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.8
\[\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 2 regimes
  2. if z < 9.911470405844933e-126 or 2.746616074133984e+68 < z

    1. Initial program 17.0

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

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

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

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

      \[\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-identity2.3

      \[\leadsto \frac{1}{\color{blue}{1 \cdot z}} \cdot \left(\frac{x}{z} \cdot \frac{y}{z + 1}\right)\]
    10. Applied add-sqr-sqrt2.3

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

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

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

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

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

    if 9.911470405844933e-126 < z < 2.746616074133984e+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 frac-times4.6

      \[\leadsto \frac{1}{z} \cdot \color{blue}{\frac{x \cdot y}{z \cdot \left(z + 1\right)}}\]
    10. Applied frac-times4.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le 9.9114704058449326 \cdot 10^{-126} \lor \neg \left(z \le 2.7466160741339841 \cdot 10^{68}\right):\\ \;\;\;\;\frac{\sqrt{1}}{1} \cdot \frac{\frac{x}{z} \cdot \frac{1}{\frac{z + 1}{y}}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z \cdot \left(z \cdot \left(z + 1\right)\right)}\\ \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))))