Average Error: 22.9 → 23.1
Time: 22.4s
Precision: 64
\[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.971825994473462967444916924423559119718 \cdot 10^{122}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \le -2.796826227540087352386099490764401515765 \cdot 10^{-172}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, x, \left(t - a\right) \cdot z\right)}{\mathsf{fma}\left(z, b - y, y\right)}\\ \mathbf{elif}\;y \le 5.963446547461525348794679545605033353565 \cdot 10^{-202}:\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{elif}\;y \le 2.0360845306702607886990471003994885178 \cdot 10^{199}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, x, \left(t - a\right) \cdot z\right)}{\mathsf{fma}\left(z, b - y, y\right)}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\begin{array}{l}
\mathbf{if}\;y \le -1.971825994473462967444916924423559119718 \cdot 10^{122}:\\
\;\;\;\;x\\

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

\mathbf{elif}\;y \le 5.963446547461525348794679545605033353565 \cdot 10^{-202}:\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

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

\mathbf{else}:\\
\;\;\;\;x\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r32934930 = x;
        double r32934931 = y;
        double r32934932 = r32934930 * r32934931;
        double r32934933 = z;
        double r32934934 = t;
        double r32934935 = a;
        double r32934936 = r32934934 - r32934935;
        double r32934937 = r32934933 * r32934936;
        double r32934938 = r32934932 + r32934937;
        double r32934939 = b;
        double r32934940 = r32934939 - r32934931;
        double r32934941 = r32934933 * r32934940;
        double r32934942 = r32934931 + r32934941;
        double r32934943 = r32934938 / r32934942;
        return r32934943;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r32934944 = y;
        double r32934945 = -1.971825994473463e+122;
        bool r32934946 = r32934944 <= r32934945;
        double r32934947 = x;
        double r32934948 = -2.7968262275400874e-172;
        bool r32934949 = r32934944 <= r32934948;
        double r32934950 = t;
        double r32934951 = a;
        double r32934952 = r32934950 - r32934951;
        double r32934953 = z;
        double r32934954 = r32934952 * r32934953;
        double r32934955 = fma(r32934944, r32934947, r32934954);
        double r32934956 = b;
        double r32934957 = r32934956 - r32934944;
        double r32934958 = fma(r32934953, r32934957, r32934944);
        double r32934959 = r32934955 / r32934958;
        double r32934960 = 5.963446547461525e-202;
        bool r32934961 = r32934944 <= r32934960;
        double r32934962 = r32934950 / r32934956;
        double r32934963 = r32934951 / r32934956;
        double r32934964 = r32934962 - r32934963;
        double r32934965 = 2.036084530670261e+199;
        bool r32934966 = r32934944 <= r32934965;
        double r32934967 = r32934966 ? r32934959 : r32934947;
        double r32934968 = r32934961 ? r32934964 : r32934967;
        double r32934969 = r32934949 ? r32934959 : r32934968;
        double r32934970 = r32934946 ? r32934947 : r32934969;
        return r32934970;
}

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.9
Target17.8
Herbie23.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 3 regimes
  2. if y < -1.971825994473463e+122 or 2.036084530670261e+199 < y

    1. Initial program 38.2

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

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

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

      \[\leadsto \color{blue}{x}\]

    if -1.971825994473463e+122 < y < -2.7968262275400874e-172 or 5.963446547461525e-202 < y < 2.036084530670261e+199

    1. Initial program 18.8

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

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

      \[\leadsto \frac{\mathsf{fma}\left(y, x, z \cdot \color{blue}{\left(t + \left(-a\right)\right)}\right)}{\mathsf{fma}\left(z, b - y, y\right)}\]
    5. Applied distribute-rgt-in18.8

      \[\leadsto \frac{\mathsf{fma}\left(y, x, \color{blue}{t \cdot z + \left(-a\right) \cdot z}\right)}{\mathsf{fma}\left(z, b - y, y\right)}\]
    6. Using strategy rm
    7. Applied div-inv18.9

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

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

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

    if -2.7968262275400874e-172 < y < 5.963446547461525e-202

    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(y, x, z \cdot \left(t - a\right)\right)}{\mathsf{fma}\left(z, b - y, y\right)}}\]
    3. Using strategy rm
    4. Applied clear-num14.9

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

      \[\leadsto \color{blue}{\frac{t}{b} - \frac{a}{b}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification23.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.971825994473462967444916924423559119718 \cdot 10^{122}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \le -2.796826227540087352386099490764401515765 \cdot 10^{-172}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, x, \left(t - a\right) \cdot z\right)}{\mathsf{fma}\left(z, b - y, y\right)}\\ \mathbf{elif}\;y \le 5.963446547461525348794679545605033353565 \cdot 10^{-202}:\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{elif}\;y \le 2.0360845306702607886990471003994885178 \cdot 10^{199}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, x, \left(t - a\right) \cdot z\right)}{\mathsf{fma}\left(z, b - y, y\right)}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]

Reproduce

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