Average Error: 12.0 → 3.1
Time: 10.7s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(y + z\right) \cdot x}{z} \le -3.8810833874863355 \cdot 10^{+62}:\\ \;\;\;\;\frac{x}{z} \cdot \left(y + z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y + z}{z} \cdot x\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;\frac{\left(y + z\right) \cdot x}{z} \le -3.8810833874863355 \cdot 10^{+62}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + z\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{y + z}{z} \cdot x\\

\end{array}
double f(double x, double y, double z) {
        double r22848662 = x;
        double r22848663 = y;
        double r22848664 = z;
        double r22848665 = r22848663 + r22848664;
        double r22848666 = r22848662 * r22848665;
        double r22848667 = r22848666 / r22848664;
        return r22848667;
}

double f(double x, double y, double z) {
        double r22848668 = y;
        double r22848669 = z;
        double r22848670 = r22848668 + r22848669;
        double r22848671 = x;
        double r22848672 = r22848670 * r22848671;
        double r22848673 = r22848672 / r22848669;
        double r22848674 = -3.8810833874863355e+62;
        bool r22848675 = r22848673 <= r22848674;
        double r22848676 = r22848671 / r22848669;
        double r22848677 = r22848676 * r22848670;
        double r22848678 = r22848670 / r22848669;
        double r22848679 = r22848678 * r22848671;
        double r22848680 = r22848675 ? r22848677 : r22848679;
        return r22848680;
}

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.0
Target2.9
Herbie3.1
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (* x (+ y z)) z) < -3.8810833874863355e+62

    1. Initial program 19.3

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Using strategy rm
    5. Applied associate-/r/6.0

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

    if -3.8810833874863355e+62 < (/ (* x (+ y z)) z)

    1. Initial program 9.8

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Using strategy rm
    5. Applied div-inv2.2

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

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

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

Reproduce

herbie shell --seed 2019163 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"

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

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