Average Error: 27.2 → 24.1
Time: 23.3s
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}\;a \le -1.489344028745425998561278378852190845938 \cdot 10^{159}:\\ \;\;\;\;a\\ \mathbf{elif}\;a \le 3.661868286866103037316279475658426551258 \cdot 10^{52}:\\ \;\;\;\;\left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right) \cdot \frac{1}{\left(x + y\right) + t}\\ \mathbf{elif}\;a \le 5.169109652046862613428321933936456788957 \cdot 10^{144}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;a\\ \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}\;a \le -1.489344028745425998561278378852190845938 \cdot 10^{159}:\\
\;\;\;\;a\\

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

\mathbf{elif}\;a \le 5.169109652046862613428321933936456788957 \cdot 10^{144}:\\
\;\;\;\;z\\

\mathbf{else}:\\
\;\;\;\;a\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r593567 = x;
        double r593568 = y;
        double r593569 = r593567 + r593568;
        double r593570 = z;
        double r593571 = r593569 * r593570;
        double r593572 = t;
        double r593573 = r593572 + r593568;
        double r593574 = a;
        double r593575 = r593573 * r593574;
        double r593576 = r593571 + r593575;
        double r593577 = b;
        double r593578 = r593568 * r593577;
        double r593579 = r593576 - r593578;
        double r593580 = r593567 + r593572;
        double r593581 = r593580 + r593568;
        double r593582 = r593579 / r593581;
        return r593582;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r593583 = a;
        double r593584 = -1.489344028745426e+159;
        bool r593585 = r593583 <= r593584;
        double r593586 = 3.661868286866103e+52;
        bool r593587 = r593583 <= r593586;
        double r593588 = x;
        double r593589 = y;
        double r593590 = r593588 + r593589;
        double r593591 = z;
        double r593592 = r593590 * r593591;
        double r593593 = t;
        double r593594 = r593593 + r593589;
        double r593595 = r593594 * r593583;
        double r593596 = r593592 + r593595;
        double r593597 = b;
        double r593598 = r593589 * r593597;
        double r593599 = r593596 - r593598;
        double r593600 = 1.0;
        double r593601 = r593590 + r593593;
        double r593602 = r593600 / r593601;
        double r593603 = r593599 * r593602;
        double r593604 = 5.1691096520468626e+144;
        bool r593605 = r593583 <= r593604;
        double r593606 = r593605 ? r593591 : r593583;
        double r593607 = r593587 ? r593603 : r593606;
        double r593608 = r593585 ? r593583 : r593607;
        return r593608;
}

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.2
Target11.2
Herbie24.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.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 3 regimes
  2. if a < -1.489344028745426e+159 or 5.1691096520468626e+144 < a

    1. Initial program 43.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 26.1

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

    if -1.489344028745426e+159 < a < 3.661868286866103e+52

    1. Initial program 20.8

      \[\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-inv20.9

      \[\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}}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt20.9

      \[\leadsto \left(\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b\right) \cdot \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\left(x + t\right) + y}\]
    6. Applied associate-/l*20.9

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

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

    if 3.661868286866103e+52 < a < 5.1691096520468626e+144

    1. Initial program 28.9

      \[\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 45.2

      \[\leadsto \color{blue}{z}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification24.1

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

Reproduce

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