Average Error: 27.0 → 21.7
Time: 7.3s
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.6986254320624221 \cdot 10^{168}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;t \le -6.3905130963088939 \cdot 10^{97}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;t \le -4.2813816300222497 \cdot 10^{92}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;t \le -2.3344990110164508 \cdot 10^{-75}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{y}{\left(x + t\right) + y}\right)\right) \cdot b\\ \mathbf{elif}\;t \le -2.103108494735924 \cdot 10^{-196}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;t \le -3.0085102585021934 \cdot 10^{-276}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}} - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{elif}\;t \le 1.6261331649776397 \cdot 10^{-101}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;t \le 2.77683352002521313 \cdot 10^{150}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{y}{\left(x + t\right) + y}\right)\right) \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}\;t \le -1.6986254320624221 \cdot 10^{168}:\\
\;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\

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

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

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

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

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

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

\mathbf{elif}\;t \le 2.77683352002521313 \cdot 10^{150}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{y}{\left(x + t\right) + y}\right)\right) \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 r1192236 = x;
        double r1192237 = y;
        double r1192238 = r1192236 + r1192237;
        double r1192239 = z;
        double r1192240 = r1192238 * r1192239;
        double r1192241 = t;
        double r1192242 = r1192241 + r1192237;
        double r1192243 = a;
        double r1192244 = r1192242 * r1192243;
        double r1192245 = r1192240 + r1192244;
        double r1192246 = b;
        double r1192247 = r1192237 * r1192246;
        double r1192248 = r1192245 - r1192247;
        double r1192249 = r1192236 + r1192241;
        double r1192250 = r1192249 + r1192237;
        double r1192251 = r1192248 / r1192250;
        return r1192251;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1192252 = t;
        double r1192253 = -1.6986254320624221e+168;
        bool r1192254 = r1192252 <= r1192253;
        double r1192255 = a;
        double r1192256 = y;
        double r1192257 = x;
        double r1192258 = r1192257 + r1192252;
        double r1192259 = r1192258 + r1192256;
        double r1192260 = b;
        double r1192261 = r1192259 / r1192260;
        double r1192262 = r1192256 / r1192261;
        double r1192263 = r1192255 - r1192262;
        double r1192264 = -6.390513096308894e+97;
        bool r1192265 = r1192252 <= r1192264;
        double r1192266 = z;
        double r1192267 = r1192266 - r1192262;
        double r1192268 = -4.2813816300222497e+92;
        bool r1192269 = r1192252 <= r1192268;
        double r1192270 = -2.334499011016451e-75;
        bool r1192271 = r1192252 <= r1192270;
        double r1192272 = r1192257 + r1192256;
        double r1192273 = r1192252 + r1192256;
        double r1192274 = r1192273 * r1192255;
        double r1192275 = fma(r1192272, r1192266, r1192274);
        double r1192276 = 1.0;
        double r1192277 = r1192275 / r1192276;
        double r1192278 = r1192277 / r1192259;
        double r1192279 = r1192256 / r1192259;
        double r1192280 = log1p(r1192279);
        double r1192281 = expm1(r1192280);
        double r1192282 = r1192281 * r1192260;
        double r1192283 = r1192278 - r1192282;
        double r1192284 = -2.103108494735924e-196;
        bool r1192285 = r1192252 <= r1192284;
        double r1192286 = -3.0085102585021934e-276;
        bool r1192287 = r1192252 <= r1192286;
        double r1192288 = r1192259 / r1192275;
        double r1192289 = r1192276 / r1192288;
        double r1192290 = r1192279 * r1192260;
        double r1192291 = r1192289 - r1192290;
        double r1192292 = 1.6261331649776397e-101;
        bool r1192293 = r1192252 <= r1192292;
        double r1192294 = 2.776833520025213e+150;
        bool r1192295 = r1192252 <= r1192294;
        double r1192296 = r1192295 ? r1192283 : r1192263;
        double r1192297 = r1192293 ? r1192267 : r1192296;
        double r1192298 = r1192287 ? r1192291 : r1192297;
        double r1192299 = r1192285 ? r1192267 : r1192298;
        double r1192300 = r1192271 ? r1192283 : r1192299;
        double r1192301 = r1192269 ? r1192263 : r1192300;
        double r1192302 = r1192265 ? r1192267 : r1192301;
        double r1192303 = r1192254 ? r1192263 : r1192302;
        return r1192303;
}

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.5
Herbie21.7
\[\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 4 regimes
  2. if t < -1.6986254320624221e+168 or -6.390513096308894e+97 < t < -4.2813816300222497e+92 or 2.776833520025213e+150 < t

    1. Initial program 35.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-sub35.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. Simplified35.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*33.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 21.3

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

    if -1.6986254320624221e+168 < t < -6.390513096308894e+97 or -2.334499011016451e-75 < t < -2.103108494735924e-196 or -3.0085102585021934e-276 < t < 1.6261331649776397e-101

    1. Initial program 24.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 div-sub24.7

      \[\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. Simplified24.7

      \[\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*23.4

      \[\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 23.8

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

    if -4.2813816300222497e+92 < t < -2.334499011016451e-75 or 1.6261331649776397e-101 < t < 2.776833520025213e+150

    1. Initial program 23.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. Using strategy rm
    3. Applied div-sub23.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. Simplified23.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*20.3

      \[\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/20.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}\]
    9. Using strategy rm
    10. Applied expm1-log1p-u20.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}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{y}{\left(x + t\right) + y}\right)\right)} \cdot b\]

    if -2.103108494735924e-196 < t < -3.0085102585021934e-276

    1. Initial program 24.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-sub24.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. Simplified24.5

      \[\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*22.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/20.4

      \[\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}\]
    9. Using strategy rm
    10. Applied clear-num20.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -1.6986254320624221 \cdot 10^{168}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;t \le -6.3905130963088939 \cdot 10^{97}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;t \le -4.2813816300222497 \cdot 10^{92}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;t \le -2.3344990110164508 \cdot 10^{-75}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{y}{\left(x + t\right) + y}\right)\right) \cdot b\\ \mathbf{elif}\;t \le -2.103108494735924 \cdot 10^{-196}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;t \le -3.0085102585021934 \cdot 10^{-276}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}} - \frac{y}{\left(x + t\right) + y} \cdot b\\ \mathbf{elif}\;t \le 1.6261331649776397 \cdot 10^{-101}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;t \le 2.77683352002521313 \cdot 10^{150}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{y}{\left(x + t\right) + y}\right)\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;a - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \end{array}\]

Reproduce

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