Average Error: 23.3 → 19.1
Time: 27.6s
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.38322835723796380516786120602979593777 \cdot 10^{135} \lor \neg \left(z \le 5.115612150638236515910171343054123777678 \cdot 10^{154}\right):\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, y, z \cdot t + z \cdot \left(-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}\;z \le -1.38322835723796380516786120602979593777 \cdot 10^{135} \lor \neg \left(z \le 5.115612150638236515910171343054123777678 \cdot 10^{154}\right):\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, y, z \cdot t + z \cdot \left(-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 r1188729 = x;
        double r1188730 = y;
        double r1188731 = r1188729 * r1188730;
        double r1188732 = z;
        double r1188733 = t;
        double r1188734 = a;
        double r1188735 = r1188733 - r1188734;
        double r1188736 = r1188732 * r1188735;
        double r1188737 = r1188731 + r1188736;
        double r1188738 = b;
        double r1188739 = r1188738 - r1188730;
        double r1188740 = r1188732 * r1188739;
        double r1188741 = r1188730 + r1188740;
        double r1188742 = r1188737 / r1188741;
        return r1188742;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1188743 = z;
        double r1188744 = -1.3832283572379638e+135;
        bool r1188745 = r1188743 <= r1188744;
        double r1188746 = 5.1156121506382365e+154;
        bool r1188747 = r1188743 <= r1188746;
        double r1188748 = !r1188747;
        bool r1188749 = r1188745 || r1188748;
        double r1188750 = t;
        double r1188751 = b;
        double r1188752 = r1188750 / r1188751;
        double r1188753 = a;
        double r1188754 = r1188753 / r1188751;
        double r1188755 = r1188752 - r1188754;
        double r1188756 = x;
        double r1188757 = y;
        double r1188758 = r1188743 * r1188750;
        double r1188759 = -r1188753;
        double r1188760 = r1188743 * r1188759;
        double r1188761 = r1188758 + r1188760;
        double r1188762 = fma(r1188756, r1188757, r1188761);
        double r1188763 = 1.0;
        double r1188764 = r1188751 - r1188757;
        double r1188765 = fma(r1188743, r1188764, r1188757);
        double r1188766 = r1188763 / r1188765;
        double r1188767 = r1188762 * r1188766;
        double r1188768 = r1188749 ? r1188755 : r1188767;
        return r1188768;
}

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.3
Target18.1
Herbie19.1
\[\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.3832283572379638e+135 or 5.1156121506382365e+154 < z

    1. Initial program 49.3

      \[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\]
    2. Simplified49.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 clear-num49.3

      \[\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.1

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

    if -1.3832283572379638e+135 < z < 5.1156121506382365e+154

    1. Initial program 14.0

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

      \[\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-inv14.1

      \[\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)}}\]
    5. Using strategy rm
    6. Applied sub-neg14.1

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

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

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

Reproduce

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