Average Error: 23.8 → 18.6
Time: 7.9s
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)} \le -2.79673673651931108 \cdot 10^{302}:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le -7.49345867746150626 \cdot 10^{-260}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(z, b - y, y\right)} \cdot \mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\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 6.3783135830699213 \cdot 10^{296}:\\ \;\;\;\;\frac{1}{\frac{y + z \cdot \left(b - y\right)}{x \cdot y + z \cdot \left(t - a\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}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le -2.79673673651931108 \cdot 10^{302}:\\
\;\;\;\;x\\

\mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le -7.49345867746150626 \cdot 10^{-260}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(z, b - y, y\right)} \cdot \mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\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 6.3783135830699213 \cdot 10^{296}:\\
\;\;\;\;\frac{1}{\frac{y + z \cdot \left(b - y\right)}{x \cdot y + z \cdot \left(t - a\right)}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r861386 = x;
        double r861387 = y;
        double r861388 = r861386 * r861387;
        double r861389 = z;
        double r861390 = t;
        double r861391 = a;
        double r861392 = r861390 - r861391;
        double r861393 = r861389 * r861392;
        double r861394 = r861388 + r861393;
        double r861395 = b;
        double r861396 = r861395 - r861387;
        double r861397 = r861389 * r861396;
        double r861398 = r861387 + r861397;
        double r861399 = r861394 / r861398;
        return r861399;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r861400 = x;
        double r861401 = y;
        double r861402 = r861400 * r861401;
        double r861403 = z;
        double r861404 = t;
        double r861405 = a;
        double r861406 = r861404 - r861405;
        double r861407 = r861403 * r861406;
        double r861408 = r861402 + r861407;
        double r861409 = b;
        double r861410 = r861409 - r861401;
        double r861411 = r861403 * r861410;
        double r861412 = r861401 + r861411;
        double r861413 = r861408 / r861412;
        double r861414 = -2.796736736519311e+302;
        bool r861415 = r861413 <= r861414;
        double r861416 = -7.493458677461506e-260;
        bool r861417 = r861413 <= r861416;
        double r861418 = 1.0;
        double r861419 = fma(r861403, r861410, r861401);
        double r861420 = r861418 / r861419;
        double r861421 = fma(r861400, r861401, r861407);
        double r861422 = r861420 * r861421;
        double r861423 = 0.0;
        bool r861424 = r861413 <= r861423;
        double r861425 = r861404 / r861409;
        double r861426 = r861405 / r861409;
        double r861427 = r861425 - r861426;
        double r861428 = 6.378313583069921e+296;
        bool r861429 = r861413 <= r861428;
        double r861430 = r861412 / r861408;
        double r861431 = r861418 / r861430;
        double r861432 = r861429 ? r861431 : r861400;
        double r861433 = r861424 ? r861427 : r861432;
        double r861434 = r861417 ? r861422 : r861433;
        double r861435 = r861415 ? r861400 : r861434;
        return r861435;
}

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.8
Target18.6
Herbie18.6
\[\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 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) < -2.796736736519311e+302 or 6.378313583069921e+296 < (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y))))

    1. Initial program 62.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-num62.9

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

      \[\leadsto \frac{1}{\color{blue}{\left(y + z \cdot \left(b - y\right)\right) \cdot \frac{1}{x \cdot y + z \cdot \left(t - a\right)}}}\]
    6. Applied add-cube-cbrt62.9

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\left(y + z \cdot \left(b - y\right)\right) \cdot \frac{1}{x \cdot y + z \cdot \left(t - a\right)}}\]
    7. Applied times-frac62.9

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

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

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

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

    if -2.796736736519311e+302 < (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) < -7.493458677461506e-260

    1. Initial program 0.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-num0.5

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

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

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\left(y + z \cdot \left(b - y\right)\right) \cdot \frac{1}{x \cdot y + z \cdot \left(t - a\right)}}\]
    7. Applied times-frac0.6

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

      \[\leadsto \color{blue}{\frac{1}{\mathsf{fma}\left(z, b - y, y\right)}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{x \cdot y + z \cdot \left(t - a\right)}}\]
    9. Simplified0.5

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

    if -7.493458677461506e-260 < (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) < 0.0

    1. Initial program 42.1

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(y + z \cdot \left(b - y\right)\right) \cdot \frac{1}{x \cdot y + z \cdot \left(t - a\right)}}}\]
    6. Applied add-cube-cbrt42.3

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\left(y + z \cdot \left(b - y\right)\right) \cdot \frac{1}{x \cdot y + z \cdot \left(t - a\right)}}\]
    7. Applied times-frac42.1

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

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

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

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

    if 0.0 < (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) < 6.378313583069921e+296

    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 clear-num0.5

      \[\leadsto \color{blue}{\frac{1}{\frac{y + z \cdot \left(b - y\right)}{x \cdot y + z \cdot \left(t - a\right)}}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification18.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le -2.79673673651931108 \cdot 10^{302}:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \le -7.49345867746150626 \cdot 10^{-260}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(z, b - y, y\right)} \cdot \mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\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 6.3783135830699213 \cdot 10^{296}:\\ \;\;\;\;\frac{1}{\frac{y + z \cdot \left(b - y\right)}{x \cdot y + z \cdot \left(t - a\right)}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]

Reproduce

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