Average Error: 26.3 → 17.3
Time: 18.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}\;y \le -1.243078244809433359419741519989651106527 \cdot 10^{-52}:\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{elif}\;y \le 4617794.309636129997670650482177734375:\\ \;\;\;\;\frac{\left(\left(x + y\right) \cdot z + a \cdot \left(y + t\right)\right) - y \cdot b}{\left(y + t\right) + x}\\ \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.243078244809433359419741519989651106527 \cdot 10^{-52}:\\
\;\;\;\;\left(a + z\right) - b\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r42543669 = x;
        double r42543670 = y;
        double r42543671 = r42543669 + r42543670;
        double r42543672 = z;
        double r42543673 = r42543671 * r42543672;
        double r42543674 = t;
        double r42543675 = r42543674 + r42543670;
        double r42543676 = a;
        double r42543677 = r42543675 * r42543676;
        double r42543678 = r42543673 + r42543677;
        double r42543679 = b;
        double r42543680 = r42543670 * r42543679;
        double r42543681 = r42543678 - r42543680;
        double r42543682 = r42543669 + r42543674;
        double r42543683 = r42543682 + r42543670;
        double r42543684 = r42543681 / r42543683;
        return r42543684;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r42543685 = y;
        double r42543686 = -1.2430782448094334e-52;
        bool r42543687 = r42543685 <= r42543686;
        double r42543688 = a;
        double r42543689 = z;
        double r42543690 = r42543688 + r42543689;
        double r42543691 = b;
        double r42543692 = r42543690 - r42543691;
        double r42543693 = 4617794.30963613;
        bool r42543694 = r42543685 <= r42543693;
        double r42543695 = x;
        double r42543696 = r42543695 + r42543685;
        double r42543697 = r42543696 * r42543689;
        double r42543698 = t;
        double r42543699 = r42543685 + r42543698;
        double r42543700 = r42543688 * r42543699;
        double r42543701 = r42543697 + r42543700;
        double r42543702 = r42543685 * r42543691;
        double r42543703 = r42543701 - r42543702;
        double r42543704 = r42543699 + r42543695;
        double r42543705 = r42543703 / r42543704;
        double r42543706 = r42543694 ? r42543705 : r42543692;
        double r42543707 = r42543687 ? r42543692 : r42543706;
        return r42543707;
}

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.3
Target11.2
Herbie17.3
\[\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.2430782448094334e-52 or 4617794.30963613 < y

    1. Initial program 36.0

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

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

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

    if -1.2430782448094334e-52 < y < 4617794.30963613

    1. Initial program 15.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. Simplified15.1

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(x + \left(y + t\right)\right) \cdot \frac{1}{\left(y + t\right) \cdot a + \left(z \cdot \left(x + y\right) - b \cdot y\right)}}}\]
    7. Applied *-un-lft-identity15.3

      \[\leadsto \frac{\color{blue}{1 \cdot 1}}{\left(x + \left(y + t\right)\right) \cdot \frac{1}{\left(y + t\right) \cdot a + \left(z \cdot \left(x + y\right) - b \cdot y\right)}}\]
    8. Applied times-frac15.3

      \[\leadsto \color{blue}{\frac{1}{x + \left(y + t\right)} \cdot \frac{1}{\frac{1}{\left(y + t\right) \cdot a + \left(z \cdot \left(x + y\right) - b \cdot y\right)}}}\]
    9. Simplified15.2

      \[\leadsto \frac{1}{x + \left(y + t\right)} \cdot \color{blue}{\left(\left(\left(y + t\right) \cdot a + \left(y + x\right) \cdot z\right) - b \cdot y\right)}\]
    10. Using strategy rm
    11. Applied associate-*l/15.1

      \[\leadsto \color{blue}{\frac{1 \cdot \left(\left(\left(y + t\right) \cdot a + \left(y + x\right) \cdot z\right) - b \cdot y\right)}{x + \left(y + t\right)}}\]
    12. Simplified15.1

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

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

Reproduce

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