Average Error: 26.4 → 16.2
Time: 15.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 -1.8800874783927961 \cdot 10^{115} \lor \neg \left(y \le 1.29181664689404663 \cdot 10^{42}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1} \cdot \frac{\mathsf{fma}\left(z, x + y, \mathsf{fma}\left(y, a - b, t \cdot a\right)\right)}{y + \left(x + t\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 -1.8800874783927961 \cdot 10^{115} \lor \neg \left(y \le 1.29181664689404663 \cdot 10^{42}\right):\\
\;\;\;\;\left(a + z\right) - b\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r1026870 = x;
        double r1026871 = y;
        double r1026872 = r1026870 + r1026871;
        double r1026873 = z;
        double r1026874 = r1026872 * r1026873;
        double r1026875 = t;
        double r1026876 = r1026875 + r1026871;
        double r1026877 = a;
        double r1026878 = r1026876 * r1026877;
        double r1026879 = r1026874 + r1026878;
        double r1026880 = b;
        double r1026881 = r1026871 * r1026880;
        double r1026882 = r1026879 - r1026881;
        double r1026883 = r1026870 + r1026875;
        double r1026884 = r1026883 + r1026871;
        double r1026885 = r1026882 / r1026884;
        return r1026885;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1026886 = y;
        double r1026887 = -1.880087478392796e+115;
        bool r1026888 = r1026886 <= r1026887;
        double r1026889 = 1.2918166468940466e+42;
        bool r1026890 = r1026886 <= r1026889;
        double r1026891 = !r1026890;
        bool r1026892 = r1026888 || r1026891;
        double r1026893 = a;
        double r1026894 = z;
        double r1026895 = r1026893 + r1026894;
        double r1026896 = b;
        double r1026897 = r1026895 - r1026896;
        double r1026898 = 1.0;
        double r1026899 = sqrt(r1026898);
        double r1026900 = x;
        double r1026901 = r1026900 + r1026886;
        double r1026902 = r1026893 - r1026896;
        double r1026903 = t;
        double r1026904 = r1026903 * r1026893;
        double r1026905 = fma(r1026886, r1026902, r1026904);
        double r1026906 = fma(r1026894, r1026901, r1026905);
        double r1026907 = r1026900 + r1026903;
        double r1026908 = r1026886 + r1026907;
        double r1026909 = r1026906 / r1026908;
        double r1026910 = r1026899 * r1026909;
        double r1026911 = r1026892 ? r1026897 : r1026910;
        return r1026911;
}

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.4
Target11.3
Herbie16.2
\[\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 < -1.880087478392796e+115 or 1.2918166468940466e+42 < y

    1. Initial program 42.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-num42.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. Simplified42.8

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

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

    if -1.880087478392796e+115 < y < 1.2918166468940466e+42

    1. Initial program 16.9

      \[\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-num17.0

      \[\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. Simplified17.0

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

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

      \[\leadsto \frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(z, x + y, \color{blue}{\mathsf{fma}\left(y, a - b, t \cdot a\right)}\right)}}\]
    7. Using strategy rm
    8. Applied div-inv17.1

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

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

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

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

      \[\leadsto \frac{1}{\left(x + t\right) + y} \cdot \color{blue}{\mathsf{fma}\left(z, x + y, \mathsf{fma}\left(y, a - b, t \cdot a\right)\right)}\]
    13. Using strategy rm
    14. Applied *-un-lft-identity17.0

      \[\leadsto \frac{1}{\color{blue}{1 \cdot \left(\left(x + t\right) + y\right)}} \cdot \mathsf{fma}\left(z, x + y, \mathsf{fma}\left(y, a - b, t \cdot a\right)\right)\]
    15. Applied add-sqr-sqrt17.0

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

      \[\leadsto \color{blue}{\left(\frac{\sqrt{1}}{1} \cdot \frac{\sqrt{1}}{\left(x + t\right) + y}\right)} \cdot \mathsf{fma}\left(z, x + y, \mathsf{fma}\left(y, a - b, t \cdot a\right)\right)\]
    17. Applied associate-*l*17.0

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

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

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

Reproduce

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