Average Error: 12.4 → 4.9
Time: 2.8s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\left(x \cdot y\right) \cdot \frac{1}{z} + x\]
\frac{x \cdot \left(y + z\right)}{z}
\left(x \cdot y\right) \cdot \frac{1}{z} + x
double f(double x, double y, double z) {
        double r277094 = x;
        double r277095 = y;
        double r277096 = z;
        double r277097 = r277095 + r277096;
        double r277098 = r277094 * r277097;
        double r277099 = r277098 / r277096;
        return r277099;
}

double f(double x, double y, double z) {
        double r277100 = x;
        double r277101 = y;
        double r277102 = r277100 * r277101;
        double r277103 = 1.0;
        double r277104 = z;
        double r277105 = r277103 / r277104;
        double r277106 = r277102 * r277105;
        double r277107 = r277106 + r277100;
        return r277107;
}

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.4
Target3.1
Herbie4.9
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -1.0974667898439183e+134 or 1.0010617300760747e-92 < x

    1. Initial program 21.3

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Taylor expanded around 0 7.2

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + x}\]
    3. Using strategy rm
    4. Applied div-inv7.3

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

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

    if -1.0974667898439183e+134 < x < 1.0010617300760747e-92

    1. Initial program 6.5

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Taylor expanded around 0 3.2

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + x}\]
    3. Using strategy rm
    4. Applied div-inv3.3

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

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

Reproduce

herbie shell --seed 2019304 
(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))