Average Error: 23.4 → 19.5
Time: 14.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 -6.299569873792321719916781138767649824049 \cdot 10^{186} \lor \neg \left(z \le 7.111957851088666958846129400756682389184 \cdot 10^{107}\right):\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(t - a, z, y \cdot x\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 -6.299569873792321719916781138767649824049 \cdot 10^{186} \lor \neg \left(z \le 7.111957851088666958846129400756682389184 \cdot 10^{107}\right):\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t - a, z, y \cdot x\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 r1251212 = x;
        double r1251213 = y;
        double r1251214 = r1251212 * r1251213;
        double r1251215 = z;
        double r1251216 = t;
        double r1251217 = a;
        double r1251218 = r1251216 - r1251217;
        double r1251219 = r1251215 * r1251218;
        double r1251220 = r1251214 + r1251219;
        double r1251221 = b;
        double r1251222 = r1251221 - r1251213;
        double r1251223 = r1251215 * r1251222;
        double r1251224 = r1251213 + r1251223;
        double r1251225 = r1251220 / r1251224;
        return r1251225;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1251226 = z;
        double r1251227 = -6.299569873792322e+186;
        bool r1251228 = r1251226 <= r1251227;
        double r1251229 = 7.111957851088667e+107;
        bool r1251230 = r1251226 <= r1251229;
        double r1251231 = !r1251230;
        bool r1251232 = r1251228 || r1251231;
        double r1251233 = t;
        double r1251234 = b;
        double r1251235 = r1251233 / r1251234;
        double r1251236 = a;
        double r1251237 = r1251236 / r1251234;
        double r1251238 = r1251235 - r1251237;
        double r1251239 = r1251233 - r1251236;
        double r1251240 = y;
        double r1251241 = x;
        double r1251242 = r1251240 * r1251241;
        double r1251243 = fma(r1251239, r1251226, r1251242);
        double r1251244 = r1251234 - r1251240;
        double r1251245 = fma(r1251226, r1251244, r1251240);
        double r1251246 = r1251243 / r1251245;
        double r1251247 = r1251232 ? r1251238 : r1251246;
        return r1251247;
}

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.4
Target18.2
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 < -6.299569873792322e+186 or 7.111957851088667e+107 < 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 32.7

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

    if -6.299569873792322e+186 < z < 7.111957851088667e+107

    1. Initial program 15.1

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

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

      \[\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. Using strategy rm
    6. Applied associate-/r/15.2

      \[\leadsto \color{blue}{\frac{1}{\mathsf{fma}\left(z, b - y, y\right)} \cdot \mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity15.2

      \[\leadsto \frac{1}{\color{blue}{1 \cdot \mathsf{fma}\left(z, b - y, y\right)}} \cdot \mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)\]
    9. Applied *-un-lft-identity15.2

      \[\leadsto \frac{\color{blue}{1 \cdot 1}}{1 \cdot \mathsf{fma}\left(z, b - y, y\right)} \cdot \mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)\]
    10. Applied times-frac15.2

      \[\leadsto \color{blue}{\left(\frac{1}{1} \cdot \frac{1}{\mathsf{fma}\left(z, b - y, y\right)}\right)} \cdot \mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)\]
    11. Applied associate-*l*15.2

      \[\leadsto \color{blue}{\frac{1}{1} \cdot \left(\frac{1}{\mathsf{fma}\left(z, b - y, y\right)} \cdot \mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)\right)}\]
    12. Simplified15.1

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

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

Reproduce

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