Average Error: 14.6 → 3.2
Time: 14.8s
Precision: 64
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.786098057235616148006804323569865742177 \cdot 10^{-62}:\\ \;\;\;\;\frac{\frac{x \cdot \frac{y}{1 + z}}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{1 + z}{y} \cdot z}\\ \end{array}\]
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\begin{array}{l}
\mathbf{if}\;z \le -2.786098057235616148006804323569865742177 \cdot 10^{-62}:\\
\;\;\;\;\frac{\frac{x \cdot \frac{y}{1 + z}}{z}}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r12893795 = x;
        double r12893796 = y;
        double r12893797 = r12893795 * r12893796;
        double r12893798 = z;
        double r12893799 = r12893798 * r12893798;
        double r12893800 = 1.0;
        double r12893801 = r12893798 + r12893800;
        double r12893802 = r12893799 * r12893801;
        double r12893803 = r12893797 / r12893802;
        return r12893803;
}

double f(double x, double y, double z) {
        double r12893804 = z;
        double r12893805 = -2.786098057235616e-62;
        bool r12893806 = r12893804 <= r12893805;
        double r12893807 = x;
        double r12893808 = y;
        double r12893809 = 1.0;
        double r12893810 = r12893809 + r12893804;
        double r12893811 = r12893808 / r12893810;
        double r12893812 = r12893807 * r12893811;
        double r12893813 = r12893812 / r12893804;
        double r12893814 = r12893813 / r12893804;
        double r12893815 = r12893807 / r12893804;
        double r12893816 = r12893810 / r12893808;
        double r12893817 = r12893816 * r12893804;
        double r12893818 = r12893815 / r12893817;
        double r12893819 = r12893806 ? r12893814 : r12893818;
        return r12893819;
}

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.6
Target3.9
Herbie3.2
\[\begin{array}{l} \mathbf{if}\;z \lt 249.6182814532307077115547144785523414612:\\ \;\;\;\;\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 < -2.786098057235616e-62

    1. Initial program 9.5

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

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

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

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

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

      \[\leadsto \frac{1}{z} \cdot \color{blue}{\frac{x \cdot \frac{y}{z + 1}}{z}}\]
    10. Applied associate-*r/2.3

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

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

    if -2.786098057235616e-62 < z

    1. Initial program 17.9

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{z} \cdot \left(\frac{x}{z} \cdot \frac{y}{z + 1}\right)}\]
    8. Using strategy rm
    9. Applied clear-num3.3

      \[\leadsto \frac{1}{z} \cdot \left(\frac{x}{z} \cdot \color{blue}{\frac{1}{\frac{z + 1}{y}}}\right)\]
    10. Using strategy rm
    11. Applied un-div-inv3.3

      \[\leadsto \frac{1}{z} \cdot \color{blue}{\frac{\frac{x}{z}}{\frac{z + 1}{y}}}\]
    12. Applied frac-times3.9

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{x}{z}}{z \cdot \frac{z + 1}{y}}}\]
    13. Simplified3.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.786098057235616148006804323569865742177 \cdot 10^{-62}:\\ \;\;\;\;\frac{\frac{x \cdot \frac{y}{1 + z}}{z}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{1 + z}{y} \cdot z}\\ \end{array}\]

Reproduce

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

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