Average Error: 14.5 → 1.9
Time: 16.2s
Precision: 64
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1.0\right)}\]
\[\begin{array}{l} \mathbf{if}\;x \le 1.4340218294944 \cdot 10^{-310}:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot \left(\frac{y}{1.0 + z} \cdot \frac{1}{z}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\sqrt{x}}{z} \cdot \frac{y}{1.0 + z}\right) \cdot \frac{\sqrt{x}}{z}\\ \end{array}\]
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1.0\right)}
\begin{array}{l}
\mathbf{if}\;x \le 1.4340218294944 \cdot 10^{-310}:\\
\;\;\;\;\frac{1}{z} \cdot \left(x \cdot \left(\frac{y}{1.0 + z} \cdot \frac{1}{z}\right)\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r20007021 = x;
        double r20007022 = y;
        double r20007023 = r20007021 * r20007022;
        double r20007024 = z;
        double r20007025 = r20007024 * r20007024;
        double r20007026 = 1.0;
        double r20007027 = r20007024 + r20007026;
        double r20007028 = r20007025 * r20007027;
        double r20007029 = r20007023 / r20007028;
        return r20007029;
}

double f(double x, double y, double z) {
        double r20007030 = x;
        double r20007031 = 1.4340218294944e-310;
        bool r20007032 = r20007030 <= r20007031;
        double r20007033 = 1.0;
        double r20007034 = z;
        double r20007035 = r20007033 / r20007034;
        double r20007036 = y;
        double r20007037 = 1.0;
        double r20007038 = r20007037 + r20007034;
        double r20007039 = r20007036 / r20007038;
        double r20007040 = r20007039 * r20007035;
        double r20007041 = r20007030 * r20007040;
        double r20007042 = r20007035 * r20007041;
        double r20007043 = sqrt(r20007030);
        double r20007044 = r20007043 / r20007034;
        double r20007045 = r20007044 * r20007039;
        double r20007046 = r20007045 * r20007044;
        double r20007047 = r20007032 ? r20007042 : r20007046;
        return r20007047;
}

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
Herbie1.9
\[\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 2 regimes
  2. if x < 1.4340218294944e-310

    1. Initial program 14.4

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

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

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

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

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

    if 1.4340218294944e-310 < x

    1. Initial program 14.6

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

      \[\leadsto \color{blue}{\frac{x}{z \cdot z} \cdot \frac{y}{z + 1.0}}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt10.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 1.4340218294944 \cdot 10^{-310}:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot \left(\frac{y}{1.0 + z} \cdot \frac{1}{z}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\sqrt{x}}{z} \cdot \frac{y}{1.0 + z}\right) \cdot \frac{\sqrt{x}}{z}\\ \end{array}\]

Reproduce

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