Average Error: 26.4 → 15.9
Time: 18.2s
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.602247384635264296199163215397262441724 \cdot 10^{53} \lor \neg \left(y \le 28044996243696232\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(x + t\right) + y} \cdot \mathsf{fma}\left(a, t + y, \mathsf{fma}\left(y, z - b, x \cdot z\right)\right)\\ \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.602247384635264296199163215397262441724 \cdot 10^{53} \lor \neg \left(y \le 28044996243696232\right):\\
\;\;\;\;\left(a + z\right) - b\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r1149802 = x;
        double r1149803 = y;
        double r1149804 = r1149802 + r1149803;
        double r1149805 = z;
        double r1149806 = r1149804 * r1149805;
        double r1149807 = t;
        double r1149808 = r1149807 + r1149803;
        double r1149809 = a;
        double r1149810 = r1149808 * r1149809;
        double r1149811 = r1149806 + r1149810;
        double r1149812 = b;
        double r1149813 = r1149803 * r1149812;
        double r1149814 = r1149811 - r1149813;
        double r1149815 = r1149802 + r1149807;
        double r1149816 = r1149815 + r1149803;
        double r1149817 = r1149814 / r1149816;
        return r1149817;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1149818 = y;
        double r1149819 = -1.6022473846352643e+53;
        bool r1149820 = r1149818 <= r1149819;
        double r1149821 = 2.804499624369623e+16;
        bool r1149822 = r1149818 <= r1149821;
        double r1149823 = !r1149822;
        bool r1149824 = r1149820 || r1149823;
        double r1149825 = a;
        double r1149826 = z;
        double r1149827 = r1149825 + r1149826;
        double r1149828 = b;
        double r1149829 = r1149827 - r1149828;
        double r1149830 = 1.0;
        double r1149831 = x;
        double r1149832 = t;
        double r1149833 = r1149831 + r1149832;
        double r1149834 = r1149833 + r1149818;
        double r1149835 = r1149830 / r1149834;
        double r1149836 = r1149832 + r1149818;
        double r1149837 = r1149826 - r1149828;
        double r1149838 = r1149831 * r1149826;
        double r1149839 = fma(r1149818, r1149837, r1149838);
        double r1149840 = fma(r1149825, r1149836, r1149839);
        double r1149841 = r1149835 * r1149840;
        double r1149842 = r1149824 ? r1149829 : r1149841;
        return r1149842;
}

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.4
Target11.6
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 < -1.6022473846352643e+53 or 2.804499624369623e+16 < y

    1. Initial program 40.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. Simplified40.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 clear-num40.9

      \[\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 16.6

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

    if -1.6022473846352643e+53 < y < 2.804499624369623e+16

    1. Initial program 15.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. Simplified15.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-num15.3

      \[\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 inf 15.3

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

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

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

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

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

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

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

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

Reproduce

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