Average Error: 26.6 → 17.2
Time: 14.7s
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 -1874.091779030282850726507604122161865234 \lor \neg \left(y \le 5.226391209460367194207582451634606885495 \cdot 10^{-28}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \mathsf{fma}\left(a, t, y \cdot \left(a - b\right)\right)\right)}{\left(x + t\right) + y}\\ \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 -1874.091779030282850726507604122161865234 \lor \neg \left(y \le 5.226391209460367194207582451634606885495 \cdot 10^{-28}\right):\\
\;\;\;\;\left(a + z\right) - b\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r387185 = x;
        double r387186 = y;
        double r387187 = r387185 + r387186;
        double r387188 = z;
        double r387189 = r387187 * r387188;
        double r387190 = t;
        double r387191 = r387190 + r387186;
        double r387192 = a;
        double r387193 = r387191 * r387192;
        double r387194 = r387189 + r387193;
        double r387195 = b;
        double r387196 = r387186 * r387195;
        double r387197 = r387194 - r387196;
        double r387198 = r387185 + r387190;
        double r387199 = r387198 + r387186;
        double r387200 = r387197 / r387199;
        return r387200;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r387201 = y;
        double r387202 = -1874.0917790302829;
        bool r387203 = r387201 <= r387202;
        double r387204 = 5.226391209460367e-28;
        bool r387205 = r387201 <= r387204;
        double r387206 = !r387205;
        bool r387207 = r387203 || r387206;
        double r387208 = a;
        double r387209 = z;
        double r387210 = r387208 + r387209;
        double r387211 = b;
        double r387212 = r387210 - r387211;
        double r387213 = x;
        double r387214 = r387213 + r387201;
        double r387215 = t;
        double r387216 = r387208 - r387211;
        double r387217 = r387201 * r387216;
        double r387218 = fma(r387208, r387215, r387217);
        double r387219 = fma(r387214, r387209, r387218);
        double r387220 = r387213 + r387215;
        double r387221 = r387220 + r387201;
        double r387222 = r387219 / r387221;
        double r387223 = r387207 ? r387212 : r387222;
        return r387223;
}

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.6
Target11.6
Herbie17.2
\[\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 < -1874.0917790302829 or 5.226391209460367e-28 < y

    1. Initial program 37.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. Simplified37.2

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

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

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

    if -1874.0917790302829 < y < 5.226391209460367e-28

    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{\mathsf{fma}\left(x + y, z, \mathsf{fma}\left(a, t, y \cdot \left(a - b\right)\right)\right)}{\left(x + t\right) + y}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification17.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1874.091779030282850726507604122161865234 \lor \neg \left(y \le 5.226391209460367194207582451634606885495 \cdot 10^{-28}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \mathsf{fma}\left(a, t, y \cdot \left(a - b\right)\right)\right)}{\left(x + t\right) + y}\\ \end{array}\]

Reproduce

herbie shell --seed 2019209 +o rules:numerics
(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.5813117084150564e153) (- (+ z a) b) (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) 1.2285964308315609e82) (/ 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)))