Average Error: 22.8 → 19.5
Time: 8.5s
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 -1.62478684761365408 \cdot 10^{159} \lor \neg \left(z \le 3.13193545973136145 \cdot 10^{239}\right):\\ \;\;\;\;1 \cdot \left(\frac{t}{b} - \frac{a}{b}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y + z \cdot \left(t - a\right)\right) \cdot \frac{1}{\mathsf{fma}\left(b - y, z, 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 -1.62478684761365408 \cdot 10^{159} \lor \neg \left(z \le 3.13193545973136145 \cdot 10^{239}\right):\\
\;\;\;\;1 \cdot \left(\frac{t}{b} - \frac{a}{b}\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r719293 = x;
        double r719294 = y;
        double r719295 = r719293 * r719294;
        double r719296 = z;
        double r719297 = t;
        double r719298 = a;
        double r719299 = r719297 - r719298;
        double r719300 = r719296 * r719299;
        double r719301 = r719295 + r719300;
        double r719302 = b;
        double r719303 = r719302 - r719294;
        double r719304 = r719296 * r719303;
        double r719305 = r719294 + r719304;
        double r719306 = r719301 / r719305;
        return r719306;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r719307 = z;
        double r719308 = -1.624786847613654e+159;
        bool r719309 = r719307 <= r719308;
        double r719310 = 3.1319354597313615e+239;
        bool r719311 = r719307 <= r719310;
        double r719312 = !r719311;
        bool r719313 = r719309 || r719312;
        double r719314 = 1.0;
        double r719315 = t;
        double r719316 = b;
        double r719317 = r719315 / r719316;
        double r719318 = a;
        double r719319 = r719318 / r719316;
        double r719320 = r719317 - r719319;
        double r719321 = r719314 * r719320;
        double r719322 = x;
        double r719323 = y;
        double r719324 = r719322 * r719323;
        double r719325 = r719315 - r719318;
        double r719326 = r719307 * r719325;
        double r719327 = r719324 + r719326;
        double r719328 = r719316 - r719323;
        double r719329 = fma(r719328, r719307, r719323);
        double r719330 = r719314 / r719329;
        double r719331 = r719327 * r719330;
        double r719332 = r719313 ? r719321 : r719331;
        return r719332;
}

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.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 < -1.624786847613654e+159 or 3.1319354597313615e+239 < z

    1. Initial program 50.9

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

      \[\leadsto \frac{x \cdot y + z \cdot \left(t - a\right)}{\color{blue}{1 \cdot \left(y + z \cdot \left(b - y\right)\right)}}\]
    4. Applied *-un-lft-identity50.9

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)}{\mathsf{fma}\left(b - y, z, y\right)}}\]
    8. Using strategy rm
    9. Applied clear-num50.9

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

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{t}{b} - \frac{a}{b}\right)}\]

    if -1.624786847613654e+159 < z < 3.1319354597313615e+239

    1. Initial program 16.8

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

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

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

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

Reproduce

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