Average Error: 27.2 → 17.3
Time: 20.0s
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.355585068593240611312869652125605328595 \cdot 10^{-45} \lor \neg \left(y \le 7.974061462163527509529741971981870705504 \cdot 10^{98}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, \left(y \cdot \left(\sqrt[3]{z - b} \cdot \sqrt[3]{z - b}\right)\right) \cdot \sqrt[3]{z - b}\right)\right) \cdot \frac{1}{\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 -1.355585068593240611312869652125605328595 \cdot 10^{-45} \lor \neg \left(y \le 7.974061462163527509529741971981870705504 \cdot 10^{98}\right):\\
\;\;\;\;\left(a + z\right) - b\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r591340 = x;
        double r591341 = y;
        double r591342 = r591340 + r591341;
        double r591343 = z;
        double r591344 = r591342 * r591343;
        double r591345 = t;
        double r591346 = r591345 + r591341;
        double r591347 = a;
        double r591348 = r591346 * r591347;
        double r591349 = r591344 + r591348;
        double r591350 = b;
        double r591351 = r591341 * r591350;
        double r591352 = r591349 - r591351;
        double r591353 = r591340 + r591345;
        double r591354 = r591353 + r591341;
        double r591355 = r591352 / r591354;
        return r591355;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r591356 = y;
        double r591357 = -1.3555850685932406e-45;
        bool r591358 = r591356 <= r591357;
        double r591359 = 7.974061462163528e+98;
        bool r591360 = r591356 <= r591359;
        double r591361 = !r591360;
        bool r591362 = r591358 || r591361;
        double r591363 = a;
        double r591364 = z;
        double r591365 = r591363 + r591364;
        double r591366 = b;
        double r591367 = r591365 - r591366;
        double r591368 = t;
        double r591369 = r591368 + r591356;
        double r591370 = x;
        double r591371 = r591364 - r591366;
        double r591372 = cbrt(r591371);
        double r591373 = r591372 * r591372;
        double r591374 = r591356 * r591373;
        double r591375 = r591374 * r591372;
        double r591376 = fma(r591370, r591364, r591375);
        double r591377 = fma(r591363, r591369, r591376);
        double r591378 = 1.0;
        double r591379 = r591370 + r591368;
        double r591380 = r591379 + r591356;
        double r591381 = r591378 / r591380;
        double r591382 = r591377 * r591381;
        double r591383 = r591362 ? r591367 : r591382;
        return r591383;
}

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

Original27.2
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.3555850685932406e-45 or 7.974061462163528e+98 < y

    1. Initial program 39.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. Simplified39.2

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

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

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

    if -1.3555850685932406e-45 < y < 7.974061462163528e+98

    1. Initial program 16.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. Simplified16.8

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

      \[\leadsto \frac{\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, y \cdot \color{blue}{\left(\left(\sqrt[3]{z - b} \cdot \sqrt[3]{z - b}\right) \cdot \sqrt[3]{z - b}\right)}\right)\right)}{\left(x + t\right) + y}\]
    5. Applied associate-*r*17.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.355585068593240611312869652125605328595 \cdot 10^{-45} \lor \neg \left(y \le 7.974061462163527509529741971981870705504 \cdot 10^{98}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, \left(y \cdot \left(\sqrt[3]{z - b} \cdot \sqrt[3]{z - b}\right)\right) \cdot \sqrt[3]{z - b}\right)\right) \cdot \frac{1}{\left(x + t\right) + y}\\ \end{array}\]

Reproduce

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