Average Error: 26.5 → 17.7
Time: 8.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.6015456318685901 \cdot 10^{-85} \lor \neg \left(y \le 2.8337340625170535 \cdot 10^{50}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{1}{\frac{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}{\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 -2.6015456318685901 \cdot 10^{-85} \lor \neg \left(y \le 2.8337340625170535 \cdot 10^{50}\right):\\
\;\;\;\;\left(a + z\right) - b\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r882829 = x;
        double r882830 = y;
        double r882831 = r882829 + r882830;
        double r882832 = z;
        double r882833 = r882831 * r882832;
        double r882834 = t;
        double r882835 = r882834 + r882830;
        double r882836 = a;
        double r882837 = r882835 * r882836;
        double r882838 = r882833 + r882837;
        double r882839 = b;
        double r882840 = r882830 * r882839;
        double r882841 = r882838 - r882840;
        double r882842 = r882829 + r882834;
        double r882843 = r882842 + r882830;
        double r882844 = r882841 / r882843;
        return r882844;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r882845 = y;
        double r882846 = -2.60154563186859e-85;
        bool r882847 = r882845 <= r882846;
        double r882848 = 2.8337340625170535e+50;
        bool r882849 = r882845 <= r882848;
        double r882850 = !r882849;
        bool r882851 = r882847 || r882850;
        double r882852 = a;
        double r882853 = z;
        double r882854 = r882852 + r882853;
        double r882855 = b;
        double r882856 = r882854 - r882855;
        double r882857 = 1.0;
        double r882858 = x;
        double r882859 = r882858 + r882845;
        double r882860 = t;
        double r882861 = r882860 + r882845;
        double r882862 = r882861 * r882852;
        double r882863 = r882845 * r882855;
        double r882864 = r882862 - r882863;
        double r882865 = fma(r882853, r882859, r882864);
        double r882866 = r882858 + r882860;
        double r882867 = r882866 + r882845;
        double r882868 = r882865 / r882867;
        double r882869 = r882857 / r882868;
        double r882870 = r882857 / r882869;
        double r882871 = r882851 ? r882856 : r882870;
        return r882871;
}

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.5
Target11.3
Herbie17.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.60154563186859e-85 or 2.8337340625170535e+50 < y

    1. Initial program 36.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. Using strategy rm
    3. Applied clear-num36.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. Simplified36.2

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

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

    if -2.60154563186859e-85 < y < 2.8337340625170535e+50

    1. Initial program 15.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 clear-num15.9

      \[\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. Simplified15.9

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

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

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

Reproduce

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