Average Error: 12.6 → 2.2
Time: 2.9s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.1386197326311352 \cdot 10^{-196} \lor \neg \left(z \le 8.41080899877055 \cdot 10^{-53}\right):\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -4.1386197326311352 \cdot 10^{-196} \lor \neg \left(z \le 8.41080899877055 \cdot 10^{-53}\right):\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r533112 = x;
        double r533113 = y;
        double r533114 = z;
        double r533115 = r533113 + r533114;
        double r533116 = r533112 * r533115;
        double r533117 = r533116 / r533114;
        return r533117;
}

double f(double x, double y, double z) {
        double r533118 = z;
        double r533119 = -4.138619732631135e-196;
        bool r533120 = r533118 <= r533119;
        double r533121 = 8.41080899877055e-53;
        bool r533122 = r533118 <= r533121;
        double r533123 = !r533122;
        bool r533124 = r533120 || r533123;
        double r533125 = x;
        double r533126 = y;
        double r533127 = r533126 + r533118;
        double r533128 = r533118 / r533127;
        double r533129 = r533125 / r533128;
        double r533130 = r533125 * r533126;
        double r533131 = r533130 / r533118;
        double r533132 = r533131 + r533125;
        double r533133 = r533124 ? r533129 : r533132;
        return r533133;
}

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

Derivation

  1. Split input into 2 regimes
  2. if z < -4.138619732631135e-196 or 8.41080899877055e-53 < z

    1. Initial program 13.6

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

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

    if -4.138619732631135e-196 < z < 8.41080899877055e-53

    1. Initial program 9.2

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

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

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

      \[\leadsto \color{blue}{x} \cdot \frac{y + z}{z}\]
    6. Taylor expanded around 0 5.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.1386197326311352 \cdot 10^{-196} \lor \neg \left(z \le 8.41080899877055 \cdot 10^{-53}\right):\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \end{array}\]

Reproduce

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