Average Error: 22.8 → 21.5
Time: 1.9m
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 -8.17254112775349194 \cdot 10^{35}:\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(z, b - y, y\right)}{\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\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 -8.17254112775349194 \cdot 10^{35}:\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r1659862 = x;
        double r1659863 = y;
        double r1659864 = r1659862 * r1659863;
        double r1659865 = z;
        double r1659866 = t;
        double r1659867 = a;
        double r1659868 = r1659866 - r1659867;
        double r1659869 = r1659865 * r1659868;
        double r1659870 = r1659864 + r1659869;
        double r1659871 = b;
        double r1659872 = r1659871 - r1659863;
        double r1659873 = r1659865 * r1659872;
        double r1659874 = r1659863 + r1659873;
        double r1659875 = r1659870 / r1659874;
        return r1659875;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1659876 = z;
        double r1659877 = -8.172541127753492e+35;
        bool r1659878 = r1659876 <= r1659877;
        double r1659879 = t;
        double r1659880 = b;
        double r1659881 = r1659879 / r1659880;
        double r1659882 = a;
        double r1659883 = r1659882 / r1659880;
        double r1659884 = r1659881 - r1659883;
        double r1659885 = 1.0;
        double r1659886 = y;
        double r1659887 = r1659880 - r1659886;
        double r1659888 = fma(r1659876, r1659887, r1659886);
        double r1659889 = x;
        double r1659890 = r1659879 - r1659882;
        double r1659891 = r1659876 * r1659890;
        double r1659892 = fma(r1659889, r1659886, r1659891);
        double r1659893 = r1659888 / r1659892;
        double r1659894 = r1659885 / r1659893;
        double r1659895 = r1659878 ? r1659884 : r1659894;
        return r1659895;
}

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

Original22.8
Target18.0
Herbie21.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 < -8.172541127753492e+35

    1. Initial program 41.0

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

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

      \[\leadsto \frac{1}{\color{blue}{\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 34.4

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

    if -8.172541127753492e+35 < z

    1. Initial program 17.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -8.17254112775349194 \cdot 10^{35}:\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(z, b - y, y\right)}{\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)}}\\ \end{array}\]

Reproduce

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