Average Error: 26.2 → 16.1
Time: 7.7s
Precision: 64
\[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -7.3254035686044846 \cdot 10^{114} \lor \neg \left(y \le 32.351428127283\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}\\ \end{array}\]
\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
\begin{array}{l}
\mathbf{if}\;y \le -7.3254035686044846 \cdot 10^{114} \lor \neg \left(y \le 32.351428127283\right):\\
\;\;\;\;\left(a + z\right) - b\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r931924 = x;
        double r931925 = y;
        double r931926 = r931924 + r931925;
        double r931927 = z;
        double r931928 = r931926 * r931927;
        double r931929 = t;
        double r931930 = r931929 + r931925;
        double r931931 = a;
        double r931932 = r931930 * r931931;
        double r931933 = r931928 + r931932;
        double r931934 = b;
        double r931935 = r931925 * r931934;
        double r931936 = r931933 - r931935;
        double r931937 = r931924 + r931929;
        double r931938 = r931937 + r931925;
        double r931939 = r931936 / r931938;
        return r931939;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r931940 = y;
        double r931941 = -7.325403568604485e+114;
        bool r931942 = r931940 <= r931941;
        double r931943 = 32.351428127283;
        bool r931944 = r931940 <= r931943;
        double r931945 = !r931944;
        bool r931946 = r931942 || r931945;
        double r931947 = a;
        double r931948 = z;
        double r931949 = r931947 + r931948;
        double r931950 = b;
        double r931951 = r931949 - r931950;
        double r931952 = 1.0;
        double r931953 = x;
        double r931954 = t;
        double r931955 = r931953 + r931954;
        double r931956 = r931955 + r931940;
        double r931957 = r931953 + r931940;
        double r931958 = r931954 + r931940;
        double r931959 = r931958 * r931947;
        double r931960 = r931940 * r931950;
        double r931961 = r931959 - r931960;
        double r931962 = fma(r931948, r931957, r931961);
        double r931963 = r931956 / r931962;
        double r931964 = r931952 / r931963;
        double r931965 = r931946 ? r931951 : r931964;
        return r931965;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Target

Original26.2
Target11.2
Herbie16.1
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \lt -3.5813117084150564 \cdot 10^{153}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \lt 1.2285964308315609 \cdot 10^{82}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\left(z + a\right) - b\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -7.325403568604485e+114 or 32.351428127283 < y

    1. Initial program 41.7

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
    2. Using strategy rm
    3. Applied clear-num41.7

      \[\leadsto \color{blue}{\frac{1}{\frac{\left(x + t\right) + y}{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}}}\]
    4. Simplified41.7

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}}\]
    5. Taylor expanded around 0 16.0

      \[\leadsto \color{blue}{\left(a + z\right) - b}\]

    if -7.325403568604485e+114 < y < 32.351428127283

    1. Initial program 16.1

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
    2. Using strategy rm
    3. Applied clear-num16.2

      \[\leadsto \color{blue}{\frac{1}{\frac{\left(x + t\right) + y}{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}}}\]
    4. Simplified16.2

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification16.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -7.3254035686044846 \cdot 10^{114} \lor \neg \left(y \le 32.351428127283\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020035 +o rules:numerics
(FPCore (x y z t a b)
  :name "AI.Clustering.Hierarchical.Internal:ward from clustering-0.2.1"
  :precision binary64

  :herbie-target
  (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) -3.5813117084150564e+153) (- (+ z a) b) (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) 1.2285964308315609e+82) (/ 1 (/ (+ (+ x t) y) (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)))) (- (+ z a) b)))

  (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))