Average Error: 12.3 → 0.4
Time: 2.3s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le -1.5566900973758558 \cdot 10^{66}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 0.01199271336345329:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 3.95135482282658372 \cdot 10^{293}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, x\right)\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le -1.5566900973758558 \cdot 10^{66}:\\
\;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 0.01199271336345329:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 3.95135482282658372 \cdot 10^{293}:\\
\;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, x\right)\\

\end{array}
double f(double x, double y, double z) {
        double r455368 = x;
        double r455369 = y;
        double r455370 = z;
        double r455371 = r455369 + r455370;
        double r455372 = r455368 * r455371;
        double r455373 = r455372 / r455370;
        return r455373;
}

double f(double x, double y, double z) {
        double r455374 = x;
        double r455375 = y;
        double r455376 = z;
        double r455377 = r455375 + r455376;
        double r455378 = r455374 * r455377;
        double r455379 = r455378 / r455376;
        double r455380 = -inf.0;
        bool r455381 = r455379 <= r455380;
        double r455382 = r455376 / r455377;
        double r455383 = r455374 / r455382;
        double r455384 = -1.5566900973758558e+66;
        bool r455385 = r455379 <= r455384;
        double r455386 = 0.01199271336345329;
        bool r455387 = r455379 <= r455386;
        double r455388 = r455375 / r455376;
        double r455389 = fma(r455388, r455374, r455374);
        double r455390 = 3.951354822826584e+293;
        bool r455391 = r455379 <= r455390;
        double r455392 = r455374 / r455376;
        double r455393 = fma(r455392, r455375, r455374);
        double r455394 = r455391 ? r455379 : r455393;
        double r455395 = r455387 ? r455389 : r455394;
        double r455396 = r455385 ? r455379 : r455395;
        double r455397 = r455381 ? r455383 : r455396;
        return r455397;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original12.3
Target3.1
Herbie0.4
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 4 regimes
  2. if (/ (* x (+ y z)) z) < -inf.0

    1. Initial program 64.0

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

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

    if -inf.0 < (/ (* x (+ y z)) z) < -1.5566900973758558e+66 or 0.01199271336345329 < (/ (* x (+ y z)) z) < 3.951354822826584e+293

    1. Initial program 0.2

      \[\frac{x \cdot \left(y + z\right)}{z}\]

    if -1.5566900973758558e+66 < (/ (* x (+ y z)) z) < 0.01199271336345329

    1. Initial program 5.6

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

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

    if 3.951354822826584e+293 < (/ (* x (+ y z)) z)

    1. Initial program 58.2

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{z}, y, x\right)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} = -\infty:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le -1.5566900973758558 \cdot 10^{66}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 0.01199271336345329:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 3.95135482282658372 \cdot 10^{293}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020046 +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))