Average Error: 26.0 → 23.4
Time: 14.0s
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 r888772 = x;
        double r888773 = y;
        double r888774 = r888772 + r888773;
        double r888775 = z;
        double r888776 = r888774 * r888775;
        double r888777 = t;
        double r888778 = r888777 + r888773;
        double r888779 = a;
        double r888780 = r888778 * r888779;
        double r888781 = r888776 + r888780;
        double r888782 = b;
        double r888783 = r888773 * r888782;
        double r888784 = r888781 - r888783;
        double r888785 = r888772 + r888777;
        double r888786 = r888785 + r888773;
        double r888787 = r888784 / r888786;
        return r888787;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r888788 = z;
        double r888789 = -2.0102242405280762e+130;
        bool r888790 = r888788 <= r888789;
        double r888791 = -2.1108017491855503e-230;
        bool r888792 = r888788 <= r888791;
        double r888793 = x;
        double r888794 = y;
        double r888795 = r888793 + r888794;
        double r888796 = r888795 * r888788;
        double r888797 = t;
        double r888798 = r888797 + r888794;
        double r888799 = a;
        double r888800 = r888798 * r888799;
        double r888801 = r888796 + r888800;
        double r888802 = b;
        double r888803 = r888794 * r888802;
        double r888804 = r888801 - r888803;
        double r888805 = 1.0;
        double r888806 = r888793 + r888797;
        double r888807 = r888806 + r888794;
        double r888808 = r888805 / r888807;
        double r888809 = r888804 * r888808;
        double r888810 = -1.6194793515167915e-266;
        bool r888811 = r888788 <= r888810;
        double r888812 = 2.7492352456446427e+212;
        bool r888813 = r888788 <= r888812;
        double r888814 = r888813 ? r888809 : r888788;
        double r888815 = r888811 ? r888799 : r888814;
        double r888816 = r888792 ? r888809 : r888815;
        double r888817 = r888790 ? r888788 : r888816;
        return r888817;
}

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)))