Average Error: 27.2 → 21.3
Time: 20.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}\;x \le -1.343517699116082085988013028938453324825 \cdot 10^{182}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le -1.375028386241234800074588117756530326546 \cdot 10^{-50}:\\ \;\;\;\;\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}\;x \le -1.118643715046927542610803400339886881246 \cdot 10^{-149}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le -1.16974325889302484717093484562260440578 \cdot 10^{-281}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{\frac{y}{\left(x + t\right) + y}}{\frac{1}{b}}\\ \mathbf{elif}\;x \le 1.110981286409301297083753758046103104188 \cdot 10^{-125}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le 7.771333049681687694819501234115560782491 \cdot 10^{171}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}} - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{else}:\\ \;\;\;\;z - 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}\;x \le -1.343517699116082085988013028938453324825 \cdot 10^{182}:\\
\;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\

\mathbf{elif}\;x \le -1.375028386241234800074588117756530326546 \cdot 10^{-50}:\\
\;\;\;\;\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}\;x \le -1.118643715046927542610803400339886881246 \cdot 10^{-149}:\\
\;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;z - 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 r546293 = x;
        double r546294 = y;
        double r546295 = r546293 + r546294;
        double r546296 = z;
        double r546297 = r546295 * r546296;
        double r546298 = t;
        double r546299 = r546298 + r546294;
        double r546300 = a;
        double r546301 = r546299 * r546300;
        double r546302 = r546297 + r546301;
        double r546303 = b;
        double r546304 = r546294 * r546303;
        double r546305 = r546302 - r546304;
        double r546306 = r546293 + r546298;
        double r546307 = r546306 + r546294;
        double r546308 = r546305 / r546307;
        return r546308;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r546309 = x;
        double r546310 = -1.343517699116082e+182;
        bool r546311 = r546309 <= r546310;
        double r546312 = z;
        double r546313 = y;
        double r546314 = b;
        double r546315 = t;
        double r546316 = r546309 + r546315;
        double r546317 = r546316 + r546313;
        double r546318 = r546314 / r546317;
        double r546319 = r546313 * r546318;
        double r546320 = r546312 - r546319;
        double r546321 = -1.3750283862412348e-50;
        bool r546322 = r546309 <= r546321;
        double r546323 = r546309 + r546313;
        double r546324 = r546315 + r546313;
        double r546325 = a;
        double r546326 = r546324 * r546325;
        double r546327 = fma(r546323, r546312, r546326);
        double r546328 = r546327 / r546317;
        double r546329 = r546317 / r546314;
        double r546330 = r546313 / r546329;
        double r546331 = r546328 - r546330;
        double r546332 = -1.1186437150469275e-149;
        bool r546333 = r546309 <= r546332;
        double r546334 = r546325 - r546319;
        double r546335 = -1.1697432588930248e-281;
        bool r546336 = r546309 <= r546335;
        double r546337 = r546313 / r546317;
        double r546338 = 1.0;
        double r546339 = r546338 / r546314;
        double r546340 = r546337 / r546339;
        double r546341 = r546328 - r546340;
        double r546342 = 1.1109812864093013e-125;
        bool r546343 = r546309 <= r546342;
        double r546344 = 7.771333049681688e+171;
        bool r546345 = r546309 <= r546344;
        double r546346 = r546317 / r546327;
        double r546347 = r546338 / r546346;
        double r546348 = r546347 - r546319;
        double r546349 = r546345 ? r546348 : r546320;
        double r546350 = r546343 ? r546334 : r546349;
        double r546351 = r546336 ? r546341 : r546350;
        double r546352 = r546333 ? r546334 : r546351;
        double r546353 = r546322 ? r546331 : r546352;
        double r546354 = r546311 ? r546320 : r546353;
        return r546354;
}

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.2
Target11.6
Herbie21.3
\[\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 5 regimes
  2. if x < -1.343517699116082e+182 or 7.771333049681688e+171 < x

    1. Initial program 37.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-sub37.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. Simplified37.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 *-un-lft-identity37.3

      \[\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)}}\]
    7. Applied times-frac34.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}{1} \cdot \frac{b}{\left(x + t\right) + y}}\]
    8. Simplified34.7

      \[\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}\]
    9. Taylor expanded around inf 20.8

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

    if -1.343517699116082e+182 < x < -1.3750283862412348e-50

    1. Initial program 26.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-sub26.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. Simplified26.2

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

      \[\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 -1.3750283862412348e-50 < x < -1.1186437150469275e-149 or -1.1697432588930248e-281 < x < 1.1109812864093013e-125

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

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

      \[\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 *-un-lft-identity24.0

      \[\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)}}\]
    7. Applied times-frac21.8

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

      \[\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}\]
    9. Taylor expanded around 0 21.0

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

    if -1.1186437150469275e-149 < x < -1.1697432588930248e-281

    1. Initial program 23.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-sub23.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. Simplified23.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*22.4

      \[\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 div-inv22.5

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

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

    if 1.1109812864093013e-125 < x < 7.771333049681688e+171

    1. Initial program 23.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 div-sub23.6

      \[\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.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}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity23.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)}}\]
    7. Applied times-frac21.1

      \[\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}}\]
    8. Simplified21.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.343517699116082085988013028938453324825 \cdot 10^{182}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le -1.375028386241234800074588117756530326546 \cdot 10^{-50}:\\ \;\;\;\;\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}\;x \le -1.118643715046927542610803400339886881246 \cdot 10^{-149}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le -1.16974325889302484717093484562260440578 \cdot 10^{-281}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y} - \frac{\frac{y}{\left(x + t\right) + y}}{\frac{1}{b}}\\ \mathbf{elif}\;x \le 1.110981286409301297083753758046103104188 \cdot 10^{-125}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le 7.771333049681687694819501234115560782491 \cdot 10^{171}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}} - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{else}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \end{array}\]

Reproduce

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