Average Error: 24.9 → 7.5
Time: 20.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}\;\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 1.5983951554988548 \cdot 10^{+248}:\\ \;\;\;\;\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 1.5983951554988548 \cdot 10^{+248}:\\
\;\;\;\;\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 r37849604 = x;
        double r37849605 = y;
        double r37849606 = r37849604 + r37849605;
        double r37849607 = z;
        double r37849608 = r37849606 * r37849607;
        double r37849609 = t;
        double r37849610 = r37849609 + r37849605;
        double r37849611 = a;
        double r37849612 = r37849610 * r37849611;
        double r37849613 = r37849608 + r37849612;
        double r37849614 = b;
        double r37849615 = r37849605 * r37849614;
        double r37849616 = r37849613 - r37849615;
        double r37849617 = r37849604 + r37849609;
        double r37849618 = r37849617 + r37849605;
        double r37849619 = r37849616 / r37849618;
        return r37849619;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r37849620 = a;
        double r37849621 = y;
        double r37849622 = t;
        double r37849623 = r37849621 + r37849622;
        double r37849624 = r37849620 * r37849623;
        double r37849625 = x;
        double r37849626 = r37849621 + r37849625;
        double r37849627 = z;
        double r37849628 = r37849626 * r37849627;
        double r37849629 = r37849624 + r37849628;
        double r37849630 = b;
        double r37849631 = r37849630 * r37849621;
        double r37849632 = r37849629 - r37849631;
        double r37849633 = r37849622 + r37849625;
        double r37849634 = r37849633 + r37849621;
        double r37849635 = r37849632 / r37849634;
        double r37849636 = -inf.0;
        bool r37849637 = r37849635 <= r37849636;
        double r37849638 = r37849627 + r37849620;
        double r37849639 = r37849638 - r37849630;
        double r37849640 = 1.5983951554988548e+248;
        bool r37849641 = r37849635 <= r37849640;
        double r37849642 = r37849641 ? r37849635 : r37849639;
        double r37849643 = r37849637 ? r37849639 : r37849642;
        return r37849643;
}

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

Original24.9
Target11.4
Herbie7.5
\[\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 2 regimes
  2. if (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) < -inf.0 or 1.5983951554988548e+248 < (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y))

    1. Initial program 58.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. Simplified58.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 17.1

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

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

    1. Initial program 0.4

      \[\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 simplification7.5

    \[\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 1.5983951554988548 \cdot 10^{+248}:\\ \;\;\;\;\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 2019162 +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 (/ (+ (+ 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)))