Average Error: 22.8 → 19.5
Time: 6.7s
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 -4.02825971946509575 \cdot 10^{45} \lor \neg \left(z \le 4.6637145007917988 \cdot 10^{160}\right):\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y + \left(t - a\right) \cdot z}{y + z \cdot \left(b - 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 -4.02825971946509575 \cdot 10^{45} \lor \neg \left(z \le 4.6637145007917988 \cdot 10^{160}\right):\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r703412 = x;
        double r703413 = y;
        double r703414 = r703412 * r703413;
        double r703415 = z;
        double r703416 = t;
        double r703417 = a;
        double r703418 = r703416 - r703417;
        double r703419 = r703415 * r703418;
        double r703420 = r703414 + r703419;
        double r703421 = b;
        double r703422 = r703421 - r703413;
        double r703423 = r703415 * r703422;
        double r703424 = r703413 + r703423;
        double r703425 = r703420 / r703424;
        return r703425;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r703426 = z;
        double r703427 = -4.028259719465096e+45;
        bool r703428 = r703426 <= r703427;
        double r703429 = 4.663714500791799e+160;
        bool r703430 = r703426 <= r703429;
        double r703431 = !r703430;
        bool r703432 = r703428 || r703431;
        double r703433 = t;
        double r703434 = b;
        double r703435 = r703433 / r703434;
        double r703436 = a;
        double r703437 = r703436 / r703434;
        double r703438 = r703435 - r703437;
        double r703439 = x;
        double r703440 = y;
        double r703441 = r703439 * r703440;
        double r703442 = r703433 - r703436;
        double r703443 = r703442 * r703426;
        double r703444 = r703441 + r703443;
        double r703445 = r703434 - r703440;
        double r703446 = r703426 * r703445;
        double r703447 = r703440 + r703446;
        double r703448 = r703444 / r703447;
        double r703449 = r703432 ? r703438 : r703448;
        return r703449;
}

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
Herbie19.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 2 regimes
  2. if z < -4.028259719465096e+45 or 4.663714500791799e+160 < z

    1. Initial program 44.8

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

      \[\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-num44.8

      \[\leadsto \color{blue}{\frac{1}{\frac{y + z \cdot \left(b - y\right)}{x \cdot y + \left(t - a\right) \cdot z}}}\]
    6. Simplified44.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 34.8

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

    if -4.028259719465096e+45 < z < 4.663714500791799e+160

    1. Initial program 12.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.02825971946509575 \cdot 10^{45} \lor \neg \left(z \le 4.6637145007917988 \cdot 10^{160}\right):\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y + \left(t - a\right) \cdot z}{y + z \cdot \left(b - y\right)}\\ \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)))))