Average Error: 26.8 → 23.1
Time: 10.1s
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 r1229180 = x;
        double r1229181 = y;
        double r1229182 = r1229180 + r1229181;
        double r1229183 = z;
        double r1229184 = r1229182 * r1229183;
        double r1229185 = t;
        double r1229186 = r1229185 + r1229181;
        double r1229187 = a;
        double r1229188 = r1229186 * r1229187;
        double r1229189 = r1229184 + r1229188;
        double r1229190 = b;
        double r1229191 = r1229181 * r1229190;
        double r1229192 = r1229189 - r1229191;
        double r1229193 = r1229180 + r1229185;
        double r1229194 = r1229193 + r1229181;
        double r1229195 = r1229192 / r1229194;
        return r1229195;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1229196 = x;
        double r1229197 = -1.510420172746674e+171;
        bool r1229198 = r1229196 <= r1229197;
        double r1229199 = z;
        double r1229200 = y;
        double r1229201 = t;
        double r1229202 = r1229196 + r1229201;
        double r1229203 = r1229202 + r1229200;
        double r1229204 = b;
        double r1229205 = r1229203 / r1229204;
        double r1229206 = r1229200 / r1229205;
        double r1229207 = r1229199 - r1229206;
        double r1229208 = -1.5070868377098019e+134;
        bool r1229209 = r1229196 <= r1229208;
        double r1229210 = r1229196 + r1229200;
        double r1229211 = r1229201 + r1229200;
        double r1229212 = a;
        double r1229213 = r1229211 * r1229212;
        double r1229214 = fma(r1229210, r1229199, r1229213);
        double r1229215 = 1.0;
        double r1229216 = r1229214 / r1229215;
        double r1229217 = r1229216 / r1229203;
        double r1229218 = r1229204 / r1229203;
        double r1229219 = r1229200 * r1229218;
        double r1229220 = r1229217 - r1229219;
        double r1229221 = -485115.4001107813;
        bool r1229222 = r1229196 <= r1229221;
        double r1229223 = -6.687658727110805e-170;
        bool r1229224 = r1229196 <= r1229223;
        double r1229225 = r1229212 - r1229219;
        double r1229226 = -2.8607533668137723e-271;
        bool r1229227 = r1229196 <= r1229226;
        double r1229228 = r1229215 / r1229203;
        double r1229229 = r1229200 * r1229204;
        double r1229230 = r1229229 / r1229203;
        double r1229231 = -r1229230;
        double r1229232 = fma(r1229216, r1229228, r1229231);
        double r1229233 = 6.764295827651096e-203;
        bool r1229234 = r1229196 <= r1229233;
        double r1229235 = 9.710984417321525e+230;
        bool r1229236 = r1229196 <= r1229235;
        double r1229237 = r1229236 ? r1229220 : r1229207;
        double r1229238 = r1229234 ? r1229225 : r1229237;
        double r1229239 = r1229227 ? r1229232 : r1229238;
        double r1229240 = r1229224 ? r1229225 : r1229239;
        double r1229241 = r1229222 ? r1229207 : r1229240;
        double r1229242 = r1229209 ? r1229220 : r1229241;
        double r1229243 = r1229198 ? r1229207 : r1229242;
        return r1229243;
}

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 *-un-lft-identity21.0

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

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

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