Average Error: 26.0 → 23.4
Time: 15.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}\;z \le -2.0102242405280762 \cdot 10^{130}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \le -2.1108017491855503 \cdot 10^{-230}:\\ \;\;\;\;\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{elif}\;z \le -1.61947935151679149 \cdot 10^{-266}:\\ \;\;\;\;a\\ \mathbf{elif}\;z \le 2.74923524564464274 \cdot 10^{212}:\\ \;\;\;\;\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 -2.0102242405280762 \cdot 10^{130}:\\
\;\;\;\;z\\

\mathbf{elif}\;z \le -2.1108017491855503 \cdot 10^{-230}:\\
\;\;\;\;\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{elif}\;z \le -1.61947935151679149 \cdot 10^{-266}:\\
\;\;\;\;a\\

\mathbf{elif}\;z \le 2.74923524564464274 \cdot 10^{212}:\\
\;\;\;\;\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 r1064749 = x;
        double r1064750 = y;
        double r1064751 = r1064749 + r1064750;
        double r1064752 = z;
        double r1064753 = r1064751 * r1064752;
        double r1064754 = t;
        double r1064755 = r1064754 + r1064750;
        double r1064756 = a;
        double r1064757 = r1064755 * r1064756;
        double r1064758 = r1064753 + r1064757;
        double r1064759 = b;
        double r1064760 = r1064750 * r1064759;
        double r1064761 = r1064758 - r1064760;
        double r1064762 = r1064749 + r1064754;
        double r1064763 = r1064762 + r1064750;
        double r1064764 = r1064761 / r1064763;
        return r1064764;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1064765 = z;
        double r1064766 = -2.0102242405280762e+130;
        bool r1064767 = r1064765 <= r1064766;
        double r1064768 = -2.1108017491855503e-230;
        bool r1064769 = r1064765 <= r1064768;
        double r1064770 = x;
        double r1064771 = y;
        double r1064772 = r1064770 + r1064771;
        double r1064773 = r1064772 * r1064765;
        double r1064774 = t;
        double r1064775 = r1064774 + r1064771;
        double r1064776 = a;
        double r1064777 = r1064775 * r1064776;
        double r1064778 = r1064773 + r1064777;
        double r1064779 = b;
        double r1064780 = r1064771 * r1064779;
        double r1064781 = r1064778 - r1064780;
        double r1064782 = 1.0;
        double r1064783 = r1064770 + r1064774;
        double r1064784 = r1064783 + r1064771;
        double r1064785 = r1064782 / r1064784;
        double r1064786 = r1064781 * r1064785;
        double r1064787 = -1.6194793515167915e-266;
        bool r1064788 = r1064765 <= r1064787;
        double r1064789 = 2.7492352456446427e+212;
        bool r1064790 = r1064765 <= r1064789;
        double r1064791 = r1064790 ? r1064786 : r1064765;
        double r1064792 = r1064788 ? r1064776 : r1064791;
        double r1064793 = r1064769 ? r1064786 : r1064792;
        double r1064794 = r1064767 ? r1064765 : r1064793;
        return r1064794;
}

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.0
Target11.3
Herbie23.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 3 regimes
  2. if z < -2.0102242405280762e+130 or 2.7492352456446427e+212 < z

    1. Initial program 42.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 27.5

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

    if -2.0102242405280762e+130 < z < -2.1108017491855503e-230 or -1.6194793515167915e-266 < z < 2.7492352456446427e+212

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

      \[\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}}\]

    if -2.1108017491855503e-230 < z < -1.6194793515167915e-266

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

      \[\leadsto \color{blue}{a}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification23.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.0102242405280762 \cdot 10^{130}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \le -2.1108017491855503 \cdot 10^{-230}:\\ \;\;\;\;\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{elif}\;z \le -1.61947935151679149 \cdot 10^{-266}:\\ \;\;\;\;a\\ \mathbf{elif}\;z \le 2.74923524564464274 \cdot 10^{212}:\\ \;\;\;\;\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 2020045 +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)))