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 r491390 = x;
        double r491391 = y;
        double r491392 = z;
        double r491393 = r491391 + r491392;
        double r491394 = r491390 * r491393;
        double r491395 = r491394 / r491392;
        return r491395;
}

double f(double x, double y, double z) {
        double r491396 = z;
        double r491397 = -4.138619732631135e-196;
        bool r491398 = r491396 <= r491397;
        double r491399 = 8.41080899877055e-53;
        bool r491400 = r491396 <= r491399;
        double r491401 = !r491400;
        bool r491402 = r491398 || r491401;
        double r491403 = x;
        double r491404 = y;
        double r491405 = r491404 + r491396;
        double r491406 = r491396 / r491405;
        double r491407 = r491403 / r491406;
        double r491408 = r491403 * r491404;
        double r491409 = r491408 / r491396;
        double r491410 = r491409 + r491403;
        double r491411 = r491402 ? r491407 : r491410;
        return r491411;
}

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