Average Error: 26.7 → 15.9
Time: 47.8s
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 -44587221161492483218018742042624:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;y \le 11954042188640717677055876658790137856:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, a - b, \mathsf{fma}\left(t, a, \left(y + x\right) \cdot z\right)\right)}{t + \left(y + x\right)}\\ \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}\;y \le -44587221161492483218018742042624:\\
\;\;\;\;\left(z + a\right) - b\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r40403561 = x;
        double r40403562 = y;
        double r40403563 = r40403561 + r40403562;
        double r40403564 = z;
        double r40403565 = r40403563 * r40403564;
        double r40403566 = t;
        double r40403567 = r40403566 + r40403562;
        double r40403568 = a;
        double r40403569 = r40403567 * r40403568;
        double r40403570 = r40403565 + r40403569;
        double r40403571 = b;
        double r40403572 = r40403562 * r40403571;
        double r40403573 = r40403570 - r40403572;
        double r40403574 = r40403561 + r40403566;
        double r40403575 = r40403574 + r40403562;
        double r40403576 = r40403573 / r40403575;
        return r40403576;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r40403577 = y;
        double r40403578 = -4.458722116149248e+31;
        bool r40403579 = r40403577 <= r40403578;
        double r40403580 = z;
        double r40403581 = a;
        double r40403582 = r40403580 + r40403581;
        double r40403583 = b;
        double r40403584 = r40403582 - r40403583;
        double r40403585 = 1.1954042188640718e+37;
        bool r40403586 = r40403577 <= r40403585;
        double r40403587 = r40403581 - r40403583;
        double r40403588 = t;
        double r40403589 = x;
        double r40403590 = r40403577 + r40403589;
        double r40403591 = r40403590 * r40403580;
        double r40403592 = fma(r40403588, r40403581, r40403591);
        double r40403593 = fma(r40403577, r40403587, r40403592);
        double r40403594 = r40403588 + r40403590;
        double r40403595 = r40403593 / r40403594;
        double r40403596 = r40403586 ? r40403595 : r40403584;
        double r40403597 = r40403579 ? r40403584 : r40403596;
        return r40403597;
}

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

Target

Original26.7
Target11.1
Herbie15.9
\[\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 < -4.458722116149248e+31 or 1.1954042188640718e+37 < y

    1. Initial program 40.7

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

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

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

    if -4.458722116149248e+31 < y < 1.1954042188640718e+37

    1. Initial program 15.4

      \[\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.4

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(\left(y + x\right) + t\right) \cdot \frac{1}{\mathsf{fma}\left(y, a - b, \mathsf{fma}\left(t, a, z \cdot \left(y + x\right)\right)\right)}}}\]
    7. Applied add-cube-cbrt15.6

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\left(y + x\right) + t} \cdot \frac{\sqrt[3]{1}}{\frac{1}{\mathsf{fma}\left(y, a - b, \mathsf{fma}\left(t, a, z \cdot \left(y + x\right)\right)\right)}}}\]
    9. Simplified15.6

      \[\leadsto \color{blue}{\frac{1}{\left(y + x\right) + t}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{\mathsf{fma}\left(y, a - b, \mathsf{fma}\left(t, a, z \cdot \left(y + x\right)\right)\right)}}\]
    10. Simplified15.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -44587221161492483218018742042624:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;y \le 11954042188640717677055876658790137856:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, a - b, \mathsf{fma}\left(t, a, \left(y + x\right) \cdot z\right)\right)}{t + \left(y + x\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(z + a\right) - b\\ \end{array}\]

Reproduce

herbie shell --seed 2019200 +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.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)))