Average Error: 23.3 → 14.9
Time: 7.6s
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 -4.12381440738366815 \cdot 10^{-284}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t - a\right)}{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 2.10255424928362 \cdot 10^{302}:\\ \;\;\;\;\left(x \cdot y + z \cdot \left(t - a\right)\right) \cdot \frac{1}{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 -4.12381440738366815 \cdot 10^{-284}:\\
\;\;\;\;\frac{x \cdot y + z \cdot \left(t - a\right)}{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 2.10255424928362 \cdot 10^{302}:\\
\;\;\;\;\left(x \cdot y + z \cdot \left(t - a\right)\right) \cdot \frac{1}{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 r905306 = x;
        double r905307 = y;
        double r905308 = r905306 * r905307;
        double r905309 = z;
        double r905310 = t;
        double r905311 = a;
        double r905312 = r905310 - r905311;
        double r905313 = r905309 * r905312;
        double r905314 = r905308 + r905313;
        double r905315 = b;
        double r905316 = r905315 - r905307;
        double r905317 = r905309 * r905316;
        double r905318 = r905307 + r905317;
        double r905319 = r905314 / r905318;
        return r905319;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r905320 = x;
        double r905321 = y;
        double r905322 = r905320 * r905321;
        double r905323 = z;
        double r905324 = t;
        double r905325 = a;
        double r905326 = r905324 - r905325;
        double r905327 = r905323 * r905326;
        double r905328 = r905322 + r905327;
        double r905329 = b;
        double r905330 = r905329 - r905321;
        double r905331 = r905323 * r905330;
        double r905332 = r905321 + r905331;
        double r905333 = r905328 / r905332;
        double r905334 = -inf.0;
        bool r905335 = r905333 <= r905334;
        double r905336 = -4.123814407383668e-284;
        bool r905337 = r905333 <= r905336;
        double r905338 = -0.0;
        bool r905339 = r905333 <= r905338;
        double r905340 = r905324 / r905329;
        double r905341 = r905325 / r905329;
        double r905342 = r905340 - r905341;
        double r905343 = 2.1025542492836204e+302;
        bool r905344 = r905333 <= r905343;
        double r905345 = 1.0;
        double r905346 = r905345 / r905332;
        double r905347 = r905328 * r905346;
        double r905348 = r905344 ? r905347 : r905342;
        double r905349 = r905339 ? r905342 : r905348;
        double r905350 = r905337 ? r905333 : r905349;
        double r905351 = r905335 ? r905320 : r905350;
        return r905351;
}

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

Original23.3
Target18.1
Herbie14.9
\[\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)))) < -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 clear-num64.0

      \[\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-inv64.0

      \[\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 associate-/r*64.0

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

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

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

    if -inf.0 < (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) < -4.123814407383668e-284

    1. Initial program 0.4

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

    if -4.123814407383668e-284 < (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) < -0.0 or 2.1025542492836204e+302 < (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y))))

    1. Initial program 60.2

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

      \[\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-inv60.2

      \[\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 associate-/r*60.2

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

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

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

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

    1. Initial program 5.9

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

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

    \[\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 -4.12381440738366815 \cdot 10^{-284}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t - a\right)}{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 2.10255424928362 \cdot 10^{302}:\\ \;\;\;\;\left(x \cdot y + z \cdot \left(t - a\right)\right) \cdot \frac{1}{y + z \cdot \left(b - y\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \end{array}\]

Reproduce

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