Average Error: 26.8 → 17.0
Time: 15.8s
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 -27079908379746977475117311859620495491070:\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{elif}\;y \le -5.447793497456020768516524910978094723718 \cdot 10^{-193}:\\ \;\;\;\;\frac{1}{\left(\left(x + t\right) + y\right) \cdot \frac{1}{\mathsf{fma}\left(z, x + y, \mathsf{fma}\left(a, t, y \cdot \left(a - b\right)\right)\right)}}\\ \mathbf{elif}\;y \le -9.382616835751196398391843381844181316896 \cdot 10^{-235}:\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{elif}\;y \le 1.280793272768655509582061506115744871972 \cdot 10^{-15}:\\ \;\;\;\;\frac{1}{\left(x + t\right) + y} \cdot \mathsf{fma}\left(z, x + y, \mathsf{fma}\left(a, t, y \cdot \left(a - b\right)\right)\right)\\ \mathbf{elif}\;y \le 62471.76373336250981083139777183532714844:\\ \;\;\;\;a\\ \mathbf{elif}\;y \le 1.055048484988150356054797628954610351517 \cdot 10^{52}:\\ \;\;\;\;\frac{1}{\left(\left(x + t\right) + y\right) \cdot \frac{1}{\mathsf{fma}\left(z, x + y, \mathsf{fma}\left(a, t, y \cdot \left(a - b\right)\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(a + z\right) - b\\ \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 -27079908379746977475117311859620495491070:\\
\;\;\;\;\left(a + z\right) - b\\

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

\mathbf{elif}\;y \le -9.382616835751196398391843381844181316896 \cdot 10^{-235}:\\
\;\;\;\;\left(a + z\right) - b\\

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

\mathbf{elif}\;y \le 62471.76373336250981083139777183532714844:\\
\;\;\;\;a\\

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

\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r584543 = x;
        double r584544 = y;
        double r584545 = r584543 + r584544;
        double r584546 = z;
        double r584547 = r584545 * r584546;
        double r584548 = t;
        double r584549 = r584548 + r584544;
        double r584550 = a;
        double r584551 = r584549 * r584550;
        double r584552 = r584547 + r584551;
        double r584553 = b;
        double r584554 = r584544 * r584553;
        double r584555 = r584552 - r584554;
        double r584556 = r584543 + r584548;
        double r584557 = r584556 + r584544;
        double r584558 = r584555 / r584557;
        return r584558;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r584559 = y;
        double r584560 = -2.7079908379746977e+40;
        bool r584561 = r584559 <= r584560;
        double r584562 = a;
        double r584563 = z;
        double r584564 = r584562 + r584563;
        double r584565 = b;
        double r584566 = r584564 - r584565;
        double r584567 = -5.447793497456021e-193;
        bool r584568 = r584559 <= r584567;
        double r584569 = 1.0;
        double r584570 = x;
        double r584571 = t;
        double r584572 = r584570 + r584571;
        double r584573 = r584572 + r584559;
        double r584574 = r584570 + r584559;
        double r584575 = r584562 - r584565;
        double r584576 = r584559 * r584575;
        double r584577 = fma(r584562, r584571, r584576);
        double r584578 = fma(r584563, r584574, r584577);
        double r584579 = r584569 / r584578;
        double r584580 = r584573 * r584579;
        double r584581 = r584569 / r584580;
        double r584582 = -9.382616835751196e-235;
        bool r584583 = r584559 <= r584582;
        double r584584 = 1.2807932727686555e-15;
        bool r584585 = r584559 <= r584584;
        double r584586 = r584569 / r584573;
        double r584587 = r584586 * r584578;
        double r584588 = 62471.76373336251;
        bool r584589 = r584559 <= r584588;
        double r584590 = 1.0550484849881504e+52;
        bool r584591 = r584559 <= r584590;
        double r584592 = r584591 ? r584581 : r584566;
        double r584593 = r584589 ? r584562 : r584592;
        double r584594 = r584585 ? r584587 : r584593;
        double r584595 = r584583 ? r584566 : r584594;
        double r584596 = r584568 ? r584581 : r584595;
        double r584597 = r584561 ? r584566 : r584596;
        return r584597;
}

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.8
Target11.2
Herbie17.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.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 y < -2.7079908379746977e+40 or -5.447793497456021e-193 < y < -9.382616835751196e-235 or 1.0550484849881504e+52 < y

    1. Initial program 39.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-num39.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. Simplified39.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 17.1

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

    if -2.7079908379746977e+40 < y < -5.447793497456021e-193 or 62471.76373336251 < y < 1.0550484849881504e+52

    1. Initial program 17.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 clear-num17.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. Simplified17.5

      \[\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. Using strategy rm
    6. Applied div-inv17.6

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

    if -9.382616835751196e-235 < y < 1.2807932727686555e-15

    1. Initial program 14.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-num14.9

      \[\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. Simplified14.9

      \[\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. Using strategy rm
    6. Applied associate-/r/14.9

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

    if 1.2807932727686555e-15 < y < 62471.76373336251

    1. Initial program 14.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. Simplified14.3

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

      \[\leadsto \color{blue}{a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification17.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -27079908379746977475117311859620495491070:\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{elif}\;y \le -5.447793497456020768516524910978094723718 \cdot 10^{-193}:\\ \;\;\;\;\frac{1}{\left(\left(x + t\right) + y\right) \cdot \frac{1}{\mathsf{fma}\left(z, x + y, \mathsf{fma}\left(a, t, y \cdot \left(a - b\right)\right)\right)}}\\ \mathbf{elif}\;y \le -9.382616835751196398391843381844181316896 \cdot 10^{-235}:\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{elif}\;y \le 1.280793272768655509582061506115744871972 \cdot 10^{-15}:\\ \;\;\;\;\frac{1}{\left(x + t\right) + y} \cdot \mathsf{fma}\left(z, x + y, \mathsf{fma}\left(a, t, y \cdot \left(a - b\right)\right)\right)\\ \mathbf{elif}\;y \le 62471.76373336250981083139777183532714844:\\ \;\;\;\;a\\ \mathbf{elif}\;y \le 1.055048484988150356054797628954610351517 \cdot 10^{52}:\\ \;\;\;\;\frac{1}{\left(\left(x + t\right) + y\right) \cdot \frac{1}{\mathsf{fma}\left(z, x + y, \mathsf{fma}\left(a, t, y \cdot \left(a - b\right)\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\left(a + z\right) - b\\ \end{array}\]

Reproduce

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