Average Error: 26.8 → 15.7
Time: 14.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}\;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 r1029761 = x;
        double r1029762 = y;
        double r1029763 = r1029761 + r1029762;
        double r1029764 = z;
        double r1029765 = r1029763 * r1029764;
        double r1029766 = t;
        double r1029767 = r1029766 + r1029762;
        double r1029768 = a;
        double r1029769 = r1029767 * r1029768;
        double r1029770 = r1029765 + r1029769;
        double r1029771 = b;
        double r1029772 = r1029762 * r1029771;
        double r1029773 = r1029770 - r1029772;
        double r1029774 = r1029761 + r1029766;
        double r1029775 = r1029774 + r1029762;
        double r1029776 = r1029773 / r1029775;
        return r1029776;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1029777 = y;
        double r1029778 = -2.9055951739605413e+59;
        bool r1029779 = r1029777 <= r1029778;
        double r1029780 = 3.396242341673578e+123;
        bool r1029781 = r1029777 <= r1029780;
        double r1029782 = !r1029781;
        bool r1029783 = r1029779 || r1029782;
        double r1029784 = a;
        double r1029785 = z;
        double r1029786 = r1029784 + r1029785;
        double r1029787 = b;
        double r1029788 = r1029786 - r1029787;
        double r1029789 = 1.0;
        double r1029790 = x;
        double r1029791 = t;
        double r1029792 = r1029790 + r1029791;
        double r1029793 = r1029792 + r1029777;
        double r1029794 = r1029789 / r1029793;
        double r1029795 = r1029790 + r1029777;
        double r1029796 = r1029784 - r1029787;
        double r1029797 = r1029777 * r1029796;
        double r1029798 = fma(r1029784, r1029791, r1029797);
        double r1029799 = fma(r1029785, r1029795, r1029798);
        double r1029800 = r1029789 / r1029799;
        double r1029801 = r1029794 / r1029800;
        double r1029802 = r1029783 ? r1029788 : r1029801;
        return r1029802;
}

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)))