Average Error: 23.8 → 19.6
Time: 11.9s
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 r761368 = x;
        double r761369 = y;
        double r761370 = r761368 * r761369;
        double r761371 = z;
        double r761372 = t;
        double r761373 = a;
        double r761374 = r761372 - r761373;
        double r761375 = r761371 * r761374;
        double r761376 = r761370 + r761375;
        double r761377 = b;
        double r761378 = r761377 - r761369;
        double r761379 = r761371 * r761378;
        double r761380 = r761369 + r761379;
        double r761381 = r761376 / r761380;
        return r761381;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r761382 = z;
        double r761383 = -1.285204343974009e+172;
        bool r761384 = r761382 <= r761383;
        double r761385 = 1.621555450877592e+125;
        bool r761386 = r761382 <= r761385;
        double r761387 = !r761386;
        bool r761388 = r761384 || r761387;
        double r761389 = t;
        double r761390 = b;
        double r761391 = r761389 / r761390;
        double r761392 = a;
        double r761393 = r761392 / r761390;
        double r761394 = r761391 - r761393;
        double r761395 = x;
        double r761396 = y;
        double r761397 = r761395 * r761396;
        double r761398 = r761382 * r761389;
        double r761399 = -r761392;
        double r761400 = r761382 * r761399;
        double r761401 = r761398 + r761400;
        double r761402 = r761397 + r761401;
        double r761403 = r761390 - r761396;
        double r761404 = fma(r761382, r761403, r761396);
        double r761405 = r761402 / r761404;
        double r761406 = r761388 ? r761394 : r761405;
        return r761406;
}

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)))))