Average Error: 23.3 → 19.1
Time: 26.3s
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.988371964820880469700793496719732359235 \cdot 10^{105} \lor \neg \left(z \le 1.233512851050891765045306855779556737944 \cdot 10^{130}\right):\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right) \cdot \frac{1}{\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.988371964820880469700793496719732359235 \cdot 10^{105} \lor \neg \left(z \le 1.233512851050891765045306855779556737944 \cdot 10^{130}\right):\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right) \cdot \frac{1}{\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 r653487 = x;
        double r653488 = y;
        double r653489 = r653487 * r653488;
        double r653490 = z;
        double r653491 = t;
        double r653492 = a;
        double r653493 = r653491 - r653492;
        double r653494 = r653490 * r653493;
        double r653495 = r653489 + r653494;
        double r653496 = b;
        double r653497 = r653496 - r653488;
        double r653498 = r653490 * r653497;
        double r653499 = r653488 + r653498;
        double r653500 = r653495 / r653499;
        return r653500;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r653501 = z;
        double r653502 = -4.98837196482088e+105;
        bool r653503 = r653501 <= r653502;
        double r653504 = 1.2335128510508918e+130;
        bool r653505 = r653501 <= r653504;
        double r653506 = !r653505;
        bool r653507 = r653503 || r653506;
        double r653508 = t;
        double r653509 = b;
        double r653510 = r653508 / r653509;
        double r653511 = a;
        double r653512 = r653511 / r653509;
        double r653513 = r653510 - r653512;
        double r653514 = x;
        double r653515 = y;
        double r653516 = r653508 - r653511;
        double r653517 = r653501 * r653516;
        double r653518 = fma(r653514, r653515, r653517);
        double r653519 = 1.0;
        double r653520 = r653509 - r653515;
        double r653521 = fma(r653501, r653520, r653515);
        double r653522 = r653519 / r653521;
        double r653523 = r653518 * r653522;
        double r653524 = r653507 ? r653513 : r653523;
        return r653524;
}

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.3
Target18.1
Herbie19.1
\[\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.98837196482088e+105 or 1.2335128510508918e+130 < z

    1. Initial program 48.3

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

      \[\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-num48.3

      \[\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 34.4

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

    if -4.98837196482088e+105 < z < 1.2335128510508918e+130

    1. Initial program 12.2

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

      \[\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 div-inv12.3

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

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

Reproduce

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