Average Error: 27.3 → 21.0
Time: 8.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}\;a \le -2.111066731865552478060237903452713090318 \cdot 10^{178}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;a \le -3344137092950426910720:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{elif}\;a \le -2.788415468105767438847664484391119198398 \cdot 10^{-51}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;a \le -6.193858000040435257723437786353755699455 \cdot 10^{-146}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{elif}\;a \le -1.141835227065033822326419932961804639532 \cdot 10^{-217}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;a \le 9.723148837765889764688987845110578988326 \cdot 10^{-29}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{elif}\;a \le 41039768.558911733329296112060546875:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;a \le 9.987563654923615629307058833077917765152 \cdot 10^{143}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{else}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{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}\;a \le -2.111066731865552478060237903452713090318 \cdot 10^{178}:\\
\;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\

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

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

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

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

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

\mathbf{elif}\;a \le 41039768.558911733329296112060546875:\\
\;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r1089576 = x;
        double r1089577 = y;
        double r1089578 = r1089576 + r1089577;
        double r1089579 = z;
        double r1089580 = r1089578 * r1089579;
        double r1089581 = t;
        double r1089582 = r1089581 + r1089577;
        double r1089583 = a;
        double r1089584 = r1089582 * r1089583;
        double r1089585 = r1089580 + r1089584;
        double r1089586 = b;
        double r1089587 = r1089577 * r1089586;
        double r1089588 = r1089585 - r1089587;
        double r1089589 = r1089576 + r1089581;
        double r1089590 = r1089589 + r1089577;
        double r1089591 = r1089588 / r1089590;
        return r1089591;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1089592 = a;
        double r1089593 = -2.1110667318655525e+178;
        bool r1089594 = r1089592 <= r1089593;
        double r1089595 = y;
        double r1089596 = x;
        double r1089597 = t;
        double r1089598 = r1089596 + r1089597;
        double r1089599 = r1089598 + r1089595;
        double r1089600 = b;
        double r1089601 = r1089599 / r1089600;
        double r1089602 = r1089595 / r1089601;
        double r1089603 = r1089592 - r1089602;
        double r1089604 = -3.344137092950427e+21;
        bool r1089605 = r1089592 <= r1089604;
        double r1089606 = r1089596 + r1089595;
        double r1089607 = z;
        double r1089608 = r1089597 + r1089595;
        double r1089609 = r1089608 * r1089592;
        double r1089610 = fma(r1089606, r1089607, r1089609);
        double r1089611 = 1.0;
        double r1089612 = r1089610 / r1089611;
        double r1089613 = r1089612 / r1089599;
        double r1089614 = r1089595 / r1089599;
        double r1089615 = r1089614 * r1089600;
        double r1089616 = r1089613 - r1089615;
        double r1089617 = -2.7884154681057674e-51;
        bool r1089618 = r1089592 <= r1089617;
        double r1089619 = r1089607 - r1089602;
        double r1089620 = -6.193858000040435e-146;
        bool r1089621 = r1089592 <= r1089620;
        double r1089622 = -1.1418352270650338e-217;
        bool r1089623 = r1089592 <= r1089622;
        double r1089624 = 9.72314883776589e-29;
        bool r1089625 = r1089592 <= r1089624;
        double r1089626 = 41039768.55891173;
        bool r1089627 = r1089592 <= r1089626;
        double r1089628 = 9.987563654923616e+143;
        bool r1089629 = r1089592 <= r1089628;
        double r1089630 = r1089629 ? r1089616 : r1089603;
        double r1089631 = r1089627 ? r1089619 : r1089630;
        double r1089632 = r1089625 ? r1089616 : r1089631;
        double r1089633 = r1089623 ? r1089619 : r1089632;
        double r1089634 = r1089621 ? r1089616 : r1089633;
        double r1089635 = r1089618 ? r1089619 : r1089634;
        double r1089636 = r1089605 ? r1089616 : r1089635;
        double r1089637 = r1089594 ? r1089603 : r1089636;
        return r1089637;
}

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.3
Target11.4
Herbie21.0
\[\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 3 regimes
  2. if a < -2.1110667318655525e+178 or 9.987563654923616e+143 < a

    1. Initial program 43.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 div-sub43.2

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

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

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

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

    if -2.1110667318655525e+178 < a < -3.344137092950427e+21 or -2.7884154681057674e-51 < a < -6.193858000040435e-146 or -1.1418352270650338e-217 < a < 9.72314883776589e-29 or 41039768.55891173 < a < 9.987563654923616e+143

    1. Initial program 23.0

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

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

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

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

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

    if -3.344137092950427e+21 < a < -2.7884154681057674e-51 or -6.193858000040435e-146 < a < -1.1418352270650338e-217 or 9.72314883776589e-29 < a < 41039768.55891173

    1. Initial program 18.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-sub18.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. Simplified18.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -2.111066731865552478060237903452713090318 \cdot 10^{178}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;a \le -3344137092950426910720:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{elif}\;a \le -2.788415468105767438847664484391119198398 \cdot 10^{-51}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;a \le -6.193858000040435257723437786353755699455 \cdot 10^{-146}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{elif}\;a \le -1.141835227065033822326419932961804639532 \cdot 10^{-217}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;a \le 9.723148837765889764688987845110578988326 \cdot 10^{-29}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{elif}\;a \le 41039768.558911733329296112060546875:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;a \le 9.987563654923615629307058833077917765152 \cdot 10^{143}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{else}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \end{array}\]

Reproduce

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