Average Error: 27.0 → 13.7
Time: 20.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 -9110484639622092928439025664:\\ \;\;\;\;\left(a + z\right) - \frac{y}{\left(y + t\right) + x} \cdot b\\ \mathbf{elif}\;y \le 6.503370493896171151091587514980061243545 \cdot 10^{95}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y + x, z, a \cdot \left(y + t\right)\right)}{\left(y + t\right) + x} - b \cdot \frac{1}{\frac{\left(y + t\right) + x}{y}}\\ \mathbf{else}:\\ \;\;\;\;\left(a + z\right) - \frac{y}{\left(y + t\right) + x} \cdot b\\ \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 -9110484639622092928439025664:\\
\;\;\;\;\left(a + z\right) - \frac{y}{\left(y + t\right) + x} \cdot b\\

\mathbf{elif}\;y \le 6.503370493896171151091587514980061243545 \cdot 10^{95}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y + x, z, a \cdot \left(y + t\right)\right)}{\left(y + t\right) + x} - b \cdot \frac{1}{\frac{\left(y + t\right) + x}{y}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r33358460 = x;
        double r33358461 = y;
        double r33358462 = r33358460 + r33358461;
        double r33358463 = z;
        double r33358464 = r33358462 * r33358463;
        double r33358465 = t;
        double r33358466 = r33358465 + r33358461;
        double r33358467 = a;
        double r33358468 = r33358466 * r33358467;
        double r33358469 = r33358464 + r33358468;
        double r33358470 = b;
        double r33358471 = r33358461 * r33358470;
        double r33358472 = r33358469 - r33358471;
        double r33358473 = r33358460 + r33358465;
        double r33358474 = r33358473 + r33358461;
        double r33358475 = r33358472 / r33358474;
        return r33358475;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r33358476 = y;
        double r33358477 = -9.110484639622093e+27;
        bool r33358478 = r33358476 <= r33358477;
        double r33358479 = a;
        double r33358480 = z;
        double r33358481 = r33358479 + r33358480;
        double r33358482 = t;
        double r33358483 = r33358476 + r33358482;
        double r33358484 = x;
        double r33358485 = r33358483 + r33358484;
        double r33358486 = r33358476 / r33358485;
        double r33358487 = b;
        double r33358488 = r33358486 * r33358487;
        double r33358489 = r33358481 - r33358488;
        double r33358490 = 6.503370493896171e+95;
        bool r33358491 = r33358476 <= r33358490;
        double r33358492 = r33358476 + r33358484;
        double r33358493 = r33358479 * r33358483;
        double r33358494 = fma(r33358492, r33358480, r33358493);
        double r33358495 = r33358494 / r33358485;
        double r33358496 = 1.0;
        double r33358497 = r33358485 / r33358476;
        double r33358498 = r33358496 / r33358497;
        double r33358499 = r33358487 * r33358498;
        double r33358500 = r33358495 - r33358499;
        double r33358501 = r33358491 ? r33358500 : r33358489;
        double r33358502 = r33358478 ? r33358489 : r33358501;
        return r33358502;
}

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.0
Target11.5
Herbie13.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 y < -9.110484639622093e+27 or 6.503370493896171e+95 < y

    1. Initial program 42.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. Simplified42.1

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y + x, z, a \cdot \left(y + t\right)\right) - b \cdot y}{x + \left(y + t\right)}}\]
    3. Using strategy rm
    4. Applied div-sub42.1

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

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

      \[\leadsto \frac{\mathsf{fma}\left(y + x, z, a \cdot \left(y + t\right)\right)}{x + \left(y + t\right)} - \color{blue}{\frac{b}{1} \cdot \frac{y}{x + \left(y + t\right)}}\]
    8. Simplified34.2

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

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

    if -9.110484639622093e+27 < y < 6.503370493896171e+95

    1. Initial program 16.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. Simplified16.1

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y + x, z, a \cdot \left(y + t\right)\right) - b \cdot y}{x + \left(y + t\right)}}\]
    3. Using strategy rm
    4. Applied div-sub16.1

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019172 +o rules:numerics
(FPCore (x y z t a b)
  :name "AI.Clustering.Hierarchical.Internal:ward from clustering-0.2.1"

  :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.0 (/ (+ (+ 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)))