Average Error: 27.1 → 23.3
Time: 16.4s
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.8805809533531431 \cdot 10^{184}:\\ \;\;\;\;a\\ \mathbf{elif}\;a \le 1.30644989599949 \cdot 10^{88}:\\ \;\;\;\;\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{x + \left(t + y\right)}\\ \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.8805809533531431 \cdot 10^{184}:\\
\;\;\;\;a\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r1027464 = x;
        double r1027465 = y;
        double r1027466 = r1027464 + r1027465;
        double r1027467 = z;
        double r1027468 = r1027466 * r1027467;
        double r1027469 = t;
        double r1027470 = r1027469 + r1027465;
        double r1027471 = a;
        double r1027472 = r1027470 * r1027471;
        double r1027473 = r1027468 + r1027472;
        double r1027474 = b;
        double r1027475 = r1027465 * r1027474;
        double r1027476 = r1027473 - r1027475;
        double r1027477 = r1027464 + r1027469;
        double r1027478 = r1027477 + r1027465;
        double r1027479 = r1027476 / r1027478;
        return r1027479;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1027480 = a;
        double r1027481 = -1.880580953353143e+184;
        bool r1027482 = r1027480 <= r1027481;
        double r1027483 = 1.3064498959994905e+88;
        bool r1027484 = r1027480 <= r1027483;
        double r1027485 = x;
        double r1027486 = y;
        double r1027487 = r1027485 + r1027486;
        double r1027488 = z;
        double r1027489 = r1027487 * r1027488;
        double r1027490 = t;
        double r1027491 = r1027490 + r1027486;
        double r1027492 = r1027491 * r1027480;
        double r1027493 = r1027489 + r1027492;
        double r1027494 = b;
        double r1027495 = r1027486 * r1027494;
        double r1027496 = r1027493 - r1027495;
        double r1027497 = r1027485 + r1027491;
        double r1027498 = r1027496 / r1027497;
        double r1027499 = r1027484 ? r1027498 : r1027480;
        double r1027500 = r1027482 ? r1027480 : r1027499;
        return r1027500;
}

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.1
Target11.5
Herbie23.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.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 a < -1.880580953353143e+184 or 1.3064498959994905e+88 < a

    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. Using strategy rm
    3. Applied div-inv42.3

      \[\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 *-un-lft-identity42.3

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

      \[\leadsto \color{blue}{1 \cdot \left(\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}\right)}\]
    7. Simplified42.3

      \[\leadsto 1 \cdot \color{blue}{\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{x + \left(t + y\right)}}\]
    8. Taylor expanded around 0 28.6

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

    if -1.880580953353143e+184 < a < 1.3064498959994905e+88

    1. Initial program 21.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. Using strategy rm
    3. Applied div-inv21.3

      \[\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 *-un-lft-identity21.3

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

      \[\leadsto \color{blue}{1 \cdot \left(\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}\right)}\]
    7. Simplified21.3

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

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

Reproduce

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