Average Error: 21.8 → 18.5
Time: 19.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 -3.46309436887537 \cdot 10^{+119}:\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{elif}\;z \le 1.8428426605187136 \cdot 10^{+116}:\\ \;\;\;\;\frac{\mathsf{fma}\left(t - a, z, x \cdot y\right)}{\mathsf{fma}\left(b - y, z, y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \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 -3.46309436887537 \cdot 10^{+119}:\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r31692558 = x;
        double r31692559 = y;
        double r31692560 = r31692558 * r31692559;
        double r31692561 = z;
        double r31692562 = t;
        double r31692563 = a;
        double r31692564 = r31692562 - r31692563;
        double r31692565 = r31692561 * r31692564;
        double r31692566 = r31692560 + r31692565;
        double r31692567 = b;
        double r31692568 = r31692567 - r31692559;
        double r31692569 = r31692561 * r31692568;
        double r31692570 = r31692559 + r31692569;
        double r31692571 = r31692566 / r31692570;
        return r31692571;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r31692572 = z;
        double r31692573 = -3.46309436887537e+119;
        bool r31692574 = r31692572 <= r31692573;
        double r31692575 = t;
        double r31692576 = b;
        double r31692577 = r31692575 / r31692576;
        double r31692578 = a;
        double r31692579 = r31692578 / r31692576;
        double r31692580 = r31692577 - r31692579;
        double r31692581 = 1.8428426605187136e+116;
        bool r31692582 = r31692572 <= r31692581;
        double r31692583 = r31692575 - r31692578;
        double r31692584 = x;
        double r31692585 = y;
        double r31692586 = r31692584 * r31692585;
        double r31692587 = fma(r31692583, r31692572, r31692586);
        double r31692588 = r31692576 - r31692585;
        double r31692589 = fma(r31692588, r31692572, r31692585);
        double r31692590 = r31692587 / r31692589;
        double r31692591 = r31692582 ? r31692590 : r31692580;
        double r31692592 = r31692574 ? r31692580 : r31692591;
        return r31692592;
}

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

Original21.8
Target16.9
Herbie18.5
\[\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 < -3.46309436887537e+119 or 1.8428426605187136e+116 < z

    1. Initial program 45.1

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

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

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

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

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

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

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

    if -3.46309436887537e+119 < z < 1.8428426605187136e+116

    1. Initial program 12.3

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

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

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

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

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

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

Reproduce

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

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

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