Average Error: 27.0 → 21.0
Time: 8.9s
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 -9.59621725839655908 \cdot 10^{78}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;y \le 2.570722063616475 \cdot 10^{90}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\sqrt[3]{\left(x + t\right) + y} \cdot \sqrt[3]{\left(x + t\right) + y}}}{\sqrt[3]{\left(x + t\right) + y}} - \frac{y \cdot b}{\left(x + t\right) + y}\\ \mathbf{elif}\;y \le 2.0673661513817186 \cdot 10^{176}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{else}:\\ \;\;\;\;z - y \cdot \frac{b}{\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 -9.59621725839655908 \cdot 10^{78}:\\
\;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\

\mathbf{elif}\;y \le 2.570722063616475 \cdot 10^{90}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\sqrt[3]{\left(x + t\right) + y} \cdot \sqrt[3]{\left(x + t\right) + y}}}{\sqrt[3]{\left(x + t\right) + y}} - \frac{y \cdot b}{\left(x + t\right) + y}\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r946611 = x;
        double r946612 = y;
        double r946613 = r946611 + r946612;
        double r946614 = z;
        double r946615 = r946613 * r946614;
        double r946616 = t;
        double r946617 = r946616 + r946612;
        double r946618 = a;
        double r946619 = r946617 * r946618;
        double r946620 = r946615 + r946619;
        double r946621 = b;
        double r946622 = r946612 * r946621;
        double r946623 = r946620 - r946622;
        double r946624 = r946611 + r946616;
        double r946625 = r946624 + r946612;
        double r946626 = r946623 / r946625;
        return r946626;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r946627 = y;
        double r946628 = -9.596217258396559e+78;
        bool r946629 = r946627 <= r946628;
        double r946630 = z;
        double r946631 = b;
        double r946632 = x;
        double r946633 = t;
        double r946634 = r946632 + r946633;
        double r946635 = r946634 + r946627;
        double r946636 = r946631 / r946635;
        double r946637 = r946627 * r946636;
        double r946638 = r946630 - r946637;
        double r946639 = 2.570722063616475e+90;
        bool r946640 = r946627 <= r946639;
        double r946641 = r946632 + r946627;
        double r946642 = r946633 + r946627;
        double r946643 = a;
        double r946644 = r946642 * r946643;
        double r946645 = fma(r946641, r946630, r946644);
        double r946646 = cbrt(r946635);
        double r946647 = r946646 * r946646;
        double r946648 = r946645 / r946647;
        double r946649 = r946648 / r946646;
        double r946650 = r946627 * r946631;
        double r946651 = r946650 / r946635;
        double r946652 = r946649 - r946651;
        double r946653 = 2.0673661513817186e+176;
        bool r946654 = r946627 <= r946653;
        double r946655 = r946643 - r946637;
        double r946656 = r946654 ? r946655 : r946638;
        double r946657 = r946640 ? r946652 : r946656;
        double r946658 = r946629 ? r946638 : r946657;
        return r946658;
}

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.0
Target11.1
Herbie21.0
\[\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 3 regimes
  2. if y < -9.596217258396559e+78 or 2.0673661513817186e+176 < y

    1. Initial program 46.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. Using strategy rm
    3. Applied div-sub46.2

      \[\leadsto \color{blue}{\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}}\]
    4. Simplified46.2

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

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

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

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

      \[\leadsto \color{blue}{z} - y \cdot \frac{b}{\left(x + t\right) + y}\]

    if -9.596217258396559e+78 < y < 2.570722063616475e+90

    1. Initial program 17.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. Using strategy rm
    3. Applied div-sub17.2

      \[\leadsto \color{blue}{\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}}\]
    4. Simplified17.2

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

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

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

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

    if 2.570722063616475e+90 < y < 2.0673661513817186e+176

    1. Initial program 35.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. Using strategy rm
    3. Applied div-sub35.8

      \[\leadsto \color{blue}{\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}}\]
    4. Simplified35.8

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -9.59621725839655908 \cdot 10^{78}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;y \le 2.570722063616475 \cdot 10^{90}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{\sqrt[3]{\left(x + t\right) + y} \cdot \sqrt[3]{\left(x + t\right) + y}}}{\sqrt[3]{\left(x + t\right) + y}} - \frac{y \cdot b}{\left(x + t\right) + y}\\ \mathbf{elif}\;y \le 2.0673661513817186 \cdot 10^{176}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{else}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \end{array}\]

Reproduce

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