Average Error: 27.1 → 16.4
Time: 23.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 -9.283225756149319248945106802416453318378 \cdot 10^{114} \lor \neg \left(y \le 339454492032664018177593228072776105984\right):\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a, t + y, \mathsf{fma}\left(x, z, y \cdot \left(z - b\right)\right)\right) \cdot \frac{1}{\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 -9.283225756149319248945106802416453318378 \cdot 10^{114} \lor \neg \left(y \le 339454492032664018177593228072776105984\right):\\
\;\;\;\;\left(a + z\right) - b\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r766440 = x;
        double r766441 = y;
        double r766442 = r766440 + r766441;
        double r766443 = z;
        double r766444 = r766442 * r766443;
        double r766445 = t;
        double r766446 = r766445 + r766441;
        double r766447 = a;
        double r766448 = r766446 * r766447;
        double r766449 = r766444 + r766448;
        double r766450 = b;
        double r766451 = r766441 * r766450;
        double r766452 = r766449 - r766451;
        double r766453 = r766440 + r766445;
        double r766454 = r766453 + r766441;
        double r766455 = r766452 / r766454;
        return r766455;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r766456 = y;
        double r766457 = -9.283225756149319e+114;
        bool r766458 = r766456 <= r766457;
        double r766459 = 3.39454492032664e+38;
        bool r766460 = r766456 <= r766459;
        double r766461 = !r766460;
        bool r766462 = r766458 || r766461;
        double r766463 = a;
        double r766464 = z;
        double r766465 = r766463 + r766464;
        double r766466 = b;
        double r766467 = r766465 - r766466;
        double r766468 = t;
        double r766469 = r766468 + r766456;
        double r766470 = x;
        double r766471 = r766464 - r766466;
        double r766472 = r766456 * r766471;
        double r766473 = fma(r766470, r766464, r766472);
        double r766474 = fma(r766463, r766469, r766473);
        double r766475 = 1.0;
        double r766476 = r766470 + r766468;
        double r766477 = r766476 + r766456;
        double r766478 = r766475 / r766477;
        double r766479 = r766474 * r766478;
        double r766480 = r766462 ? r766467 : r766479;
        return r766480;
}

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

Original27.1
Target11.4
Herbie16.4
\[\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 < -9.283225756149319e+114 or 3.39454492032664e+38 < y

    1. Initial program 44.0

      \[\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.0

      \[\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.0

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

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

    if -9.283225756149319e+114 < y < 3.39454492032664e+38

    1. Initial program 17.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. Simplified17.1

      \[\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 div-inv17.2

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

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

Reproduce

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