Average Error: 11.1 → 1.7
Time: 5.9s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(y + z\right) \cdot x}{z} \le 1.2164222642491233 \cdot 10^{-71}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{elif}\;\frac{\left(y + z\right) \cdot x}{z} \le 4.7576076920553454 \cdot 10^{+303}:\\ \;\;\;\;\frac{\left(y + z\right) \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \left(y + z\right)\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;\frac{\left(y + z\right) \cdot x}{z} \le 1.2164222642491233 \cdot 10^{-71}:\\
\;\;\;\;x \cdot \frac{y + z}{z}\\

\mathbf{elif}\;\frac{\left(y + z\right) \cdot x}{z} \le 4.7576076920553454 \cdot 10^{+303}:\\
\;\;\;\;\frac{\left(y + z\right) \cdot x}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r7748917 = x;
        double r7748918 = y;
        double r7748919 = z;
        double r7748920 = r7748918 + r7748919;
        double r7748921 = r7748917 * r7748920;
        double r7748922 = r7748921 / r7748919;
        return r7748922;
}

double f(double x, double y, double z) {
        double r7748923 = y;
        double r7748924 = z;
        double r7748925 = r7748923 + r7748924;
        double r7748926 = x;
        double r7748927 = r7748925 * r7748926;
        double r7748928 = r7748927 / r7748924;
        double r7748929 = 1.2164222642491233e-71;
        bool r7748930 = r7748928 <= r7748929;
        double r7748931 = r7748925 / r7748924;
        double r7748932 = r7748926 * r7748931;
        double r7748933 = 4.7576076920553454e+303;
        bool r7748934 = r7748928 <= r7748933;
        double r7748935 = r7748926 / r7748924;
        double r7748936 = r7748935 * r7748925;
        double r7748937 = r7748934 ? r7748928 : r7748936;
        double r7748938 = r7748930 ? r7748932 : r7748937;
        return r7748938;
}

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

Original11.1
Target3.0
Herbie1.7
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ (* x (+ y z)) z) < 1.2164222642491233e-71

    1. Initial program 10.6

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity10.6

      \[\leadsto \frac{x \cdot \left(y + z\right)}{\color{blue}{1 \cdot z}}\]
    4. Applied times-frac2.3

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

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

    if 1.2164222642491233e-71 < (/ (* x (+ y z)) z) < 4.7576076920553454e+303

    1. Initial program 0.2

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

    if 4.7576076920553454e+303 < (/ (* x (+ y z)) z)

    1. Initial program 57.9

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

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

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

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

Reproduce

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