Average Error: 13.9 → 3.3
Time: 8.5s
Precision: 64
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1.0\right)}\]
\[\begin{array}{l} \mathbf{if}\;z \le 4.913726010820968 \cdot 10^{-185}:\\ \;\;\;\;\left(x \cdot \left(\frac{1}{z} \cdot \frac{y}{z + 1.0}\right)\right) \cdot \frac{1}{z}\\ \mathbf{elif}\;z \le 1.0537074098609829 \cdot 10^{+80}:\\ \;\;\;\;\frac{y}{z + 1.0} \cdot \frac{\frac{x}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\frac{y}{z + 1.0} \cdot \frac{x}{z}\right)\\ \end{array}\]
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1.0\right)}
\begin{array}{l}
\mathbf{if}\;z \le 4.913726010820968 \cdot 10^{-185}:\\
\;\;\;\;\left(x \cdot \left(\frac{1}{z} \cdot \frac{y}{z + 1.0}\right)\right) \cdot \frac{1}{z}\\

\mathbf{elif}\;z \le 1.0537074098609829 \cdot 10^{+80}:\\
\;\;\;\;\frac{y}{z + 1.0} \cdot \frac{\frac{x}{z}}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r5386773 = x;
        double r5386774 = y;
        double r5386775 = r5386773 * r5386774;
        double r5386776 = z;
        double r5386777 = r5386776 * r5386776;
        double r5386778 = 1.0;
        double r5386779 = r5386776 + r5386778;
        double r5386780 = r5386777 * r5386779;
        double r5386781 = r5386775 / r5386780;
        return r5386781;
}

double f(double x, double y, double z) {
        double r5386782 = z;
        double r5386783 = 4.913726010820968e-185;
        bool r5386784 = r5386782 <= r5386783;
        double r5386785 = x;
        double r5386786 = 1.0;
        double r5386787 = r5386786 / r5386782;
        double r5386788 = y;
        double r5386789 = 1.0;
        double r5386790 = r5386782 + r5386789;
        double r5386791 = r5386788 / r5386790;
        double r5386792 = r5386787 * r5386791;
        double r5386793 = r5386785 * r5386792;
        double r5386794 = r5386793 * r5386787;
        double r5386795 = 1.0537074098609829e+80;
        bool r5386796 = r5386782 <= r5386795;
        double r5386797 = r5386785 / r5386782;
        double r5386798 = r5386797 / r5386782;
        double r5386799 = r5386791 * r5386798;
        double r5386800 = r5386791 * r5386797;
        double r5386801 = r5386787 * r5386800;
        double r5386802 = r5386796 ? r5386799 : r5386801;
        double r5386803 = r5386784 ? r5386794 : r5386802;
        return r5386803;
}

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

Original13.9
Target3.9
Herbie3.3
\[\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 z < 4.913726010820968e-185

    1. Initial program 17.1

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

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

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

      \[\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 div-inv2.6

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

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

    if 4.913726010820968e-185 < z < 1.0537074098609829e+80

    1. Initial program 9.3

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

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

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

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

      \[\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*7.1

      \[\leadsto \color{blue}{\left(\frac{1}{z} \cdot \frac{x}{z}\right) \cdot \frac{y}{z + 1.0}}\]
    10. Simplified7.0

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

    if 1.0537074098609829e+80 < z

    1. Initial program 11.1

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

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019156 +o rules:numerics
(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))))