Average Error: 27.2 → 15.9
Time: 7.1s
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.82726962280634511 \cdot 10^{54} \lor \neg \left(y \le 4.53189748522320259 \cdot 10^{41}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \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 -1.82726962280634511 \cdot 10^{54} \lor \neg \left(y \le 4.53189748522320259 \cdot 10^{41}\right):\\
\;\;\;\;\left(a + z\right) - b\\

\mathbf{else}:\\
\;\;\;\;1 \cdot \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 r864699 = x;
        double r864700 = y;
        double r864701 = r864699 + r864700;
        double r864702 = z;
        double r864703 = r864701 * r864702;
        double r864704 = t;
        double r864705 = r864704 + r864700;
        double r864706 = a;
        double r864707 = r864705 * r864706;
        double r864708 = r864703 + r864707;
        double r864709 = b;
        double r864710 = r864700 * r864709;
        double r864711 = r864708 - r864710;
        double r864712 = r864699 + r864704;
        double r864713 = r864712 + r864700;
        double r864714 = r864711 / r864713;
        return r864714;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r864715 = y;
        double r864716 = -1.827269622806345e+54;
        bool r864717 = r864715 <= r864716;
        double r864718 = 4.5318974852232026e+41;
        bool r864719 = r864715 <= r864718;
        double r864720 = !r864719;
        bool r864721 = r864717 || r864720;
        double r864722 = a;
        double r864723 = z;
        double r864724 = r864722 + r864723;
        double r864725 = b;
        double r864726 = r864724 - r864725;
        double r864727 = 1.0;
        double r864728 = x;
        double r864729 = r864728 + r864715;
        double r864730 = t;
        double r864731 = r864730 + r864715;
        double r864732 = r864731 * r864722;
        double r864733 = r864715 * r864725;
        double r864734 = r864732 - r864733;
        double r864735 = fma(r864723, r864729, r864734);
        double r864736 = r864728 + r864730;
        double r864737 = r864736 + r864715;
        double r864738 = r864735 / r864737;
        double r864739 = r864727 * r864738;
        double r864740 = r864721 ? r864726 : r864739;
        return r864740;
}

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.2
Target11.7
Herbie15.9
\[\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.827269622806345e+54 or 4.5318974852232026e+41 < y

    1. Initial program 42.2

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

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

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

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

    if -1.827269622806345e+54 < y < 4.5318974852232026e+41

    1. Initial program 16.1

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.82726962280634511 \cdot 10^{54} \lor \neg \left(y \le 4.53189748522320259 \cdot 10^{41}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \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 2020083 +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)))