Average Error: 12.4 → 3.2
Time: 2.0s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.458030110290383629327789829095143522841 \cdot 10^{-10} \lor \neg \left(x \le -1.241099098232442995043783878232537440558 \cdot 10^{-297}\right):\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot \left(y + z\right)\right)\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \le -2.458030110290383629327789829095143522841 \cdot 10^{-10} \lor \neg \left(x \le -1.241099098232442995043783878232537440558 \cdot 10^{-297}\right):\\
\;\;\;\;x \cdot \frac{y + z}{z}\\

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

\end{array}
double f(double x, double y, double z) {
        double r501471 = x;
        double r501472 = y;
        double r501473 = z;
        double r501474 = r501472 + r501473;
        double r501475 = r501471 * r501474;
        double r501476 = r501475 / r501473;
        return r501476;
}

double f(double x, double y, double z) {
        double r501477 = x;
        double r501478 = -2.4580301102903836e-10;
        bool r501479 = r501477 <= r501478;
        double r501480 = -1.241099098232443e-297;
        bool r501481 = r501477 <= r501480;
        double r501482 = !r501481;
        bool r501483 = r501479 || r501482;
        double r501484 = y;
        double r501485 = z;
        double r501486 = r501484 + r501485;
        double r501487 = r501486 / r501485;
        double r501488 = r501477 * r501487;
        double r501489 = 1.0;
        double r501490 = r501489 / r501485;
        double r501491 = r501477 * r501486;
        double r501492 = r501490 * r501491;
        double r501493 = r501483 ? r501488 : r501492;
        return r501493;
}

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.4
Target3.1
Herbie3.2
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -2.4580301102903836e-10 or -1.241099098232443e-297 < x

    1. Initial program 15.2

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

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

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

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

    if -2.4580301102903836e-10 < x < -1.241099098232443e-297

    1. Initial program 5.0

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

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

      \[\leadsto \frac{x}{\color{blue}{z \cdot \frac{1}{y + z}}}\]
    6. Applied *-un-lft-identity5.4

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{z \cdot \frac{1}{y + z}}\]
    7. Applied times-frac5.1

      \[\leadsto \color{blue}{\frac{1}{z} \cdot \frac{x}{\frac{1}{y + z}}}\]
    8. Simplified5.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.458030110290383629327789829095143522841 \cdot 10^{-10} \lor \neg \left(x \le -1.241099098232442995043783878232537440558 \cdot 10^{-297}\right):\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \left(x \cdot \left(y + z\right)\right)\\ \end{array}\]

Reproduce

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