Average Error: 12.6 → 0.2
Time: 2.9s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le -5.36585091453369265 \cdot 10^{29} \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le 4.7357356704441813 \cdot 10^{-60} \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le 4.83290498311523521 \cdot 10^{302}\right)\right)\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le -5.36585091453369265 \cdot 10^{29} \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le 4.7357356704441813 \cdot 10^{-60} \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le 4.83290498311523521 \cdot 10^{302}\right)\right)\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r400479 = x;
        double r400480 = y;
        double r400481 = z;
        double r400482 = r400480 + r400481;
        double r400483 = r400479 * r400482;
        double r400484 = r400483 / r400481;
        return r400484;
}

double f(double x, double y, double z) {
        double r400485 = x;
        double r400486 = y;
        double r400487 = z;
        double r400488 = r400486 + r400487;
        double r400489 = r400485 * r400488;
        double r400490 = r400489 / r400487;
        double r400491 = -inf.0;
        bool r400492 = r400490 <= r400491;
        double r400493 = -5.3658509145336926e+29;
        bool r400494 = r400490 <= r400493;
        double r400495 = 4.7357356704441813e-60;
        bool r400496 = r400490 <= r400495;
        double r400497 = 4.832904983115235e+302;
        bool r400498 = r400490 <= r400497;
        double r400499 = !r400498;
        bool r400500 = r400496 || r400499;
        double r400501 = !r400500;
        bool r400502 = r400494 || r400501;
        double r400503 = !r400502;
        bool r400504 = r400492 || r400503;
        double r400505 = r400486 / r400487;
        double r400506 = fma(r400505, r400485, r400485);
        double r400507 = r400504 ? r400506 : r400490;
        return r400507;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original12.6
Target2.9
Herbie0.2
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (* x (+ y z)) z) < -inf.0 or -5.3658509145336926e+29 < (/ (* x (+ y z)) z) < 4.7357356704441813e-60 or 4.832904983115235e+302 < (/ (* x (+ y z)) z)

    1. Initial program 22.2

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Simplified0.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z}, x, x\right)}\]

    if -inf.0 < (/ (* x (+ y z)) z) < -5.3658509145336926e+29 or 4.7357356704441813e-60 < (/ (* x (+ y z)) z) < 4.832904983115235e+302

    1. Initial program 0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le -5.36585091453369265 \cdot 10^{29} \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le 4.7357356704441813 \cdot 10^{-60} \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \le 4.83290498311523521 \cdot 10^{302}\right)\right)\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2020036 +o rules:numerics
(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))