Average Error: 26.4 → 16.2
Time: 13.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 -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(x + y, z, \mathsf{fma}\left(t, a, y \cdot \left(a - b\right)\right)\right)}{t + \left(x + y\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(x + y, z, \mathsf{fma}\left(t, a, y \cdot \left(a - b\right)\right)\right)}{t + \left(x + y\right)}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r978540 = x;
        double r978541 = y;
        double r978542 = r978540 + r978541;
        double r978543 = z;
        double r978544 = r978542 * r978543;
        double r978545 = t;
        double r978546 = r978545 + r978541;
        double r978547 = a;
        double r978548 = r978546 * r978547;
        double r978549 = r978544 + r978548;
        double r978550 = b;
        double r978551 = r978541 * r978550;
        double r978552 = r978549 - r978551;
        double r978553 = r978540 + r978545;
        double r978554 = r978553 + r978541;
        double r978555 = r978552 / r978554;
        return r978555;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r978556 = y;
        double r978557 = -1.880087478392796e+115;
        bool r978558 = r978556 <= r978557;
        double r978559 = 1.2918166468940466e+42;
        bool r978560 = r978556 <= r978559;
        double r978561 = !r978560;
        bool r978562 = r978558 || r978561;
        double r978563 = a;
        double r978564 = z;
        double r978565 = r978563 + r978564;
        double r978566 = b;
        double r978567 = r978565 - r978566;
        double r978568 = 1.0;
        double r978569 = sqrt(r978568);
        double r978570 = x;
        double r978571 = r978570 + r978556;
        double r978572 = t;
        double r978573 = r978563 - r978566;
        double r978574 = r978556 * r978573;
        double r978575 = fma(r978572, r978563, r978574);
        double r978576 = fma(r978571, r978564, r978575);
        double r978577 = r978572 + r978571;
        double r978578 = r978576 / r978577;
        double r978579 = r978569 * r978578;
        double r978580 = r978562 ? r978567 : r978579;
        return r978580;
}

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(t, a, 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(t, a, y \cdot \left(a - b\right)\right)\right)}}}\]
    5. Using strategy rm
    6. Applied fma-udef17.0

      \[\leadsto \frac{1}{\frac{\left(x + t\right) + y}{\color{blue}{z \cdot \left(x + y\right) + \mathsf{fma}\left(t, a, y \cdot \left(a - b\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}{z \cdot \left(x + y\right) + \mathsf{fma}\left(t, a, y \cdot \left(a - b\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}{z \cdot \left(x + y\right) + \mathsf{fma}\left(t, a, y \cdot \left(a - b\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}{z \cdot \left(x + y\right) + \mathsf{fma}\left(t, a, y \cdot \left(a - b\right)\right)}}}\]
    11. Simplified17.1

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

      \[\leadsto \frac{1}{\left(x + t\right) + y} \cdot \color{blue}{\mathsf{fma}\left(x + y, z, \mathsf{fma}\left(t, a, y \cdot \left(a - b\right)\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(x + y, z, \mathsf{fma}\left(t, a, y \cdot \left(a - b\right)\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(x + y, z, \mathsf{fma}\left(t, a, y \cdot \left(a - b\right)\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(x + y, z, \mathsf{fma}\left(t, a, y \cdot \left(a - b\right)\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(x + y, z, \mathsf{fma}\left(t, a, y \cdot \left(a - b\right)\right)\right)\right)}\]
    18. Simplified16.9

      \[\leadsto \frac{\sqrt{1}}{1} \cdot \color{blue}{\frac{\mathsf{fma}\left(x + y, z, \mathsf{fma}\left(t, a, y \cdot \left(a - b\right)\right)\right)}{t + \left(x + y\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(x + y, z, \mathsf{fma}\left(t, a, y \cdot \left(a - b\right)\right)\right)}{t + \left(x + y\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)))