Average Error: 26.7 → 21.4
Time: 6.4s
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}\;z \le -5.7064454628396416 \cdot 10^{113}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \le 6.7517803750987954 \cdot 10^{-172}:\\ \;\;\;\;\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right) \cdot \frac{1}{\left(x + t\right) + y} - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;z \le 4.59633073358905232 \cdot 10^{-89}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;z \le 9.2007045395479632 \cdot 10^{79}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{else}:\\ \;\;\;\;z\\ \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}\;z \le -5.7064454628396416 \cdot 10^{113}:\\
\;\;\;\;z\\

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

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

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

\mathbf{else}:\\
\;\;\;\;z\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r1013000 = x;
        double r1013001 = y;
        double r1013002 = r1013000 + r1013001;
        double r1013003 = z;
        double r1013004 = r1013002 * r1013003;
        double r1013005 = t;
        double r1013006 = r1013005 + r1013001;
        double r1013007 = a;
        double r1013008 = r1013006 * r1013007;
        double r1013009 = r1013004 + r1013008;
        double r1013010 = b;
        double r1013011 = r1013001 * r1013010;
        double r1013012 = r1013009 - r1013011;
        double r1013013 = r1013000 + r1013005;
        double r1013014 = r1013013 + r1013001;
        double r1013015 = r1013012 / r1013014;
        return r1013015;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1013016 = z;
        double r1013017 = -5.7064454628396416e+113;
        bool r1013018 = r1013016 <= r1013017;
        double r1013019 = 6.751780375098795e-172;
        bool r1013020 = r1013016 <= r1013019;
        double r1013021 = x;
        double r1013022 = y;
        double r1013023 = r1013021 + r1013022;
        double r1013024 = t;
        double r1013025 = r1013024 + r1013022;
        double r1013026 = a;
        double r1013027 = r1013025 * r1013026;
        double r1013028 = fma(r1013023, r1013016, r1013027);
        double r1013029 = 1.0;
        double r1013030 = r1013021 + r1013024;
        double r1013031 = r1013030 + r1013022;
        double r1013032 = r1013029 / r1013031;
        double r1013033 = r1013028 * r1013032;
        double r1013034 = b;
        double r1013035 = r1013034 / r1013031;
        double r1013036 = r1013022 * r1013035;
        double r1013037 = r1013033 - r1013036;
        double r1013038 = 4.596330733589052e-89;
        bool r1013039 = r1013016 <= r1013038;
        double r1013040 = r1013026 - r1013036;
        double r1013041 = 9.200704539547963e+79;
        bool r1013042 = r1013016 <= r1013041;
        double r1013043 = r1013028 / r1013029;
        double r1013044 = r1013043 / r1013031;
        double r1013045 = r1013031 / r1013034;
        double r1013046 = r1013022 / r1013045;
        double r1013047 = r1013044 - r1013046;
        double r1013048 = r1013042 ? r1013047 : r1013016;
        double r1013049 = r1013039 ? r1013040 : r1013048;
        double r1013050 = r1013020 ? r1013037 : r1013049;
        double r1013051 = r1013018 ? r1013016 : r1013050;
        return r1013051;
}

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.7
Target11.5
Herbie21.4
\[\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 z < -5.7064454628396416e+113 or 9.200704539547963e+79 < z

    1. Initial program 40.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. Taylor expanded around inf 29.0

      \[\leadsto \color{blue}{z}\]

    if -5.7064454628396416e+113 < z < 6.751780375098795e-172

    1. Initial program 19.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-sub19.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. Simplified19.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 *-un-lft-identity19.5

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

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

      \[\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. Using strategy rm
    10. Applied *-un-lft-identity16.6

      \[\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)}} - y \cdot \frac{b}{\left(x + t\right) + y}\]
    11. Applied div-inv16.6

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

      \[\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}} - y \cdot \frac{b}{\left(x + t\right) + y}\]
    13. Simplified16.7

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

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

    if 6.751780375098795e-172 < z < 4.596330733589052e-89

    1. Initial program 18.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-sub18.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. Simplified18.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 *-un-lft-identity18.1

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

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

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

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

    if 4.596330733589052e-89 < z < 9.200704539547963e+79

    1. Initial program 20.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-sub20.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. Simplified20.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 associate-/l*17.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}}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification21.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.7064454628396416 \cdot 10^{113}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \le 6.7517803750987954 \cdot 10^{-172}:\\ \;\;\;\;\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right) \cdot \frac{1}{\left(x + t\right) + y} - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;z \le 4.59633073358905232 \cdot 10^{-89}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;z \le 9.2007045395479632 \cdot 10^{79}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y}{\frac{\left(x + t\right) + y}{b}}\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array}\]

Reproduce

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