Average Error: 12.8 → 0.2
Time: 2.2s
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 -9.7940018614008788 \cdot 10^{-16}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 1.46930528145201732 \cdot 10^{-65}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 9.17799804715485317 \cdot 10^{305}:\\ \;\;\;\;\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 -9.7940018614008788 \cdot 10^{-16}:\\
\;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\

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

\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 9.17799804715485317 \cdot 10^{305}:\\
\;\;\;\;\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 r424089 = x;
        double r424090 = y;
        double r424091 = z;
        double r424092 = r424090 + r424091;
        double r424093 = r424089 * r424092;
        double r424094 = r424093 / r424091;
        return r424094;
}

double f(double x, double y, double z) {
        double r424095 = x;
        double r424096 = y;
        double r424097 = z;
        double r424098 = r424096 + r424097;
        double r424099 = r424095 * r424098;
        double r424100 = r424099 / r424097;
        double r424101 = -inf.0;
        bool r424102 = r424100 <= r424101;
        double r424103 = r424097 / r424098;
        double r424104 = r424095 / r424103;
        double r424105 = -9.794001861400879e-16;
        bool r424106 = r424100 <= r424105;
        double r424107 = 1.4693052814520173e-65;
        bool r424108 = r424100 <= r424107;
        double r424109 = 9.177998047154853e+305;
        bool r424110 = r424100 <= r424109;
        double r424111 = r424095 / r424097;
        double r424112 = fma(r424111, r424096, r424095);
        double r424113 = r424110 ? r424100 : r424112;
        double r424114 = r424108 ? r424104 : r424113;
        double r424115 = r424106 ? r424100 : r424114;
        double r424116 = r424102 ? r424104 : r424115;
        return r424116;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Split input into 3 regimes
  2. if (/ (* x (+ y z)) z) < -inf.0 or -9.794001861400879e-16 < (/ (* x (+ y z)) z) < 1.4693052814520173e-65

    1. Initial program 17.5

      \[\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) < -9.794001861400879e-16 or 1.4693052814520173e-65 < (/ (* x (+ y z)) z) < 9.177998047154853e+305

    1. Initial program 0.2

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

    if 9.177998047154853e+305 < (/ (* x (+ y z)) z)

    1. Initial program 62.7

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

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

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

    \[\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 -9.7940018614008788 \cdot 10^{-16}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 1.46930528145201732 \cdot 10^{-65}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \le 9.17799804715485317 \cdot 10^{305}:\\ \;\;\;\;\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 2020081 +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))