Average Error: 26.1 → 18.1
Time: 19.1s
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 -9.934676971669404208720627952544604223213 \cdot 10^{152}:\\ \;\;\;\;a\\ \mathbf{elif}\;a \le 1.254801113357911761699987310927986626165 \cdot 10^{126}:\\ \;\;\;\;\left(y + x\right) \cdot \frac{z}{t + \left(x + y\right)} + \frac{\mathsf{fma}\left(t, a, \left(a - b\right) \cdot y\right)}{t + \left(x + 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 -9.934676971669404208720627952544604223213 \cdot 10^{152}:\\
\;\;\;\;a\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r646235 = x;
        double r646236 = y;
        double r646237 = r646235 + r646236;
        double r646238 = z;
        double r646239 = r646237 * r646238;
        double r646240 = t;
        double r646241 = r646240 + r646236;
        double r646242 = a;
        double r646243 = r646241 * r646242;
        double r646244 = r646239 + r646243;
        double r646245 = b;
        double r646246 = r646236 * r646245;
        double r646247 = r646244 - r646246;
        double r646248 = r646235 + r646240;
        double r646249 = r646248 + r646236;
        double r646250 = r646247 / r646249;
        return r646250;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r646251 = a;
        double r646252 = -9.934676971669404e+152;
        bool r646253 = r646251 <= r646252;
        double r646254 = 1.2548011133579118e+126;
        bool r646255 = r646251 <= r646254;
        double r646256 = y;
        double r646257 = x;
        double r646258 = r646256 + r646257;
        double r646259 = z;
        double r646260 = t;
        double r646261 = r646257 + r646256;
        double r646262 = r646260 + r646261;
        double r646263 = r646259 / r646262;
        double r646264 = r646258 * r646263;
        double r646265 = b;
        double r646266 = r646251 - r646265;
        double r646267 = r646266 * r646256;
        double r646268 = fma(r646260, r646251, r646267);
        double r646269 = r646268 / r646262;
        double r646270 = r646264 + r646269;
        double r646271 = r646255 ? r646270 : r646251;
        double r646272 = r646253 ? r646251 : r646271;
        return r646272;
}

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.1
Target11.2
Herbie18.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 2 regimes
  2. if a < -9.934676971669404e+152 or 1.2548011133579118e+126 < a

    1. Initial program 41.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. Simplified41.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. Taylor expanded around 0 27.6

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

    if -9.934676971669404e+152 < a < 1.2548011133579118e+126

    1. Initial program 20.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. Simplified20.3

      \[\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 add-cube-cbrt20.5

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

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

      \[\leadsto \frac{\mathsf{fma}\left(x + y, z, \mathsf{fma}\left(a, t, y \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt[3]{a} \cdot \sqrt[3]{a}, \sqrt[3]{a}, -\sqrt[3]{b} \cdot \left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right)\right) + \mathsf{fma}\left(-\sqrt[3]{b}, \sqrt[3]{b} \cdot \sqrt[3]{b}, \sqrt[3]{b} \cdot \left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right)\right)\right)}\right)\right)}{\left(x + t\right) + y}\]
    7. Applied distribute-lft-in20.6

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

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

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

      \[\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({\left(\sqrt[3]{a}\right)}^{3} - b\right) + \left(\left(-b\right) + b\right) \cdot y\right)\right)}}}\]
    12. Simplified20.4

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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