Average Error: 23.1 → 19.0
Time: 15.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}\;z \le -4.1178756981023261 \cdot 10^{79} \lor \neg \left(z \le 1.00381656030254721 \cdot 10^{167}\right):\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y, t \cdot z + \left(-a\right) \cdot z\right)}{\mathsf{fma}\left(z, b - y, 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.1178756981023261 \cdot 10^{79} \lor \neg \left(z \le 1.00381656030254721 \cdot 10^{167}\right):\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r836334 = x;
        double r836335 = y;
        double r836336 = r836334 * r836335;
        double r836337 = z;
        double r836338 = t;
        double r836339 = a;
        double r836340 = r836338 - r836339;
        double r836341 = r836337 * r836340;
        double r836342 = r836336 + r836341;
        double r836343 = b;
        double r836344 = r836343 - r836335;
        double r836345 = r836337 * r836344;
        double r836346 = r836335 + r836345;
        double r836347 = r836342 / r836346;
        return r836347;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r836348 = z;
        double r836349 = -4.117875698102326e+79;
        bool r836350 = r836348 <= r836349;
        double r836351 = 1.0038165603025472e+167;
        bool r836352 = r836348 <= r836351;
        double r836353 = !r836352;
        bool r836354 = r836350 || r836353;
        double r836355 = t;
        double r836356 = b;
        double r836357 = r836355 / r836356;
        double r836358 = a;
        double r836359 = r836358 / r836356;
        double r836360 = r836357 - r836359;
        double r836361 = x;
        double r836362 = y;
        double r836363 = r836355 * r836348;
        double r836364 = -r836358;
        double r836365 = r836364 * r836348;
        double r836366 = r836363 + r836365;
        double r836367 = fma(r836361, r836362, r836366);
        double r836368 = r836356 - r836362;
        double r836369 = fma(r836348, r836368, r836362);
        double r836370 = r836367 / r836369;
        double r836371 = r836354 ? r836360 : r836370;
        return r836371;
}

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.1
Target18.0
Herbie19.0
\[\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.117875698102326e+79 or 1.0038165603025472e+167 < z

    1. Initial program 47.5

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)}{\mathsf{fma}\left(z, b - y, y\right)}}\]
    3. Using strategy rm
    4. Applied clear-num47.5

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

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

    if -4.117875698102326e+79 < z < 1.0038165603025472e+167

    1. Initial program 12.8

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)}{\mathsf{fma}\left(z, b - y, y\right)}}\]
    3. Using strategy rm
    4. Applied sub-neg12.8

      \[\leadsto \frac{\mathsf{fma}\left(x, y, z \cdot \color{blue}{\left(t + \left(-a\right)\right)}\right)}{\mathsf{fma}\left(z, b - y, y\right)}\]
    5. Applied distribute-lft-in12.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.1178756981023261 \cdot 10^{79} \lor \neg \left(z \le 1.00381656030254721 \cdot 10^{167}\right):\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y, t \cdot z + \left(-a\right) \cdot z\right)}{\mathsf{fma}\left(z, b - y, y\right)}\\ \end{array}\]

Reproduce

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