Average Error: 26.3 → 17.9
Time: 7.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 -1.28364647930015676 \cdot 10^{60} \lor \neg \left(y \le -1.0932202536774648 \cdot 10^{-278} \lor \neg \left(y \le 2.1354481372959581 \cdot 10^{-289} \lor \neg \left(y \le 2.29423840239453002 \cdot 10^{-41}\right)\right)\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot \left(x + y\right)}{\left(x + t\right) + y} + \frac{\mathsf{fma}\left(y, a - b, a \cdot t\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.28364647930015676 \cdot 10^{60} \lor \neg \left(y \le -1.0932202536774648 \cdot 10^{-278} \lor \neg \left(y \le 2.1354481372959581 \cdot 10^{-289} \lor \neg \left(y \le 2.29423840239453002 \cdot 10^{-41}\right)\right)\right):\\
\;\;\;\;\left(a + z\right) - b\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r895250 = x;
        double r895251 = y;
        double r895252 = r895250 + r895251;
        double r895253 = z;
        double r895254 = r895252 * r895253;
        double r895255 = t;
        double r895256 = r895255 + r895251;
        double r895257 = a;
        double r895258 = r895256 * r895257;
        double r895259 = r895254 + r895258;
        double r895260 = b;
        double r895261 = r895251 * r895260;
        double r895262 = r895259 - r895261;
        double r895263 = r895250 + r895255;
        double r895264 = r895263 + r895251;
        double r895265 = r895262 / r895264;
        return r895265;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r895266 = y;
        double r895267 = -1.2836464793001568e+60;
        bool r895268 = r895266 <= r895267;
        double r895269 = -1.0932202536774648e-278;
        bool r895270 = r895266 <= r895269;
        double r895271 = 2.135448137295958e-289;
        bool r895272 = r895266 <= r895271;
        double r895273 = 2.29423840239453e-41;
        bool r895274 = r895266 <= r895273;
        double r895275 = !r895274;
        bool r895276 = r895272 || r895275;
        double r895277 = !r895276;
        bool r895278 = r895270 || r895277;
        double r895279 = !r895278;
        bool r895280 = r895268 || r895279;
        double r895281 = a;
        double r895282 = z;
        double r895283 = r895281 + r895282;
        double r895284 = b;
        double r895285 = r895283 - r895284;
        double r895286 = x;
        double r895287 = r895286 + r895266;
        double r895288 = r895282 * r895287;
        double r895289 = t;
        double r895290 = r895286 + r895289;
        double r895291 = r895290 + r895266;
        double r895292 = r895288 / r895291;
        double r895293 = r895281 - r895284;
        double r895294 = r895281 * r895289;
        double r895295 = fma(r895266, r895293, r895294);
        double r895296 = r895295 / r895291;
        double r895297 = r895292 + r895296;
        double r895298 = r895280 ? r895285 : r895297;
        return r895298;
}

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.3
Herbie17.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.2836464793001568e+60 or -1.0932202536774648e-278 < y < 2.135448137295958e-289 or 2.29423840239453e-41 < y

    1. Initial program 36.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 pow136.2

      \[\leadsto \frac{\color{blue}{{\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right)}^{1}}}{\left(x + t\right) + y}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity36.2

      \[\leadsto \frac{{\color{blue}{\left(1 \cdot \left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right)\right)}}^{1}}{\left(x + t\right) + y}\]
    6. Applied unpow-prod-down36.2

      \[\leadsto \frac{\color{blue}{{1}^{1} \cdot {\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right)}^{1}}}{\left(x + t\right) + y}\]
    7. Applied associate-/l*36.3

      \[\leadsto \color{blue}{\frac{{1}^{1}}{\frac{\left(x + t\right) + y}{{\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right)}^{1}}}}\]
    8. Taylor expanded around 0 20.2

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

    if -1.2836464793001568e+60 < y < -1.0932202536774648e-278 or 2.135448137295958e-289 < y < 2.29423840239453e-41

    1. Initial program 15.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 pow115.4

      \[\leadsto \frac{\color{blue}{{\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right)}^{1}}}{\left(x + t\right) + y}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity15.4

      \[\leadsto \frac{{\color{blue}{\left(1 \cdot \left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right)\right)}}^{1}}{\left(x + t\right) + y}\]
    6. Applied unpow-prod-down15.4

      \[\leadsto \frac{\color{blue}{{1}^{1} \cdot {\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right)}^{1}}}{\left(x + t\right) + y}\]
    7. Applied associate-/l*15.4

      \[\leadsto \color{blue}{\frac{{1}^{1}}{\frac{\left(x + t\right) + y}{{\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right)}^{1}}}}\]
    8. Using strategy rm
    9. Applied div-inv15.6

      \[\leadsto \frac{{1}^{1}}{\color{blue}{\left(\left(x + t\right) + y\right) \cdot \frac{1}{{\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right)}^{1}}}}\]
    10. Applied add-sqr-sqrt15.6

      \[\leadsto \frac{{\color{blue}{\left(\sqrt{1} \cdot \sqrt{1}\right)}}^{1}}{\left(\left(x + t\right) + y\right) \cdot \frac{1}{{\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right)}^{1}}}\]
    11. Applied unpow-prod-down15.6

      \[\leadsto \frac{\color{blue}{{\left(\sqrt{1}\right)}^{1} \cdot {\left(\sqrt{1}\right)}^{1}}}{\left(\left(x + t\right) + y\right) \cdot \frac{1}{{\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right)}^{1}}}\]
    12. Applied times-frac15.5

      \[\leadsto \color{blue}{\frac{{\left(\sqrt{1}\right)}^{1}}{\left(x + t\right) + y} \cdot \frac{{\left(\sqrt{1}\right)}^{1}}{\frac{1}{{\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right)}^{1}}}}\]
    13. Simplified15.5

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

      \[\leadsto \frac{1}{\left(x + t\right) + y} \cdot \color{blue}{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}\]
    15. Using strategy rm
    16. Applied fma-udef15.4

      \[\leadsto \frac{1}{\left(x + t\right) + y} \cdot \color{blue}{\left(z \cdot \left(x + y\right) + \left(\left(t + y\right) \cdot a - y \cdot b\right)\right)}\]
    17. Applied distribute-lft-in15.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.28364647930015676 \cdot 10^{60} \lor \neg \left(y \le -1.0932202536774648 \cdot 10^{-278} \lor \neg \left(y \le 2.1354481372959581 \cdot 10^{-289} \lor \neg \left(y \le 2.29423840239453002 \cdot 10^{-41}\right)\right)\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot \left(x + y\right)}{\left(x + t\right) + y} + \frac{\mathsf{fma}\left(y, a - b, a \cdot t\right)}{\left(x + t\right) + y}\\ \end{array}\]

Reproduce

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