Average Error: 23.8 → 17.8
Time: 15.8s
Precision: 64
\[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le -1.0453105058496541 \cdot 10^{-301}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le 0.0 \lor \neg \left(\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le 1.9961735121647787 \cdot 10^{271}\right):\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right) \cdot \frac{1}{\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}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le -1.0453105058496541 \cdot 10^{-301}:\\
\;\;\;\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\\

\mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le 0.0 \lor \neg \left(\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le 1.9961735121647787 \cdot 10^{271}\right):\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right) \cdot \frac{1}{\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 r1027475 = x;
        double r1027476 = y;
        double r1027477 = r1027475 * r1027476;
        double r1027478 = z;
        double r1027479 = t;
        double r1027480 = a;
        double r1027481 = r1027479 - r1027480;
        double r1027482 = r1027478 * r1027481;
        double r1027483 = r1027477 + r1027482;
        double r1027484 = b;
        double r1027485 = r1027484 - r1027476;
        double r1027486 = r1027478 * r1027485;
        double r1027487 = r1027476 + r1027486;
        double r1027488 = r1027483 / r1027487;
        return r1027488;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1027489 = x;
        double r1027490 = y;
        double r1027491 = r1027489 * r1027490;
        double r1027492 = z;
        double r1027493 = t;
        double r1027494 = a;
        double r1027495 = r1027493 - r1027494;
        double r1027496 = r1027492 * r1027495;
        double r1027497 = r1027491 + r1027496;
        double r1027498 = b;
        double r1027499 = r1027498 - r1027490;
        double r1027500 = r1027492 * r1027499;
        double r1027501 = r1027490 + r1027500;
        double r1027502 = r1027497 / r1027501;
        double r1027503 = -1.045310505849654e-301;
        bool r1027504 = r1027502 <= r1027503;
        double r1027505 = 0.0;
        bool r1027506 = r1027502 <= r1027505;
        double r1027507 = 1.9961735121647787e+271;
        bool r1027508 = r1027502 <= r1027507;
        double r1027509 = !r1027508;
        bool r1027510 = r1027506 || r1027509;
        double r1027511 = r1027493 / r1027498;
        double r1027512 = r1027494 / r1027498;
        double r1027513 = r1027511 - r1027512;
        double r1027514 = fma(r1027489, r1027490, r1027496);
        double r1027515 = 1.0;
        double r1027516 = fma(r1027492, r1027499, r1027490);
        double r1027517 = r1027515 / r1027516;
        double r1027518 = r1027514 * r1027517;
        double r1027519 = r1027510 ? r1027513 : r1027518;
        double r1027520 = r1027504 ? r1027502 : r1027519;
        return r1027520;
}

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.2
Herbie17.8
\[\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 3 regimes
  2. if (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) < -1.045310505849654e-301

    1. Initial program 13.1

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

    if -1.045310505849654e-301 < (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) < 0.0 or 1.9961735121647787e+271 < (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y))))

    1. Initial program 56.8

      \[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\]
    2. Using strategy rm
    3. Applied clear-num56.8

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

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

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

    if 0.0 < (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) < 1.9961735121647787e+271

    1. Initial program 0.3

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

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

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

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

Reproduce

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