Average Error: 26.9 → 16.4
Time: 16.2s
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 -3.057173118340997 \cdot 10^{117} \lor \neg \left(y \le 7.82737282511057462 \cdot 10^{99}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\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}\\ \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 -3.057173118340997 \cdot 10^{117} \lor \neg \left(y \le 7.82737282511057462 \cdot 10^{99}\right):\\
\;\;\;\;\left(a + z\right) - b\\

\mathbf{else}:\\
\;\;\;\;\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}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r905521 = x;
        double r905522 = y;
        double r905523 = r905521 + r905522;
        double r905524 = z;
        double r905525 = r905523 * r905524;
        double r905526 = t;
        double r905527 = r905526 + r905522;
        double r905528 = a;
        double r905529 = r905527 * r905528;
        double r905530 = r905525 + r905529;
        double r905531 = b;
        double r905532 = r905522 * r905531;
        double r905533 = r905530 - r905532;
        double r905534 = r905521 + r905526;
        double r905535 = r905534 + r905522;
        double r905536 = r905533 / r905535;
        return r905536;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r905537 = y;
        double r905538 = -3.057173118340997e+117;
        bool r905539 = r905537 <= r905538;
        double r905540 = 7.827372825110575e+99;
        bool r905541 = r905537 <= r905540;
        double r905542 = !r905541;
        bool r905543 = r905539 || r905542;
        double r905544 = a;
        double r905545 = z;
        double r905546 = r905544 + r905545;
        double r905547 = b;
        double r905548 = r905546 - r905547;
        double r905549 = x;
        double r905550 = r905549 + r905537;
        double r905551 = t;
        double r905552 = r905544 - r905547;
        double r905553 = r905537 * r905552;
        double r905554 = fma(r905544, r905551, r905553);
        double r905555 = fma(r905550, r905545, r905554);
        double r905556 = r905549 + r905551;
        double r905557 = r905556 + r905537;
        double r905558 = r905555 / r905557;
        double r905559 = r905543 ? r905548 : r905558;
        return r905559;
}

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.9
Target11.8
Herbie16.4
\[\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 < -3.057173118340997e+117 or 7.827372825110575e+99 < y

    1. Initial program 45.5

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

      \[\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. Simplified45.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. Taylor expanded around 0 13.4

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

    if -3.057173118340997e+117 < y < 7.827372825110575e+99

    1. Initial program 17.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-num18.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. Simplified18.0

      \[\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 *-un-lft-identity18.0

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \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)}}}\]
    9. Applied add-cube-cbrt18.0

      \[\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, \mathsf{fma}\left(a, t, y \cdot \left(a - b\right)\right)\right)}}\]
    10. Applied times-frac18.0

      \[\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, \mathsf{fma}\left(a, t, y \cdot \left(a - b\right)\right)\right)}}}\]
    11. Simplified18.0

      \[\leadsto \color{blue}{1} \cdot \frac{\sqrt[3]{1}}{\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)}}\]
    12. Simplified17.9

      \[\leadsto 1 \cdot \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. Recombined 2 regimes into one program.
  4. Final simplification16.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -3.057173118340997 \cdot 10^{117} \lor \neg \left(y \le 7.82737282511057462 \cdot 10^{99}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\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}\\ \end{array}\]

Reproduce

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