Average Error: 12.1 → 2.4
Time: 6.5s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.016978897081638 \cdot 10^{-26}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{elif}\;z \le -2.4206933261639595 \cdot 10^{-283}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -1.016978897081638 \cdot 10^{-26}:\\
\;\;\;\;x \cdot \frac{y + z}{z}\\

\mathbf{elif}\;z \le -2.4206933261639595 \cdot 10^{-283}:\\
\;\;\;\;\frac{x \cdot y}{z} + x\\

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

\end{array}
double f(double x, double y, double z) {
        double r391499 = x;
        double r391500 = y;
        double r391501 = z;
        double r391502 = r391500 + r391501;
        double r391503 = r391499 * r391502;
        double r391504 = r391503 / r391501;
        return r391504;
}

double f(double x, double y, double z) {
        double r391505 = z;
        double r391506 = -1.016978897081638e-26;
        bool r391507 = r391505 <= r391506;
        double r391508 = x;
        double r391509 = y;
        double r391510 = r391509 + r391505;
        double r391511 = r391510 / r391505;
        double r391512 = r391508 * r391511;
        double r391513 = -2.4206933261639595e-283;
        bool r391514 = r391505 <= r391513;
        double r391515 = r391508 * r391509;
        double r391516 = r391515 / r391505;
        double r391517 = r391516 + r391508;
        double r391518 = r391505 / r391510;
        double r391519 = r391508 / r391518;
        double r391520 = r391514 ? r391517 : r391519;
        double r391521 = r391507 ? r391512 : r391520;
        return r391521;
}

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

Derivation

  1. Split input into 3 regimes
  2. if z < -1.016978897081638e-26

    1. Initial program 14.9

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

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

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

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

    if -1.016978897081638e-26 < z < -2.4206933261639595e-283

    1. Initial program 6.7

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Taylor expanded around 0 3.9

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

    if -2.4206933261639595e-283 < z

    1. Initial program 12.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.016978897081638 \cdot 10^{-26}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{elif}\;z \le -2.4206933261639595 \cdot 10^{-283}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \end{array}\]

Reproduce

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