Average Error: 26.1 → 23.0
Time: 27.8s
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 -1.4182932798752201 \cdot 10^{113}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \le 5.47482891811364839 \cdot 10^{163}:\\ \;\;\;\;\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right) \cdot \frac{1}{\left(x + t\right) + y}\\ \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 -1.4182932798752201 \cdot 10^{113}:\\
\;\;\;\;z\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r669016 = x;
        double r669017 = y;
        double r669018 = r669016 + r669017;
        double r669019 = z;
        double r669020 = r669018 * r669019;
        double r669021 = t;
        double r669022 = r669021 + r669017;
        double r669023 = a;
        double r669024 = r669022 * r669023;
        double r669025 = r669020 + r669024;
        double r669026 = b;
        double r669027 = r669017 * r669026;
        double r669028 = r669025 - r669027;
        double r669029 = r669016 + r669021;
        double r669030 = r669029 + r669017;
        double r669031 = r669028 / r669030;
        return r669031;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r669032 = z;
        double r669033 = -1.4182932798752201e+113;
        bool r669034 = r669032 <= r669033;
        double r669035 = 5.4748289181136484e+163;
        bool r669036 = r669032 <= r669035;
        double r669037 = x;
        double r669038 = y;
        double r669039 = r669037 + r669038;
        double r669040 = r669039 * r669032;
        double r669041 = t;
        double r669042 = r669041 + r669038;
        double r669043 = a;
        double r669044 = r669042 * r669043;
        double r669045 = r669040 + r669044;
        double r669046 = b;
        double r669047 = r669038 * r669046;
        double r669048 = r669045 - r669047;
        double r669049 = 1.0;
        double r669050 = r669037 + r669041;
        double r669051 = r669050 + r669038;
        double r669052 = r669049 / r669051;
        double r669053 = r669048 * r669052;
        double r669054 = r669036 ? r669053 : r669032;
        double r669055 = r669034 ? r669032 : r669054;
        return r669055;
}

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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original26.1
Target11.4
Herbie23.0
\[\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 2 regimes
  2. if z < -1.4182932798752201e+113 or 5.4748289181136484e+163 < z

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

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

    if -1.4182932798752201e+113 < z < 5.4748289181136484e+163

    1. Initial program 20.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-inv21.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.4182932798752201 \cdot 10^{113}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \le 5.47482891811364839 \cdot 10^{163}:\\ \;\;\;\;\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right) \cdot \frac{1}{\left(x + t\right) + y}\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array}\]

Reproduce

herbie shell --seed 2019198 +o rules:numerics
(FPCore (x y z t a b)
  :name "AI.Clustering.Hierarchical.Internal:ward from clustering-0.2.1"

  :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.0 (/ (+ (+ 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)))