Average Error: 26.8 → 23.1
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}\;x \le -1.51042017274667401 \cdot 10^{171}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;x \le -1.50708683770980189 \cdot 10^{134}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le -485115.40011078131:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;x \le -6.6876587271108054 \cdot 10^{-170}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le -2.860753366813772 \cdot 10^{-271}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}, \frac{1}{\left(x + t\right) + y}, -\frac{y \cdot b}{\left(x + t\right) + y}\right)\\ \mathbf{elif}\;x \le 6.7642958276510964 \cdot 10^{-203}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le 9.7109844173215245 \cdot 10^{230}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{else}:\\ \;\;\;\;z - \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}\;x \le -1.51042017274667401 \cdot 10^{171}:\\
\;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\

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

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;z - \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 r981457 = x;
        double r981458 = y;
        double r981459 = r981457 + r981458;
        double r981460 = z;
        double r981461 = r981459 * r981460;
        double r981462 = t;
        double r981463 = r981462 + r981458;
        double r981464 = a;
        double r981465 = r981463 * r981464;
        double r981466 = r981461 + r981465;
        double r981467 = b;
        double r981468 = r981458 * r981467;
        double r981469 = r981466 - r981468;
        double r981470 = r981457 + r981462;
        double r981471 = r981470 + r981458;
        double r981472 = r981469 / r981471;
        return r981472;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r981473 = x;
        double r981474 = -1.510420172746674e+171;
        bool r981475 = r981473 <= r981474;
        double r981476 = z;
        double r981477 = y;
        double r981478 = t;
        double r981479 = r981473 + r981478;
        double r981480 = r981479 + r981477;
        double r981481 = b;
        double r981482 = r981480 / r981481;
        double r981483 = r981477 / r981482;
        double r981484 = r981476 - r981483;
        double r981485 = -1.5070868377098019e+134;
        bool r981486 = r981473 <= r981485;
        double r981487 = r981473 + r981477;
        double r981488 = r981478 + r981477;
        double r981489 = a;
        double r981490 = r981488 * r981489;
        double r981491 = fma(r981487, r981476, r981490);
        double r981492 = 1.0;
        double r981493 = r981491 / r981492;
        double r981494 = r981493 / r981480;
        double r981495 = r981481 / r981480;
        double r981496 = r981477 * r981495;
        double r981497 = r981494 - r981496;
        double r981498 = -485115.4001107813;
        bool r981499 = r981473 <= r981498;
        double r981500 = -6.687658727110805e-170;
        bool r981501 = r981473 <= r981500;
        double r981502 = r981489 - r981496;
        double r981503 = -2.8607533668137723e-271;
        bool r981504 = r981473 <= r981503;
        double r981505 = r981492 / r981480;
        double r981506 = r981477 * r981481;
        double r981507 = r981506 / r981480;
        double r981508 = -r981507;
        double r981509 = fma(r981493, r981505, r981508);
        double r981510 = 6.764295827651096e-203;
        bool r981511 = r981473 <= r981510;
        double r981512 = 9.710984417321525e+230;
        bool r981513 = r981473 <= r981512;
        double r981514 = r981513 ? r981497 : r981484;
        double r981515 = r981511 ? r981502 : r981514;
        double r981516 = r981504 ? r981509 : r981515;
        double r981517 = r981501 ? r981502 : r981516;
        double r981518 = r981499 ? r981484 : r981517;
        double r981519 = r981486 ? r981497 : r981518;
        double r981520 = r981475 ? r981484 : r981519;
        return r981520;
}

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.8
Target10.8
Herbie23.1
\[\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 x < -1.510420172746674e+171 or -1.5070868377098019e+134 < x < -485115.4001107813 or 9.710984417321525e+230 < x

    1. Initial program 33.1

      \[\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-sub33.1

      \[\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. Simplified33.1

      \[\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*30.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}{\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 -1.510420172746674e+171 < x < -1.5070868377098019e+134 or 6.764295827651096e-203 < x < 9.710984417321525e+230

    1. Initial program 25.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-sub25.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. Simplified25.6

      \[\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 *-un-lft-identity25.6

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

    if -485115.4001107813 < x < -6.687658727110805e-170 or -2.8607533668137723e-271 < x < 6.764295827651096e-203

    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{\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 *-un-lft-identity23.6

      \[\leadsto \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}{\color{blue}{1 \cdot \left(\left(x + t\right) + y\right)}}\]
    7. Applied times-frac22.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}{1} \cdot \frac{b}{\left(x + t\right) + y}}\]
    8. Simplified22.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}{y} \cdot \frac{b}{\left(x + t\right) + y}\]
    9. Taylor expanded around 0 22.6

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

    if -6.687658727110805e-170 < x < -2.8607533668137723e-271

    1. Initial program 21.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-sub21.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. Simplified21.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.51042017274667401 \cdot 10^{171}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;x \le -1.50708683770980189 \cdot 10^{134}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le -485115.40011078131:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{elif}\;x \le -6.6876587271108054 \cdot 10^{-170}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le -2.860753366813772 \cdot 10^{-271}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}, \frac{1}{\left(x + t\right) + y}, -\frac{y \cdot b}{\left(x + t\right) + y}\right)\\ \mathbf{elif}\;x \le 6.7642958276510964 \cdot 10^{-203}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;x \le 9.7109844173215245 \cdot 10^{230}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{else}:\\ \;\;\;\;z - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \end{array}\]

Reproduce

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