Average Error: 26.2 → 7.7
Time: 6.6s
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}\;\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \le -3.390161994232769603797086096996840330962 \cdot 10^{249} \lor \neg \left(\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \le 9.309448431702419412551670358836655427892 \cdot 10^{279}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot \left(x + y\right)}{\left(x + t\right) + y} + \frac{\mathsf{fma}\left(y, a - b, a \cdot t\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}\;\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \le -3.390161994232769603797086096996840330962 \cdot 10^{249} \lor \neg \left(\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \le 9.309448431702419412551670358836655427892 \cdot 10^{279}\right):\\
\;\;\;\;\left(a + z\right) - b\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r945122 = x;
        double r945123 = y;
        double r945124 = r945122 + r945123;
        double r945125 = z;
        double r945126 = r945124 * r945125;
        double r945127 = t;
        double r945128 = r945127 + r945123;
        double r945129 = a;
        double r945130 = r945128 * r945129;
        double r945131 = r945126 + r945130;
        double r945132 = b;
        double r945133 = r945123 * r945132;
        double r945134 = r945131 - r945133;
        double r945135 = r945122 + r945127;
        double r945136 = r945135 + r945123;
        double r945137 = r945134 / r945136;
        return r945137;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r945138 = x;
        double r945139 = y;
        double r945140 = r945138 + r945139;
        double r945141 = z;
        double r945142 = r945140 * r945141;
        double r945143 = t;
        double r945144 = r945143 + r945139;
        double r945145 = a;
        double r945146 = r945144 * r945145;
        double r945147 = r945142 + r945146;
        double r945148 = b;
        double r945149 = r945139 * r945148;
        double r945150 = r945147 - r945149;
        double r945151 = r945138 + r945143;
        double r945152 = r945151 + r945139;
        double r945153 = r945150 / r945152;
        double r945154 = -3.3901619942327696e+249;
        bool r945155 = r945153 <= r945154;
        double r945156 = 9.30944843170242e+279;
        bool r945157 = r945153 <= r945156;
        double r945158 = !r945157;
        bool r945159 = r945155 || r945158;
        double r945160 = r945145 + r945141;
        double r945161 = r945160 - r945148;
        double r945162 = r945141 * r945140;
        double r945163 = r945162 / r945152;
        double r945164 = r945145 - r945148;
        double r945165 = r945145 * r945143;
        double r945166 = fma(r945139, r945164, r945165);
        double r945167 = r945166 / r945152;
        double r945168 = r945163 + r945167;
        double r945169 = r945159 ? r945161 : r945168;
        return r945169;
}

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.2
Target11.3
Herbie7.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.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 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) < -3.3901619942327696e+249 or 9.30944843170242e+279 < (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y))

    1. Initial program 61.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-num61.3

      \[\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. Simplified61.3

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

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

    if -3.3901619942327696e+249 < (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) < 9.30944843170242e+279

    1. Initial program 0.3

      \[\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-num0.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. Simplified0.4

      \[\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 div-inv0.5

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

      \[\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(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}\]
    8. Applied times-frac0.5

      \[\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(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}}\]
    9. Simplified0.5

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

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

      \[\leadsto \frac{1}{\left(x + t\right) + y} \cdot \color{blue}{\left(z \cdot \left(x + y\right) + \left(\left(t + y\right) \cdot a - y \cdot b\right)\right)}\]
    13. Applied distribute-lft-in0.5

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

      \[\leadsto \color{blue}{\frac{z \cdot \left(x + y\right)}{\left(x + t\right) + y}} + \frac{1}{\left(x + t\right) + y} \cdot \left(\left(t + y\right) \cdot a - y \cdot b\right)\]
    15. Simplified0.3

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

    \[\leadsto \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} \le -3.390161994232769603797086096996840330962 \cdot 10^{249} \lor \neg \left(\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \le 9.309448431702419412551670358836655427892 \cdot 10^{279}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot \left(x + y\right)}{\left(x + t\right) + y} + \frac{\mathsf{fma}\left(y, a - b, a \cdot t\right)}{\left(x + t\right) + y}\\ \end{array}\]

Reproduce

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