Average Error: 23.0 → 19.7
Time: 18.2s
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.751098162580149858529317868152964325926 \cdot 10^{193} \lor \neg \left(z \le 2.89959794352647690190761523964510727606 \cdot 10^{68}\right):\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)}{\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.751098162580149858529317868152964325926 \cdot 10^{193} \lor \neg \left(z \le 2.89959794352647690190761523964510727606 \cdot 10^{68}\right):\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)}{\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 r680918 = x;
        double r680919 = y;
        double r680920 = r680918 * r680919;
        double r680921 = z;
        double r680922 = t;
        double r680923 = a;
        double r680924 = r680922 - r680923;
        double r680925 = r680921 * r680924;
        double r680926 = r680920 + r680925;
        double r680927 = b;
        double r680928 = r680927 - r680919;
        double r680929 = r680921 * r680928;
        double r680930 = r680919 + r680929;
        double r680931 = r680926 / r680930;
        return r680931;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r680932 = z;
        double r680933 = -1.7510981625801499e+193;
        bool r680934 = r680932 <= r680933;
        double r680935 = 2.899597943526477e+68;
        bool r680936 = r680932 <= r680935;
        double r680937 = !r680936;
        bool r680938 = r680934 || r680937;
        double r680939 = t;
        double r680940 = b;
        double r680941 = r680939 / r680940;
        double r680942 = a;
        double r680943 = r680942 / r680940;
        double r680944 = r680941 - r680943;
        double r680945 = x;
        double r680946 = y;
        double r680947 = r680939 - r680942;
        double r680948 = r680932 * r680947;
        double r680949 = fma(r680945, r680946, r680948);
        double r680950 = r680940 - r680946;
        double r680951 = fma(r680932, r680950, r680946);
        double r680952 = r680949 / r680951;
        double r680953 = r680938 ? r680944 : r680952;
        return r680953;
}

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.0
Target17.8
Herbie19.7
\[\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.7510981625801499e+193 or 2.899597943526477e+68 < z

    1. Initial program 46.3

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

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

    if -1.7510981625801499e+193 < z < 2.899597943526477e+68

    1. Initial program 14.4

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

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

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

      \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)\right)}^{1}} \cdot {\left(\frac{1}{\mathsf{fma}\left(z, b - y, y\right)}\right)}^{1}\]
    8. Applied pow-prod-down14.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.751098162580149858529317868152964325926 \cdot 10^{193} \lor \neg \left(z \le 2.89959794352647690190761523964510727606 \cdot 10^{68}\right):\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)}{\mathsf{fma}\left(z, b - y, y\right)}\\ \end{array}\]

Reproduce

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