Average Error: 14.7 → 2.1
Time: 16.2s
Precision: 64
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.142238490832584807593469027145105728374 \cdot 10^{-241}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\frac{x}{z} \cdot \frac{y}{1 + z}\right)\\ \mathbf{elif}\;y \le 9.3471931618167447031787123871737508146 \cdot 10^{-180}:\\ \;\;\;\;\frac{\frac{\frac{y}{1 + z}}{z}}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\frac{x}{z} \cdot \frac{y}{1 + z}\right)\\ \end{array}\]
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\begin{array}{l}
\mathbf{if}\;y \le -1.142238490832584807593469027145105728374 \cdot 10^{-241}:\\
\;\;\;\;\frac{1}{z} \cdot \left(\frac{x}{z} \cdot \frac{y}{1 + z}\right)\\

\mathbf{elif}\;y \le 9.3471931618167447031787123871737508146 \cdot 10^{-180}:\\
\;\;\;\;\frac{\frac{\frac{y}{1 + z}}{z}}{z} \cdot x\\

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

\end{array}
double f(double x, double y, double z) {
        double r14749992 = x;
        double r14749993 = y;
        double r14749994 = r14749992 * r14749993;
        double r14749995 = z;
        double r14749996 = r14749995 * r14749995;
        double r14749997 = 1.0;
        double r14749998 = r14749995 + r14749997;
        double r14749999 = r14749996 * r14749998;
        double r14750000 = r14749994 / r14749999;
        return r14750000;
}

double f(double x, double y, double z) {
        double r14750001 = y;
        double r14750002 = -1.1422384908325848e-241;
        bool r14750003 = r14750001 <= r14750002;
        double r14750004 = 1.0;
        double r14750005 = z;
        double r14750006 = r14750004 / r14750005;
        double r14750007 = x;
        double r14750008 = r14750007 / r14750005;
        double r14750009 = 1.0;
        double r14750010 = r14750009 + r14750005;
        double r14750011 = r14750001 / r14750010;
        double r14750012 = r14750008 * r14750011;
        double r14750013 = r14750006 * r14750012;
        double r14750014 = 9.347193161816745e-180;
        bool r14750015 = r14750001 <= r14750014;
        double r14750016 = r14750011 / r14750005;
        double r14750017 = r14750016 / r14750005;
        double r14750018 = r14750017 * r14750007;
        double r14750019 = r14750015 ? r14750018 : r14750013;
        double r14750020 = r14750003 ? r14750013 : r14750019;
        return r14750020;
}

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.7
Target4.2
Herbie2.1
\[\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 y < -1.1422384908325848e-241 or 9.347193161816745e-180 < y

    1. Initial program 14.4

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

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

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

      \[\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)}\]

    if -1.1422384908325848e-241 < y < 9.347193161816745e-180

    1. Initial program 15.7

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

      \[\leadsto \color{blue}{\frac{x}{z \cdot z} \cdot \frac{y}{z + 1}}\]
    4. Using strategy rm
    5. Applied div-inv17.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.142238490832584807593469027145105728374 \cdot 10^{-241}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\frac{x}{z} \cdot \frac{y}{1 + z}\right)\\ \mathbf{elif}\;y \le 9.3471931618167447031787123871737508146 \cdot 10^{-180}:\\ \;\;\;\;\frac{\frac{\frac{y}{1 + z}}{z}}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\frac{x}{z} \cdot \frac{y}{1 + z}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019169 +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))))