Average Error: 27.1 → 16.0
Time: 7.2s
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 -2.09253904820276937 \cdot 10^{87} \lor \neg \left(y \le 1.1685565590472489 \cdot 10^{-98} \lor \neg \left(y \le 1.8899870319995665 \cdot 10^{-88} \lor \neg \left(y \le 1.1685265508795281 \cdot 10^{44}\right)\right)\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}{\left(x + t\right) + y}\\ \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 -2.09253904820276937 \cdot 10^{87} \lor \neg \left(y \le 1.1685565590472489 \cdot 10^{-98} \lor \neg \left(y \le 1.8899870319995665 \cdot 10^{-88} \lor \neg \left(y \le 1.1685265508795281 \cdot 10^{44}\right)\right)\right):\\
\;\;\;\;\left(a + z\right) - b\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r940911 = x;
        double r940912 = y;
        double r940913 = r940911 + r940912;
        double r940914 = z;
        double r940915 = r940913 * r940914;
        double r940916 = t;
        double r940917 = r940916 + r940912;
        double r940918 = a;
        double r940919 = r940917 * r940918;
        double r940920 = r940915 + r940919;
        double r940921 = b;
        double r940922 = r940912 * r940921;
        double r940923 = r940920 - r940922;
        double r940924 = r940911 + r940916;
        double r940925 = r940924 + r940912;
        double r940926 = r940923 / r940925;
        return r940926;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r940927 = y;
        double r940928 = -2.0925390482027694e+87;
        bool r940929 = r940927 <= r940928;
        double r940930 = 1.168556559047249e-98;
        bool r940931 = r940927 <= r940930;
        double r940932 = 1.8899870319995665e-88;
        bool r940933 = r940927 <= r940932;
        double r940934 = 1.1685265508795281e+44;
        bool r940935 = r940927 <= r940934;
        double r940936 = !r940935;
        bool r940937 = r940933 || r940936;
        double r940938 = !r940937;
        bool r940939 = r940931 || r940938;
        double r940940 = !r940939;
        bool r940941 = r940929 || r940940;
        double r940942 = a;
        double r940943 = z;
        double r940944 = r940942 + r940943;
        double r940945 = b;
        double r940946 = r940944 - r940945;
        double r940947 = x;
        double r940948 = r940947 + r940927;
        double r940949 = t;
        double r940950 = r940949 + r940927;
        double r940951 = r940950 * r940942;
        double r940952 = r940927 * r940945;
        double r940953 = r940951 - r940952;
        double r940954 = fma(r940943, r940948, r940953);
        double r940955 = r940947 + r940949;
        double r940956 = r940955 + r940927;
        double r940957 = r940954 / r940956;
        double r940958 = r940941 ? r940946 : r940957;
        return r940958;
}

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

Original27.1
Target11.5
Herbie16.0
\[\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 < -2.0925390482027694e+87 or 1.168556559047249e-98 < y < 1.8899870319995665e-88 or 1.1685265508795281e+44 < 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.8

      \[\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.8

      \[\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 15.3

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

    if -2.0925390482027694e+87 < y < 1.168556559047249e-98 or 1.8899870319995665e-88 < y < 1.1685265508795281e+44

    1. Initial program 16.5

      \[\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.6

      \[\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.6

      \[\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. Using strategy rm
    6. Applied *-un-lft-identity16.6

      \[\leadsto \frac{1}{\frac{\left(x + t\right) + y}{\color{blue}{1 \cdot \mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}}\]
    7. Applied *-un-lft-identity16.6

      \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot \left(\left(x + t\right) + y\right)}}{1 \cdot \mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}\]
    8. Applied times-frac16.6

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{\left(x + t\right) + y}{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}}\]
    9. Applied add-cube-cbrt16.6

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{1}{1} \cdot \frac{\left(x + t\right) + y}{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}\]
    10. Applied times-frac16.6

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{1}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}}\]
    11. Simplified16.6

      \[\leadsto \color{blue}{1} \cdot \frac{\sqrt[3]{1}}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}\]
    12. Simplified16.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -2.09253904820276937 \cdot 10^{87} \lor \neg \left(y \le 1.1685565590472489 \cdot 10^{-98} \lor \neg \left(y \le 1.8899870319995665 \cdot 10^{-88} \lor \neg \left(y \le 1.1685265508795281 \cdot 10^{44}\right)\right)\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}{\left(x + t\right) + y}\\ \end{array}\]

Reproduce

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