Average Error: 26.8 → 15.7
Time: 15.4s
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 -2.9055951739605413 \cdot 10^{59} \lor \neg \left(y \le 3.3962423416735779 \cdot 10^{123}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{\left(x + t\right) + y}}{\frac{1}{\mathsf{fma}\left(z, x + y, \mathsf{fma}\left(a, t, y \cdot \left(a - b\right)\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 -2.9055951739605413 \cdot 10^{59} \lor \neg \left(y \le 3.3962423416735779 \cdot 10^{123}\right):\\
\;\;\;\;\left(a + z\right) - b\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r306825 = x;
        double r306826 = y;
        double r306827 = r306825 + r306826;
        double r306828 = z;
        double r306829 = r306827 * r306828;
        double r306830 = t;
        double r306831 = r306830 + r306826;
        double r306832 = a;
        double r306833 = r306831 * r306832;
        double r306834 = r306829 + r306833;
        double r306835 = b;
        double r306836 = r306826 * r306835;
        double r306837 = r306834 - r306836;
        double r306838 = r306825 + r306830;
        double r306839 = r306838 + r306826;
        double r306840 = r306837 / r306839;
        return r306840;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r306841 = y;
        double r306842 = -2.9055951739605413e+59;
        bool r306843 = r306841 <= r306842;
        double r306844 = 3.396242341673578e+123;
        bool r306845 = r306841 <= r306844;
        double r306846 = !r306845;
        bool r306847 = r306843 || r306846;
        double r306848 = a;
        double r306849 = z;
        double r306850 = r306848 + r306849;
        double r306851 = b;
        double r306852 = r306850 - r306851;
        double r306853 = 1.0;
        double r306854 = x;
        double r306855 = t;
        double r306856 = r306854 + r306855;
        double r306857 = r306856 + r306841;
        double r306858 = r306853 / r306857;
        double r306859 = r306854 + r306841;
        double r306860 = r306848 - r306851;
        double r306861 = r306841 * r306860;
        double r306862 = fma(r306848, r306855, r306861);
        double r306863 = fma(r306849, r306859, r306862);
        double r306864 = r306853 / r306863;
        double r306865 = r306858 / r306864;
        double r306866 = r306847 ? r306852 : r306865;
        return r306866;
}

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.8
Target11.4
Herbie15.7
\[\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 2 regimes
  2. if y < -2.9055951739605413e+59 or 3.396242341673578e+123 < y

    1. Initial program 44.4

      \[\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 clear-num44.4

      \[\leadsto \color{blue}{\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}}}\]
    4. Simplified44.4

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

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

    if -2.9055951739605413e+59 < y < 3.396242341673578e+123

    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 clear-num17.2

      \[\leadsto \color{blue}{\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}}}\]
    4. Simplified17.2

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

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

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

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

Reproduce

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