Average Error: 27.3 → 8.1
Time: 41.2s
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}\;\frac{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}{\left(t + x\right) + y} = -\infty:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;\frac{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}{\left(t + x\right) + y} \le 6.741673812376087 \cdot 10^{+276}:\\ \;\;\;\;\frac{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}{\left(t + x\right) + y}\\ \mathbf{else}:\\ \;\;\;\;\left(z + a\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}\;\frac{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}{\left(t + x\right) + y} = -\infty:\\
\;\;\;\;\left(z + a\right) - b\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r39079842 = x;
        double r39079843 = y;
        double r39079844 = r39079842 + r39079843;
        double r39079845 = z;
        double r39079846 = r39079844 * r39079845;
        double r39079847 = t;
        double r39079848 = r39079847 + r39079843;
        double r39079849 = a;
        double r39079850 = r39079848 * r39079849;
        double r39079851 = r39079846 + r39079850;
        double r39079852 = b;
        double r39079853 = r39079843 * r39079852;
        double r39079854 = r39079851 - r39079853;
        double r39079855 = r39079842 + r39079847;
        double r39079856 = r39079855 + r39079843;
        double r39079857 = r39079854 / r39079856;
        return r39079857;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r39079858 = a;
        double r39079859 = y;
        double r39079860 = t;
        double r39079861 = r39079859 + r39079860;
        double r39079862 = r39079858 * r39079861;
        double r39079863 = x;
        double r39079864 = r39079859 + r39079863;
        double r39079865 = z;
        double r39079866 = r39079864 * r39079865;
        double r39079867 = r39079862 + r39079866;
        double r39079868 = b;
        double r39079869 = r39079868 * r39079859;
        double r39079870 = r39079867 - r39079869;
        double r39079871 = r39079860 + r39079863;
        double r39079872 = r39079871 + r39079859;
        double r39079873 = r39079870 / r39079872;
        double r39079874 = -inf.0;
        bool r39079875 = r39079873 <= r39079874;
        double r39079876 = r39079865 + r39079858;
        double r39079877 = r39079876 - r39079868;
        double r39079878 = 6.741673812376087e+276;
        bool r39079879 = r39079873 <= r39079878;
        double r39079880 = r39079879 ? r39079873 : r39079877;
        double r39079881 = r39079875 ? r39079877 : r39079880;
        return r39079881;
}

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.3
Target11.7
Herbie8.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.0}{\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 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) < -inf.0 or 6.741673812376087e+276 < (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y))

    1. Initial program 63.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. Simplified63.1

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(z, x, \mathsf{fma}\left(a, t, \left(\left(z + a\right) - b\right) \cdot y\right)\right)}{x + \left(y + t\right)}}\]
    3. Taylor expanded around 0 18.5

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

    if -inf.0 < (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) < 6.741673812376087e+276

    1. Initial program 0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}{\left(t + x\right) + y} = -\infty:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;\frac{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}{\left(t + x\right) + y} \le 6.741673812376087 \cdot 10^{+276}:\\ \;\;\;\;\frac{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}{\left(t + x\right) + y}\\ \mathbf{else}:\\ \;\;\;\;\left(z + a\right) - b\\ \end{array}\]

Reproduce

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