Average Error: 26.3 → 16.0
Time: 23.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.411764817356564236098712359069926133514 \cdot 10^{141} \lor \neg \left(y \le 1.443268457983921237856330673277442625005 \cdot 10^{66}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\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}\\ \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.411764817356564236098712359069926133514 \cdot 10^{141} \lor \neg \left(y \le 1.443268457983921237856330673277442625005 \cdot 10^{66}\right):\\
\;\;\;\;\left(a + z\right) - b\\

\mathbf{else}:\\
\;\;\;\;\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}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r426208 = x;
        double r426209 = y;
        double r426210 = r426208 + r426209;
        double r426211 = z;
        double r426212 = r426210 * r426211;
        double r426213 = t;
        double r426214 = r426213 + r426209;
        double r426215 = a;
        double r426216 = r426214 * r426215;
        double r426217 = r426212 + r426216;
        double r426218 = b;
        double r426219 = r426209 * r426218;
        double r426220 = r426217 - r426219;
        double r426221 = r426208 + r426213;
        double r426222 = r426221 + r426209;
        double r426223 = r426220 / r426222;
        return r426223;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r426224 = y;
        double r426225 = -1.4117648173565642e+141;
        bool r426226 = r426224 <= r426225;
        double r426227 = 1.4432684579839212e+66;
        bool r426228 = r426224 <= r426227;
        double r426229 = !r426228;
        bool r426230 = r426226 || r426229;
        double r426231 = a;
        double r426232 = z;
        double r426233 = r426231 + r426232;
        double r426234 = b;
        double r426235 = r426233 - r426234;
        double r426236 = t;
        double r426237 = r426236 + r426224;
        double r426238 = x;
        double r426239 = r426232 - r426234;
        double r426240 = r426224 * r426239;
        double r426241 = fma(r426238, r426232, r426240);
        double r426242 = fma(r426231, r426237, r426241);
        double r426243 = r426238 + r426236;
        double r426244 = r426243 + r426224;
        double r426245 = r426242 / r426244;
        double r426246 = r426230 ? r426235 : r426245;
        return r426246;
}

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.3
Target11.2
Herbie16.0
\[\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.4117648173565642e+141 or 1.4432684579839212e+66 < 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. Simplified44.4

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

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

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

    if -1.4117648173565642e+141 < y < 1.4432684579839212e+66

    1. Initial program 17.5

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
    2. Simplified17.5

      \[\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. Recombined 2 regimes into one program.
  4. Final simplification16.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.411764817356564236098712359069926133514 \cdot 10^{141} \lor \neg \left(y \le 1.443268457983921237856330673277442625005 \cdot 10^{66}\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\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}\\ \end{array}\]

Reproduce

herbie shell --seed 2019306 +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.5813117084150564e153) (- (+ z a) b) (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) 1.2285964308315609e82) (/ 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)))