Average Error: 26.3 → 20.6
Time: 24.5s
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}\;a \le -1.329351671379600395696054258455065074018 \cdot 10^{162}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le 5.325165846082585887271445202627113987297 \cdot 10^{-212}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\sqrt[3]{\left(x + t\right) + y} \cdot \sqrt[3]{\left(x + t\right) + y}} \cdot \frac{b}{\sqrt[3]{\left(x + t\right) + y}}\\ \mathbf{elif}\;a \le 1.908584443905937974655168865478710611307 \cdot 10^{-45}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le 1.978965818958528848241507275261864808485 \cdot 10^{164}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{else}:\\ \;\;\;\;a - y \cdot \frac{b}{\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}\;a \le -1.329351671379600395696054258455065074018 \cdot 10^{162}:\\
\;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\

\mathbf{elif}\;a \le 5.325165846082585887271445202627113987297 \cdot 10^{-212}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\sqrt[3]{\left(x + t\right) + y} \cdot \sqrt[3]{\left(x + t\right) + y}} \cdot \frac{b}{\sqrt[3]{\left(x + t\right) + y}}\\

\mathbf{elif}\;a \le 1.908584443905937974655168865478710611307 \cdot 10^{-45}:\\
\;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\

\mathbf{elif}\;a \le 1.978965818958528848241507275261864808485 \cdot 10^{164}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r600974 = x;
        double r600975 = y;
        double r600976 = r600974 + r600975;
        double r600977 = z;
        double r600978 = r600976 * r600977;
        double r600979 = t;
        double r600980 = r600979 + r600975;
        double r600981 = a;
        double r600982 = r600980 * r600981;
        double r600983 = r600978 + r600982;
        double r600984 = b;
        double r600985 = r600975 * r600984;
        double r600986 = r600983 - r600985;
        double r600987 = r600974 + r600979;
        double r600988 = r600987 + r600975;
        double r600989 = r600986 / r600988;
        return r600989;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r600990 = a;
        double r600991 = -1.3293516713796004e+162;
        bool r600992 = r600990 <= r600991;
        double r600993 = y;
        double r600994 = b;
        double r600995 = x;
        double r600996 = t;
        double r600997 = r600995 + r600996;
        double r600998 = r600997 + r600993;
        double r600999 = r600994 / r600998;
        double r601000 = r600993 * r600999;
        double r601001 = r600990 - r601000;
        double r601002 = 5.325165846082586e-212;
        bool r601003 = r600990 <= r601002;
        double r601004 = r600995 + r600993;
        double r601005 = z;
        double r601006 = r600996 + r600993;
        double r601007 = r601006 * r600990;
        double r601008 = fma(r601004, r601005, r601007);
        double r601009 = r601008 / r600998;
        double r601010 = cbrt(r600998);
        double r601011 = r601010 * r601010;
        double r601012 = r600993 / r601011;
        double r601013 = r600994 / r601010;
        double r601014 = r601012 * r601013;
        double r601015 = r601009 - r601014;
        double r601016 = 1.908584443905938e-45;
        bool r601017 = r600990 <= r601016;
        double r601018 = r601005 - r601000;
        double r601019 = 1.9789658189585288e+164;
        bool r601020 = r600990 <= r601019;
        double r601021 = r600998 / r600994;
        double r601022 = r600993 / r601021;
        double r601023 = r601009 - r601022;
        double r601024 = r601020 ? r601023 : r601001;
        double r601025 = r601017 ? r601018 : r601024;
        double r601026 = r601003 ? r601015 : r601025;
        double r601027 = r600992 ? r601001 : r601026;
        return r601027;
}

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.3
Target11.6
Herbie20.6
\[\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.581311708415056427521064305370896655752 \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.228596430831560895857110658734089400289 \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 4 regimes
  2. if a < -1.3293516713796004e+162 or 1.9789658189585288e+164 < a

    1. Initial program 42.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 div-sub42.9

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}} - \frac{y \cdot b}{\left(x + t\right) + y}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity42.9

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

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

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

      \[\leadsto \color{blue}{a} - y \cdot \frac{b}{\left(x + t\right) + y}\]

    if -1.3293516713796004e+162 < a < 5.325165846082586e-212

    1. Initial program 20.3

      \[\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 div-sub20.3

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}} - \frac{y \cdot b}{\left(x + t\right) + y}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity20.3

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

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

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

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

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

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

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

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

    if 5.325165846082586e-212 < a < 1.908584443905938e-45

    1. Initial program 18.8

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}} - \frac{y \cdot b}{\left(x + t\right) + y}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity18.8

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

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

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

      \[\leadsto \color{blue}{z} - y \cdot \frac{b}{\left(x + t\right) + y}\]

    if 1.908584443905938e-45 < a < 1.9789658189585288e+164

    1. Initial program 26.4

      \[\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 div-sub26.4

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}} - \frac{y \cdot b}{\left(x + t\right) + y}\]
    5. Using strategy rm
    6. Applied associate-/l*23.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.329351671379600395696054258455065074018 \cdot 10^{162}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le 5.325165846082585887271445202627113987297 \cdot 10^{-212}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\sqrt[3]{\left(x + t\right) + y} \cdot \sqrt[3]{\left(x + t\right) + y}} \cdot \frac{b}{\sqrt[3]{\left(x + t\right) + y}}\\ \mathbf{elif}\;a \le 1.908584443905937974655168865478710611307 \cdot 10^{-45}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le 1.978965818958528848241507275261864808485 \cdot 10^{164}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{else}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \end{array}\]

Reproduce

herbie shell --seed 2019303 +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.5813117084150564e153) (- (+ z a) b) (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) 1.2285964308315609e82) (/ 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)))