Average Error: 27.3 → 21.0
Time: 7.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}\;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 r886673 = x;
        double r886674 = y;
        double r886675 = r886673 + r886674;
        double r886676 = z;
        double r886677 = r886675 * r886676;
        double r886678 = t;
        double r886679 = r886678 + r886674;
        double r886680 = a;
        double r886681 = r886679 * r886680;
        double r886682 = r886677 + r886681;
        double r886683 = b;
        double r886684 = r886674 * r886683;
        double r886685 = r886682 - r886684;
        double r886686 = r886673 + r886678;
        double r886687 = r886686 + r886674;
        double r886688 = r886685 / r886687;
        return r886688;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r886689 = a;
        double r886690 = -2.1110667318655525e+178;
        bool r886691 = r886689 <= r886690;
        double r886692 = y;
        double r886693 = x;
        double r886694 = t;
        double r886695 = r886693 + r886694;
        double r886696 = r886695 + r886692;
        double r886697 = b;
        double r886698 = r886696 / r886697;
        double r886699 = r886692 / r886698;
        double r886700 = r886689 - r886699;
        double r886701 = -3.344137092950427e+21;
        bool r886702 = r886689 <= r886701;
        double r886703 = r886693 + r886692;
        double r886704 = z;
        double r886705 = r886694 + r886692;
        double r886706 = r886705 * r886689;
        double r886707 = fma(r886703, r886704, r886706);
        double r886708 = 1.0;
        double r886709 = r886707 / r886708;
        double r886710 = r886709 / r886696;
        double r886711 = r886692 / r886696;
        double r886712 = r886711 * r886697;
        double r886713 = r886710 - r886712;
        double r886714 = -2.7884154681057674e-51;
        bool r886715 = r886689 <= r886714;
        double r886716 = r886704 - r886699;
        double r886717 = -6.193858000040435e-146;
        bool r886718 = r886689 <= r886717;
        double r886719 = -1.1418352270650338e-217;
        bool r886720 = r886689 <= r886719;
        double r886721 = 9.72314883776589e-29;
        bool r886722 = r886689 <= r886721;
        double r886723 = 41039768.55891173;
        bool r886724 = r886689 <= r886723;
        double r886725 = 9.987563654923616e+143;
        bool r886726 = r886689 <= r886725;
        double r886727 = r886726 ? r886713 : r886700;
        double r886728 = r886724 ? r886716 : r886727;
        double r886729 = r886722 ? r886713 : r886728;
        double r886730 = r886720 ? r886716 : r886729;
        double r886731 = r886718 ? r886713 : r886730;
        double r886732 = r886715 ? r886716 : r886731;
        double r886733 = r886702 ? r886713 : r886732;
        double r886734 = r886691 ? r886700 : r886733;
        return r886734;
}

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)))