Average Error: 27.1 → 16.7
Time: 20.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}\;y \le -4.963679822741098923711711123984814712826 \cdot 10^{90}:\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{elif}\;y \le 1.495453019463623917434530780565366229939 \cdot 10^{124}:\\ \;\;\;\;\left(a \cdot \left(y + t\right) + \left(\left(x + y\right) \cdot z - y \cdot b\right)\right) \cdot \frac{1}{x + \left(y + t\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(a + z\right) - 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}\;y \le -4.963679822741098923711711123984814712826 \cdot 10^{90}:\\
\;\;\;\;\left(a + z\right) - b\\

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

\mathbf{else}:\\
\;\;\;\;\left(a + z\right) - b\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r38171889 = x;
        double r38171890 = y;
        double r38171891 = r38171889 + r38171890;
        double r38171892 = z;
        double r38171893 = r38171891 * r38171892;
        double r38171894 = t;
        double r38171895 = r38171894 + r38171890;
        double r38171896 = a;
        double r38171897 = r38171895 * r38171896;
        double r38171898 = r38171893 + r38171897;
        double r38171899 = b;
        double r38171900 = r38171890 * r38171899;
        double r38171901 = r38171898 - r38171900;
        double r38171902 = r38171889 + r38171894;
        double r38171903 = r38171902 + r38171890;
        double r38171904 = r38171901 / r38171903;
        return r38171904;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r38171905 = y;
        double r38171906 = -4.963679822741099e+90;
        bool r38171907 = r38171905 <= r38171906;
        double r38171908 = a;
        double r38171909 = z;
        double r38171910 = r38171908 + r38171909;
        double r38171911 = b;
        double r38171912 = r38171910 - r38171911;
        double r38171913 = 1.495453019463624e+124;
        bool r38171914 = r38171905 <= r38171913;
        double r38171915 = t;
        double r38171916 = r38171905 + r38171915;
        double r38171917 = r38171908 * r38171916;
        double r38171918 = x;
        double r38171919 = r38171918 + r38171905;
        double r38171920 = r38171919 * r38171909;
        double r38171921 = r38171905 * r38171911;
        double r38171922 = r38171920 - r38171921;
        double r38171923 = r38171917 + r38171922;
        double r38171924 = 1.0;
        double r38171925 = r38171918 + r38171916;
        double r38171926 = r38171924 / r38171925;
        double r38171927 = r38171923 * r38171926;
        double r38171928 = r38171914 ? r38171927 : r38171912;
        double r38171929 = r38171907 ? r38171912 : r38171928;
        return r38171929;
}

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

Original27.1
Target11.9
Herbie16.7
\[\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 2 regimes
  2. if y < -4.963679822741099e+90 or 1.495453019463624e+124 < y

    1. Initial program 46.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. Simplified46.6

      \[\leadsto \color{blue}{\frac{\left(y + t\right) \cdot a + \left(z \cdot \left(x + y\right) - b \cdot y\right)}{x + \left(y + t\right)}}\]
    3. Taylor expanded around inf 13.7

      \[\leadsto \color{blue}{\left(a + z\right) - b}\]

    if -4.963679822741099e+90 < y < 1.495453019463624e+124

    1. Initial program 18.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. Simplified18.0

      \[\leadsto \color{blue}{\frac{\left(y + t\right) \cdot a + \left(z \cdot \left(x + y\right) - b \cdot y\right)}{x + \left(y + t\right)}}\]
    3. Using strategy rm
    4. Applied div-inv18.1

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

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

Reproduce

herbie shell --seed 2019169 
(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)))