Average Error: 12.6 → 3.2
Time: 2.2s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\frac{x}{\frac{z}{y + z}}\]
\frac{x \cdot \left(y + z\right)}{z}
\frac{x}{\frac{z}{y + z}}
double f(double x, double y, double z) {
        double r399977 = x;
        double r399978 = y;
        double r399979 = z;
        double r399980 = r399978 + r399979;
        double r399981 = r399977 * r399980;
        double r399982 = r399981 / r399979;
        return r399982;
}

double f(double x, double y, double z) {
        double r399983 = x;
        double r399984 = z;
        double r399985 = y;
        double r399986 = r399985 + r399984;
        double r399987 = r399984 / r399986;
        double r399988 = r399983 / r399987;
        return r399988;
}

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

Original12.6
Target3.2
Herbie3.2
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Initial program 12.6

    \[\frac{x \cdot \left(y + z\right)}{z}\]
  2. Using strategy rm
  3. Applied associate-/l*3.2

    \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
  4. Final simplification3.2

    \[\leadsto \frac{x}{\frac{z}{y + z}}\]

Reproduce

herbie shell --seed 2020083 +o rules:numerics
(FPCore (x y z)
  :name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (/ x (/ z (+ y z)))

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