Average Error: 15.5 → 1.9
Time: 2.7s
Precision: 64
\[\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le 7.8962089579623809 \cdot 10^{-127} \lor \neg \left(x \cdot y \le 1.06517562882529206 \cdot 10^{204}\right):\\ \;\;\;\;\frac{x}{z} \cdot \frac{\frac{y}{z + 1}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot y}{z \cdot \left(z + 1\right)}}{z}\\ \end{array}\]
\frac{x \cdot y}{\left(z \cdot z\right) \cdot \left(z + 1\right)}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le 7.8962089579623809 \cdot 10^{-127} \lor \neg \left(x \cdot y \le 1.06517562882529206 \cdot 10^{204}\right):\\
\;\;\;\;\frac{x}{z} \cdot \frac{\frac{y}{z + 1}}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r243393 = x;
        double r243394 = y;
        double r243395 = r243393 * r243394;
        double r243396 = z;
        double r243397 = r243396 * r243396;
        double r243398 = 1.0;
        double r243399 = r243396 + r243398;
        double r243400 = r243397 * r243399;
        double r243401 = r243395 / r243400;
        return r243401;
}

double f(double x, double y, double z) {
        double r243402 = x;
        double r243403 = y;
        double r243404 = r243402 * r243403;
        double r243405 = 7.896208957962381e-127;
        bool r243406 = r243404 <= r243405;
        double r243407 = 1.065175628825292e+204;
        bool r243408 = r243404 <= r243407;
        double r243409 = !r243408;
        bool r243410 = r243406 || r243409;
        double r243411 = z;
        double r243412 = r243402 / r243411;
        double r243413 = 1.0;
        double r243414 = r243411 + r243413;
        double r243415 = r243403 / r243414;
        double r243416 = r243415 / r243411;
        double r243417 = r243412 * r243416;
        double r243418 = r243411 * r243414;
        double r243419 = r243404 / r243418;
        double r243420 = r243419 / r243411;
        double r243421 = r243410 ? r243417 : r243420;
        return r243421;
}

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

Original15.5
Target4.0
Herbie1.9
\[\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 (* x y) < 7.896208957962381e-127 or 1.065175628825292e+204 < (* x y)

    1. Initial program 18.6

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

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

      \[\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.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/7.4

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{z}}{1} \cdot \frac{\frac{y}{z + 1}}{z}}\]
    15. Simplified2.3

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

    if 7.896208957962381e-127 < (* x y) < 1.065175628825292e+204

    1. Initial program 4.2

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

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

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

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

      \[\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/0.8

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

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

      \[\leadsto \frac{\color{blue}{\frac{x}{z} \cdot \frac{y}{z + 1}}}{z}\]
    12. Using strategy rm
    13. Applied frac-times0.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le 7.8962089579623809 \cdot 10^{-127} \lor \neg \left(x \cdot y \le 1.06517562882529206 \cdot 10^{204}\right):\\ \;\;\;\;\frac{x}{z} \cdot \frac{\frac{y}{z + 1}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot y}{z \cdot \left(z + 1\right)}}{z}\\ \end{array}\]

Reproduce

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