Average Error: 12.0 → 3.1
Time: 10.2s
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 r22224770 = x;
        double r22224771 = y;
        double r22224772 = z;
        double r22224773 = r22224771 + r22224772;
        double r22224774 = r22224770 * r22224773;
        double r22224775 = r22224774 / r22224772;
        return r22224775;
}

double f(double x, double y, double z) {
        double r22224776 = y;
        double r22224777 = z;
        double r22224778 = r22224776 + r22224777;
        double r22224779 = x;
        double r22224780 = r22224778 * r22224779;
        double r22224781 = r22224780 / r22224777;
        double r22224782 = -3.8810833874863355e+62;
        bool r22224783 = r22224781 <= r22224782;
        double r22224784 = r22224779 / r22224777;
        double r22224785 = r22224784 * r22224778;
        double r22224786 = r22224778 / r22224777;
        double r22224787 = r22224786 * r22224779;
        double r22224788 = r22224783 ? r22224785 : r22224787;
        return r22224788;
}

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))