Average Error: 12.5 → 1.9
Time: 17.3s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -4.851098445033534649200289234832441763791 \cdot 10^{99}:\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \mathbf{elif}\;x \le 2.80261989963081169980465809957944374288 \cdot 10^{-79}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \le -4.851098445033534649200289234832441763791 \cdot 10^{99}:\\
\;\;\;\;\frac{x}{\frac{z}{z + y}}\\

\mathbf{elif}\;x \le 2.80261989963081169980465809957944374288 \cdot 10^{-79}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, x\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r19736153 = x;
        double r19736154 = y;
        double r19736155 = z;
        double r19736156 = r19736154 + r19736155;
        double r19736157 = r19736153 * r19736156;
        double r19736158 = r19736157 / r19736155;
        return r19736158;
}

double f(double x, double y, double z) {
        double r19736159 = x;
        double r19736160 = -4.851098445033535e+99;
        bool r19736161 = r19736159 <= r19736160;
        double r19736162 = z;
        double r19736163 = y;
        double r19736164 = r19736162 + r19736163;
        double r19736165 = r19736162 / r19736164;
        double r19736166 = r19736159 / r19736165;
        double r19736167 = 2.8026198996308117e-79;
        bool r19736168 = r19736159 <= r19736167;
        double r19736169 = r19736159 / r19736162;
        double r19736170 = fma(r19736169, r19736163, r19736159);
        double r19736171 = r19736168 ? r19736170 : r19736166;
        double r19736172 = r19736161 ? r19736166 : r19736171;
        return r19736172;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original12.5
Target3.1
Herbie1.9
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -4.851098445033535e+99 or 2.8026198996308117e-79 < x

    1. Initial program 21.8

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

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

    if -4.851098445033535e+99 < x < 2.8026198996308117e-79

    1. Initial program 5.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.851098445033534649200289234832441763791 \cdot 10^{99}:\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \mathbf{elif}\;x \le 2.80261989963081169980465809957944374288 \cdot 10^{-79}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{z + y}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y z)
  :name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"

  :herbie-target
  (/ x (/ z (+ y z)))

  (/ (* x (+ y z)) z))