Average Error: 23.8 → 19.6
Time: 15.0s
Precision: 64
\[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.285204343974009 \cdot 10^{172} \lor \neg \left(z \le 1.6215554508775919 \cdot 10^{125}\right):\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y + \left(z \cdot t + z \cdot \left(-a\right)\right)}{\mathsf{fma}\left(z, b - y, y\right)}\\ \end{array}\]
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\begin{array}{l}
\mathbf{if}\;z \le -1.285204343974009 \cdot 10^{172} \lor \neg \left(z \le 1.6215554508775919 \cdot 10^{125}\right):\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r729553 = x;
        double r729554 = y;
        double r729555 = r729553 * r729554;
        double r729556 = z;
        double r729557 = t;
        double r729558 = a;
        double r729559 = r729557 - r729558;
        double r729560 = r729556 * r729559;
        double r729561 = r729555 + r729560;
        double r729562 = b;
        double r729563 = r729562 - r729554;
        double r729564 = r729556 * r729563;
        double r729565 = r729554 + r729564;
        double r729566 = r729561 / r729565;
        return r729566;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r729567 = z;
        double r729568 = -1.285204343974009e+172;
        bool r729569 = r729567 <= r729568;
        double r729570 = 1.621555450877592e+125;
        bool r729571 = r729567 <= r729570;
        double r729572 = !r729571;
        bool r729573 = r729569 || r729572;
        double r729574 = t;
        double r729575 = b;
        double r729576 = r729574 / r729575;
        double r729577 = a;
        double r729578 = r729577 / r729575;
        double r729579 = r729576 - r729578;
        double r729580 = x;
        double r729581 = y;
        double r729582 = r729580 * r729581;
        double r729583 = r729567 * r729574;
        double r729584 = -r729577;
        double r729585 = r729567 * r729584;
        double r729586 = r729583 + r729585;
        double r729587 = r729582 + r729586;
        double r729588 = r729575 - r729581;
        double r729589 = fma(r729567, r729588, r729581);
        double r729590 = r729587 / r729589;
        double r729591 = r729573 ? r729579 : r729590;
        return r729591;
}

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

Original23.8
Target18.5
Herbie19.6
\[\frac{z \cdot t + y \cdot x}{y + z \cdot \left(b - y\right)} - \frac{a}{\left(b - y\right) + \frac{y}{z}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -1.285204343974009e+172 or 1.621555450877592e+125 < z

    1. Initial program 49.9

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

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

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

      \[\leadsto \color{blue}{\frac{t}{b} - \frac{a}{b}}\]

    if -1.285204343974009e+172 < z < 1.621555450877592e+125

    1. Initial program 14.8

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

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

      \[\leadsto \frac{\mathsf{fma}\left(x, y, z \cdot \color{blue}{\left(t + \left(-a\right)\right)}\right)}{\mathsf{fma}\left(z, b - y, y\right)}\]
    5. Applied distribute-lft-in14.8

      \[\leadsto \frac{\mathsf{fma}\left(x, y, \color{blue}{z \cdot t + z \cdot \left(-a\right)}\right)}{\mathsf{fma}\left(z, b - y, y\right)}\]
    6. Using strategy rm
    7. Applied fma-udef14.8

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

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

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(FPCore (x y z t a b)
  :name "Development.Shake.Progress:decay from shake-0.15.5"
  :precision binary64

  :herbie-target
  (- (/ (+ (* z t) (* y x)) (+ y (* z (- b y)))) (/ a (+ (- b y) (/ y z))))

  (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))