Average Error: 12.5 → 1.9
Time: 19.1s
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}{y + z}}\\ \mathbf{elif}\;x \le 2.80261989963081169980465809957944374288 \cdot 10^{-79}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \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}{y + z}}\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r24524940 = x;
        double r24524941 = y;
        double r24524942 = z;
        double r24524943 = r24524941 + r24524942;
        double r24524944 = r24524940 * r24524943;
        double r24524945 = r24524944 / r24524942;
        return r24524945;
}

double f(double x, double y, double z) {
        double r24524946 = x;
        double r24524947 = -4.851098445033535e+99;
        bool r24524948 = r24524946 <= r24524947;
        double r24524949 = z;
        double r24524950 = y;
        double r24524951 = r24524950 + r24524949;
        double r24524952 = r24524949 / r24524951;
        double r24524953 = r24524946 / r24524952;
        double r24524954 = 2.8026198996308117e-79;
        bool r24524955 = r24524946 <= r24524954;
        double r24524956 = r24524946 / r24524949;
        double r24524957 = fma(r24524950, r24524956, r24524946);
        double r24524958 = r24524955 ? r24524957 : r24524953;
        double r24524959 = r24524948 ? r24524953 : r24524958;
        return r24524959;
}

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(y, \frac{x}{z}, 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}{y + z}}\\ \mathbf{elif}\;x \le 2.80261989963081169980465809957944374288 \cdot 10^{-79}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \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))