Average Error: 27.0 → 16.0
Time: 19.6s
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 -1.377781447530395283080383565792233554007 \cdot 10^{49}:\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{elif}\;y \le 2.740519347061663533893075988126946093752 \cdot 10^{102}:\\ \;\;\;\;\frac{1}{\left(t + y\right) + x} \cdot \left(\left(z \cdot \left(y + x\right) + a \cdot \left(t + y\right)\right) - y \cdot b\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 -1.377781447530395283080383565792233554007 \cdot 10^{49}:\\
\;\;\;\;\left(a + z\right) - b\\

\mathbf{elif}\;y \le 2.740519347061663533893075988126946093752 \cdot 10^{102}:\\
\;\;\;\;\frac{1}{\left(t + y\right) + x} \cdot \left(\left(z \cdot \left(y + x\right) + a \cdot \left(t + y\right)\right) - y \cdot b\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 r40336819 = x;
        double r40336820 = y;
        double r40336821 = r40336819 + r40336820;
        double r40336822 = z;
        double r40336823 = r40336821 * r40336822;
        double r40336824 = t;
        double r40336825 = r40336824 + r40336820;
        double r40336826 = a;
        double r40336827 = r40336825 * r40336826;
        double r40336828 = r40336823 + r40336827;
        double r40336829 = b;
        double r40336830 = r40336820 * r40336829;
        double r40336831 = r40336828 - r40336830;
        double r40336832 = r40336819 + r40336824;
        double r40336833 = r40336832 + r40336820;
        double r40336834 = r40336831 / r40336833;
        return r40336834;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r40336835 = y;
        double r40336836 = -1.3777814475303953e+49;
        bool r40336837 = r40336835 <= r40336836;
        double r40336838 = a;
        double r40336839 = z;
        double r40336840 = r40336838 + r40336839;
        double r40336841 = b;
        double r40336842 = r40336840 - r40336841;
        double r40336843 = 2.7405193470616635e+102;
        bool r40336844 = r40336835 <= r40336843;
        double r40336845 = 1.0;
        double r40336846 = t;
        double r40336847 = r40336846 + r40336835;
        double r40336848 = x;
        double r40336849 = r40336847 + r40336848;
        double r40336850 = r40336845 / r40336849;
        double r40336851 = r40336835 + r40336848;
        double r40336852 = r40336839 * r40336851;
        double r40336853 = r40336838 * r40336847;
        double r40336854 = r40336852 + r40336853;
        double r40336855 = r40336835 * r40336841;
        double r40336856 = r40336854 - r40336855;
        double r40336857 = r40336850 * r40336856;
        double r40336858 = r40336844 ? r40336857 : r40336842;
        double r40336859 = r40336837 ? r40336842 : r40336858;
        return r40336859;
}

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.0
Target11.3
Herbie16.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.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 < -1.3777814475303953e+49 or 2.7405193470616635e+102 < y

    1. Initial program 43.2

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
    2. Simplified43.2

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

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

    if -1.3777814475303953e+49 < y < 2.7405193470616635e+102

    1. Initial program 17.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. Simplified17.1

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

      \[\leadsto \color{blue}{\frac{1}{\frac{x + \left(y + t\right)}{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}}}\]
    5. Using strategy rm
    6. Applied associate-/r/17.2

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

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

Reproduce

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