Average Error: 22.8 → 14.8
Time: 7.0s
Precision: 64
\[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} = -\infty:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le -3.1179243146321728 \cdot 10^{-291}:\\ \;\;\;\;\frac{x \cdot y + \left(t - a\right) \cdot z}{y + z \cdot \left(b - y\right)}\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le -0.0:\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le 3.0860807734783257 \cdot 10^{279}:\\ \;\;\;\;\frac{x \cdot y + \left(t - a\right) \cdot z}{y + z \cdot \left(b - 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}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} = -\infty:\\
\;\;\;\;x\\

\mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le -3.1179243146321728 \cdot 10^{-291}:\\
\;\;\;\;\frac{x \cdot y + \left(t - a\right) \cdot z}{y + z \cdot \left(b - y\right)}\\

\mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le -0.0:\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

\mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le 3.0860807734783257 \cdot 10^{279}:\\
\;\;\;\;\frac{x \cdot y + \left(t - a\right) \cdot z}{y + z \cdot \left(b - 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 r677818 = x;
        double r677819 = y;
        double r677820 = r677818 * r677819;
        double r677821 = z;
        double r677822 = t;
        double r677823 = a;
        double r677824 = r677822 - r677823;
        double r677825 = r677821 * r677824;
        double r677826 = r677820 + r677825;
        double r677827 = b;
        double r677828 = r677827 - r677819;
        double r677829 = r677821 * r677828;
        double r677830 = r677819 + r677829;
        double r677831 = r677826 / r677830;
        return r677831;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r677832 = x;
        double r677833 = y;
        double r677834 = r677832 * r677833;
        double r677835 = z;
        double r677836 = t;
        double r677837 = a;
        double r677838 = r677836 - r677837;
        double r677839 = r677835 * r677838;
        double r677840 = r677834 + r677839;
        double r677841 = b;
        double r677842 = r677841 - r677833;
        double r677843 = r677835 * r677842;
        double r677844 = r677833 + r677843;
        double r677845 = r677840 / r677844;
        double r677846 = -inf.0;
        bool r677847 = r677845 <= r677846;
        double r677848 = -3.1179243146321728e-291;
        bool r677849 = r677845 <= r677848;
        double r677850 = r677838 * r677835;
        double r677851 = r677834 + r677850;
        double r677852 = r677851 / r677844;
        double r677853 = -0.0;
        bool r677854 = r677845 <= r677853;
        double r677855 = r677836 / r677841;
        double r677856 = r677837 / r677841;
        double r677857 = r677855 - r677856;
        double r677858 = 3.0860807734783257e+279;
        bool r677859 = r677845 <= r677858;
        double r677860 = r677859 ? r677852 : r677857;
        double r677861 = r677854 ? r677857 : r677860;
        double r677862 = r677849 ? r677852 : r677861;
        double r677863 = r677847 ? r677832 : r677862;
        return r677863;
}

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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original22.8
Target17.7
Herbie14.8
\[\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 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) < -inf.0

    1. Initial program 64.0

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

      \[\leadsto \frac{x \cdot y + \color{blue}{\left(t - a\right) \cdot z}}{y + z \cdot \left(b - y\right)}\]
    4. Using strategy rm
    5. Applied clear-num64.0

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

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

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

    if -inf.0 < (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) < -3.1179243146321728e-291 or -0.0 < (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) < 3.0860807734783257e+279

    1. Initial program 0.3

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

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

    if -3.1179243146321728e-291 < (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) < -0.0 or 3.0860807734783257e+279 < (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y))))

    1. Initial program 56.7

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

      \[\leadsto \frac{x \cdot y + \color{blue}{\left(t - a\right) \cdot z}}{y + z \cdot \left(b - y\right)}\]
    4. Using strategy rm
    5. Applied clear-num56.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} = -\infty:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le -3.1179243146321728 \cdot 10^{-291}:\\ \;\;\;\;\frac{x \cdot y + \left(t - a\right) \cdot z}{y + z \cdot \left(b - y\right)}\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le -0.0:\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le 3.0860807734783257 \cdot 10^{279}:\\ \;\;\;\;\frac{x \cdot y + \left(t - a\right) \cdot z}{y + z \cdot \left(b - y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \end{array}\]

Reproduce

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