Average Error: 22.4 → 20.5
Time: 25.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}\;z \le -5.062409672741701 \cdot 10^{+211}:\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{elif}\;z \le -1.5073212909314457 \cdot 10^{-240}:\\ \;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(z, b - y, y\right)}{\mathsf{fma}\left(y, x, z \cdot \left(t - a\right)\right)}}\\ \mathbf{elif}\;z \le 5.972417992529298 \cdot 10^{-285}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \le 8.879606465820762 \cdot 10^{+192}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(z, b - y, y\right)} \cdot \mathsf{fma}\left(y, x, z \cdot \left(t - a\right)\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}\;z \le -5.062409672741701 \cdot 10^{+211}:\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

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

\mathbf{elif}\;z \le 5.972417992529298 \cdot 10^{-285}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \le 8.879606465820762 \cdot 10^{+192}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(z, b - y, y\right)} \cdot \mathsf{fma}\left(y, x, z \cdot \left(t - a\right)\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 r33922974 = x;
        double r33922975 = y;
        double r33922976 = r33922974 * r33922975;
        double r33922977 = z;
        double r33922978 = t;
        double r33922979 = a;
        double r33922980 = r33922978 - r33922979;
        double r33922981 = r33922977 * r33922980;
        double r33922982 = r33922976 + r33922981;
        double r33922983 = b;
        double r33922984 = r33922983 - r33922975;
        double r33922985 = r33922977 * r33922984;
        double r33922986 = r33922975 + r33922985;
        double r33922987 = r33922982 / r33922986;
        return r33922987;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r33922988 = z;
        double r33922989 = -5.062409672741701e+211;
        bool r33922990 = r33922988 <= r33922989;
        double r33922991 = t;
        double r33922992 = b;
        double r33922993 = r33922991 / r33922992;
        double r33922994 = a;
        double r33922995 = r33922994 / r33922992;
        double r33922996 = r33922993 - r33922995;
        double r33922997 = -1.5073212909314457e-240;
        bool r33922998 = r33922988 <= r33922997;
        double r33922999 = 1.0;
        double r33923000 = y;
        double r33923001 = r33922992 - r33923000;
        double r33923002 = fma(r33922988, r33923001, r33923000);
        double r33923003 = x;
        double r33923004 = r33922991 - r33922994;
        double r33923005 = r33922988 * r33923004;
        double r33923006 = fma(r33923000, r33923003, r33923005);
        double r33923007 = r33923002 / r33923006;
        double r33923008 = r33922999 / r33923007;
        double r33923009 = 5.972417992529298e-285;
        bool r33923010 = r33922988 <= r33923009;
        double r33923011 = 8.879606465820762e+192;
        bool r33923012 = r33922988 <= r33923011;
        double r33923013 = r33922999 / r33923002;
        double r33923014 = r33923013 * r33923006;
        double r33923015 = r33923012 ? r33923014 : r33922996;
        double r33923016 = r33923010 ? r33923003 : r33923015;
        double r33923017 = r33922998 ? r33923008 : r33923016;
        double r33923018 = r33922990 ? r33922996 : r33923017;
        return r33923018;
}

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.4
Target17.5
Herbie20.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 4 regimes
  2. if z < -5.062409672741701e+211 or 8.879606465820762e+192 < z

    1. Initial program 50.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-num50.1

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

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

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

    if -5.062409672741701e+211 < z < -1.5073212909314457e-240

    1. Initial program 19.4

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

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

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

    if -1.5073212909314457e-240 < z < 5.972417992529298e-285

    1. Initial program 8.3

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

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

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

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

    if 5.972417992529298e-285 < z < 8.879606465820762e+192

    1. Initial program 16.6

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.062409672741701 \cdot 10^{+211}:\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{elif}\;z \le -1.5073212909314457 \cdot 10^{-240}:\\ \;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(z, b - y, y\right)}{\mathsf{fma}\left(y, x, z \cdot \left(t - a\right)\right)}}\\ \mathbf{elif}\;z \le 5.972417992529298 \cdot 10^{-285}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \le 8.879606465820762 \cdot 10^{+192}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(z, b - y, y\right)} \cdot \mathsf{fma}\left(y, x, z \cdot \left(t - a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \end{array}\]

Reproduce

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