Average Error: 26.8 → 19.6
Time: 25.0s
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}\;z \le -3.8781444753116508 \cdot 10^{76}:\\ \;\;\;\;z - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{elif}\;z \le -1.331450716195835 \cdot 10^{-231}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{elif}\;z \le 7.62480360204854082 \cdot 10^{-203}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;z \le 7.11326089674771819 \cdot 10^{108}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{else}:\\ \;\;\;\;z - \frac{y}{\left(x + t\right) + y} \cdot 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}\;z \le -3.8781444753116508 \cdot 10^{76}:\\
\;\;\;\;z - \frac{y}{\left(x + t\right) + y} \cdot b\\

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

\mathbf{elif}\;z \le 7.62480360204854082 \cdot 10^{-203}:\\
\;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r570565 = x;
        double r570566 = y;
        double r570567 = r570565 + r570566;
        double r570568 = z;
        double r570569 = r570567 * r570568;
        double r570570 = t;
        double r570571 = r570570 + r570566;
        double r570572 = a;
        double r570573 = r570571 * r570572;
        double r570574 = r570569 + r570573;
        double r570575 = b;
        double r570576 = r570566 * r570575;
        double r570577 = r570574 - r570576;
        double r570578 = r570565 + r570570;
        double r570579 = r570578 + r570566;
        double r570580 = r570577 / r570579;
        return r570580;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r570581 = z;
        double r570582 = -3.878144475311651e+76;
        bool r570583 = r570581 <= r570582;
        double r570584 = y;
        double r570585 = x;
        double r570586 = t;
        double r570587 = r570585 + r570586;
        double r570588 = r570587 + r570584;
        double r570589 = r570584 / r570588;
        double r570590 = b;
        double r570591 = r570589 * r570590;
        double r570592 = r570581 - r570591;
        double r570593 = -1.331450716195835e-231;
        bool r570594 = r570581 <= r570593;
        double r570595 = r570585 + r570584;
        double r570596 = r570586 + r570584;
        double r570597 = a;
        double r570598 = r570596 * r570597;
        double r570599 = fma(r570595, r570581, r570598);
        double r570600 = r570599 / r570588;
        double r570601 = r570600 - r570591;
        double r570602 = 7.624803602048541e-203;
        bool r570603 = r570581 <= r570602;
        double r570604 = r570588 / r570590;
        double r570605 = r570584 / r570604;
        double r570606 = r570597 - r570605;
        double r570607 = 7.113260896747718e+108;
        bool r570608 = r570581 <= r570607;
        double r570609 = r570608 ? r570601 : r570592;
        double r570610 = r570603 ? r570606 : r570609;
        double r570611 = r570594 ? r570601 : r570610;
        double r570612 = r570583 ? r570592 : r570611;
        return r570612;
}

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.8
Target11.3
Herbie19.6
\[\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 3 regimes
  2. if z < -3.878144475311651e+76 or 7.113260896747718e+108 < z

    1. Initial program 40.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 div-sub40.4

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}} - \frac{y \cdot b}{\left(x + t\right) + y}\]
    5. Using strategy rm
    6. Applied associate-/l*40.5

      \[\leadsto \frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \color{blue}{\frac{y}{\frac{\left(x + t\right) + y}{b}}}\]
    7. Using strategy rm
    8. Applied associate-/r/39.7

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

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

    if -3.878144475311651e+76 < z < -1.331450716195835e-231 or 7.624803602048541e-203 < z < 7.113260896747718e+108

    1. Initial program 20.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. Using strategy rm
    3. Applied div-sub20.3

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}} - \frac{y \cdot b}{\left(x + t\right) + y}\]
    5. Using strategy rm
    6. Applied associate-/l*16.6

      \[\leadsto \frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \color{blue}{\frac{y}{\frac{\left(x + t\right) + y}{b}}}\]
    7. Using strategy rm
    8. Applied associate-/r/16.0

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

    if -1.331450716195835e-231 < z < 7.624803602048541e-203

    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. Using strategy rm
    3. Applied div-sub17.5

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}} - \frac{y \cdot b}{\left(x + t\right) + y}\]
    5. Using strategy rm
    6. Applied associate-/l*15.0

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

      \[\leadsto \color{blue}{a} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification19.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.8781444753116508 \cdot 10^{76}:\\ \;\;\;\;z - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{elif}\;z \le -1.331450716195835 \cdot 10^{-231}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{elif}\;z \le 7.62480360204854082 \cdot 10^{-203}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;z \le 7.11326089674771819 \cdot 10^{108}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{else}:\\ \;\;\;\;z - \frac{y}{\left(x + t\right) + y} \cdot b\\ \end{array}\]

Reproduce

herbie shell --seed 2019199 +o rules:numerics
(FPCore (x y z t a b)
  :name "AI.Clustering.Hierarchical.Internal:ward from clustering-0.2.1"

  :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.0 (/ (+ (+ 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)))