Average Error: 26.3 → 21.5
Time: 8.5s
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}\;t \le -1.25150232717518858 \cdot 10^{200}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;t \le -4.1840463071979065 \cdot 10^{-131}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;t \le 6.63565468032893206 \cdot 10^{-276}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;t \le 5.9747624034034444 \cdot 10^{-75}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;t \le 2.51319291468979468 \cdot 10^{-6}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;t \le 3.53162670404046633 \cdot 10^{64}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{else}:\\ \;\;\;\;a - y \cdot \frac{b}{\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}\;t \le -1.25150232717518858 \cdot 10^{200}:\\
\;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\

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

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

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

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

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r817116 = x;
        double r817117 = y;
        double r817118 = r817116 + r817117;
        double r817119 = z;
        double r817120 = r817118 * r817119;
        double r817121 = t;
        double r817122 = r817121 + r817117;
        double r817123 = a;
        double r817124 = r817122 * r817123;
        double r817125 = r817120 + r817124;
        double r817126 = b;
        double r817127 = r817117 * r817126;
        double r817128 = r817125 - r817127;
        double r817129 = r817116 + r817121;
        double r817130 = r817129 + r817117;
        double r817131 = r817128 / r817130;
        return r817131;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r817132 = t;
        double r817133 = -1.2515023271751886e+200;
        bool r817134 = r817132 <= r817133;
        double r817135 = a;
        double r817136 = y;
        double r817137 = b;
        double r817138 = x;
        double r817139 = r817138 + r817132;
        double r817140 = r817139 + r817136;
        double r817141 = r817137 / r817140;
        double r817142 = r817136 * r817141;
        double r817143 = r817135 - r817142;
        double r817144 = -4.1840463071979065e-131;
        bool r817145 = r817132 <= r817144;
        double r817146 = r817138 + r817136;
        double r817147 = z;
        double r817148 = r817132 + r817136;
        double r817149 = r817148 * r817135;
        double r817150 = fma(r817146, r817147, r817149);
        double r817151 = r817150 / r817140;
        double r817152 = r817140 / r817137;
        double r817153 = r817136 / r817152;
        double r817154 = r817151 - r817153;
        double r817155 = 6.635654680328932e-276;
        bool r817156 = r817132 <= r817155;
        double r817157 = r817147 - r817142;
        double r817158 = 5.974762403403444e-75;
        bool r817159 = r817132 <= r817158;
        double r817160 = 2.5131929146897947e-06;
        bool r817161 = r817132 <= r817160;
        double r817162 = 3.5316267040404663e+64;
        bool r817163 = r817132 <= r817162;
        double r817164 = r817163 ? r817154 : r817143;
        double r817165 = r817161 ? r817157 : r817164;
        double r817166 = r817159 ? r817154 : r817165;
        double r817167 = r817156 ? r817157 : r817166;
        double r817168 = r817145 ? r817154 : r817167;
        double r817169 = r817134 ? r817143 : r817168;
        return r817169;
}

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.3
Target11.3
Herbie21.5
\[\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 t < -1.2515023271751886e+200 or 3.5316267040404663e+64 < t

    1. Initial program 34.6

      \[\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 fma-def34.6

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

      \[\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}}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity34.6

      \[\leadsto \frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y \cdot b}{\color{blue}{1 \cdot \left(\left(x + t\right) + y\right)}}\]
    8. Applied times-frac32.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}{1} \cdot \frac{b}{\left(x + t\right) + y}}\]
    9. Simplified32.0

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

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

    if -1.2515023271751886e+200 < t < -4.1840463071979065e-131 or 6.635654680328932e-276 < t < 5.974762403403444e-75 or 2.5131929146897947e-06 < t < 3.5316267040404663e+64

    1. Initial program 23.7

      \[\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 fma-def23.7

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

      \[\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}}\]
    6. Using strategy rm
    7. Applied associate-/l*21.9

      \[\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}}}\]

    if -4.1840463071979065e-131 < t < 6.635654680328932e-276 or 5.974762403403444e-75 < t < 2.5131929146897947e-06

    1. Initial program 21.7

      \[\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 fma-def21.7

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

      \[\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}}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity21.7

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -1.25150232717518858 \cdot 10^{200}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;t \le -4.1840463071979065 \cdot 10^{-131}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;t \le 6.63565468032893206 \cdot 10^{-276}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;t \le 5.9747624034034444 \cdot 10^{-75}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;t \le 2.51319291468979468 \cdot 10^{-6}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;t \le 3.53162670404046633 \cdot 10^{64}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{else}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \end{array}\]

Reproduce

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