Average Error: 27.0 → 17.4
Time: 19.9s
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.376417511233807504954447860767241687645 \cdot 10^{123}:\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{elif}\;y \le 8.886742017387841076993780424139264576187 \cdot 10^{-21}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(z, x, y \cdot \left(z - b\right)\right)\right)}}\\ \mathbf{elif}\;y \le 154639980052450147762700288:\\ \;\;\;\;z\\ \mathbf{elif}\;y \le 15954454677582262648209180778915954688:\\ \;\;\;\;\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, y \cdot \left(z - b\right)\right)\right) \cdot \frac{1}{\left(x + t\right) + y}\\ \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 -1.376417511233807504954447860767241687645 \cdot 10^{123}:\\
\;\;\;\;\left(a + z\right) - b\\

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

\mathbf{elif}\;y \le 154639980052450147762700288:\\
\;\;\;\;z\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r499423 = x;
        double r499424 = y;
        double r499425 = r499423 + r499424;
        double r499426 = z;
        double r499427 = r499425 * r499426;
        double r499428 = t;
        double r499429 = r499428 + r499424;
        double r499430 = a;
        double r499431 = r499429 * r499430;
        double r499432 = r499427 + r499431;
        double r499433 = b;
        double r499434 = r499424 * r499433;
        double r499435 = r499432 - r499434;
        double r499436 = r499423 + r499428;
        double r499437 = r499436 + r499424;
        double r499438 = r499435 / r499437;
        return r499438;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r499439 = y;
        double r499440 = -1.3764175112338075e+123;
        bool r499441 = r499439 <= r499440;
        double r499442 = a;
        double r499443 = z;
        double r499444 = r499442 + r499443;
        double r499445 = b;
        double r499446 = r499444 - r499445;
        double r499447 = 8.886742017387841e-21;
        bool r499448 = r499439 <= r499447;
        double r499449 = 1.0;
        double r499450 = x;
        double r499451 = t;
        double r499452 = r499450 + r499451;
        double r499453 = r499452 + r499439;
        double r499454 = r499451 + r499439;
        double r499455 = r499443 - r499445;
        double r499456 = r499439 * r499455;
        double r499457 = fma(r499443, r499450, r499456);
        double r499458 = fma(r499442, r499454, r499457);
        double r499459 = r499453 / r499458;
        double r499460 = r499449 / r499459;
        double r499461 = 1.5463998005245015e+26;
        bool r499462 = r499439 <= r499461;
        double r499463 = 1.5954454677582263e+37;
        bool r499464 = r499439 <= r499463;
        double r499465 = fma(r499450, r499443, r499456);
        double r499466 = fma(r499442, r499454, r499465);
        double r499467 = r499449 / r499453;
        double r499468 = r499466 * r499467;
        double r499469 = r499464 ? r499468 : r499446;
        double r499470 = r499462 ? r499443 : r499469;
        double r499471 = r499448 ? r499460 : r499470;
        double r499472 = r499441 ? r499446 : r499471;
        return r499472;
}

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.0
Target11.3
Herbie17.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.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 < -1.3764175112338075e+123 or 1.5954454677582263e+37 < y

    1. Initial program 43.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. Simplified43.3

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, y \cdot \left(z - b\right)\right)\right)}{\left(x + t\right) + y}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt43.4

      \[\leadsto \frac{\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, y \cdot \left(z - \color{blue}{\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}}\right)\right)\right)}{\left(x + t\right) + y}\]
    5. Applied add-cube-cbrt43.5

      \[\leadsto \frac{\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, y \cdot \left(\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}} - \left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}\right)\right)\right)}{\left(x + t\right) + y}\]
    6. Applied prod-diff43.5

      \[\leadsto \frac{\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, y \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt[3]{z} \cdot \sqrt[3]{z}, \sqrt[3]{z}, -\sqrt[3]{b} \cdot \left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{b}, \sqrt[3]{b} \cdot \sqrt[3]{b}, \sqrt[3]{b} \cdot \left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right)\right)\right)}\right)\right)}{\left(x + t\right) + y}\]
    7. Applied distribute-lft-in43.5

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

      \[\leadsto \frac{\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, \color{blue}{\left({\left(\sqrt[3]{z}\right)}^{3} - b\right) \cdot y} + y \cdot \mathsf{fma}\left(-\sqrt[3]{b}, \sqrt[3]{b} \cdot \sqrt[3]{b}, \sqrt[3]{b} \cdot \left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right)\right)\right)\right)}{\left(x + t\right) + y}\]
    9. Simplified43.4

      \[\leadsto \frac{\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, \left({\left(\sqrt[3]{z}\right)}^{3} - b\right) \cdot y + \color{blue}{\left(0 \cdot b\right) \cdot y}\right)\right)}{\left(x + t\right) + y}\]
    10. Using strategy rm
    11. Applied clear-num43.4

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

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

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

    if -1.3764175112338075e+123 < y < 8.886742017387841e-21

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, y \cdot \left(z - b\right)\right)\right)}{\left(x + t\right) + y}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt17.7

      \[\leadsto \frac{\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, y \cdot \left(z - \color{blue}{\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}}\right)\right)\right)}{\left(x + t\right) + y}\]
    5. Applied add-cube-cbrt17.8

      \[\leadsto \frac{\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, y \cdot \left(\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}} - \left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}\right)\right)\right)}{\left(x + t\right) + y}\]
    6. Applied prod-diff17.8

      \[\leadsto \frac{\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, y \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt[3]{z} \cdot \sqrt[3]{z}, \sqrt[3]{z}, -\sqrt[3]{b} \cdot \left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{b}, \sqrt[3]{b} \cdot \sqrt[3]{b}, \sqrt[3]{b} \cdot \left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right)\right)\right)}\right)\right)}{\left(x + t\right) + y}\]
    7. Applied distribute-lft-in17.8

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

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

      \[\leadsto \frac{\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, \left({\left(\sqrt[3]{z}\right)}^{3} - b\right) \cdot y + \color{blue}{\left(0 \cdot b\right) \cdot y}\right)\right)}{\left(x + t\right) + y}\]
    10. Using strategy rm
    11. Applied clear-num17.7

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

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

    if 8.886742017387841e-21 < y < 1.5463998005245015e+26

    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. Simplified16.9

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

      \[\leadsto \color{blue}{z}\]

    if 1.5463998005245015e+26 < y < 1.5954454677582263e+37

    1. Initial program 17.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. Simplified17.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.376417511233807504954447860767241687645 \cdot 10^{123}:\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{elif}\;y \le 8.886742017387841076993780424139264576187 \cdot 10^{-21}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(z, x, y \cdot \left(z - b\right)\right)\right)}}\\ \mathbf{elif}\;y \le 154639980052450147762700288:\\ \;\;\;\;z\\ \mathbf{elif}\;y \le 15954454677582262648209180778915954688:\\ \;\;\;\;\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, y \cdot \left(z - b\right)\right)\right) \cdot \frac{1}{\left(x + t\right) + y}\\ \mathbf{else}:\\ \;\;\;\;\left(a + z\right) - b\\ \end{array}\]

Reproduce

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