Average Error: 23.0 → 18.7
Time: 20.2s
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 -2.228767006755458950046405946194866033764 \cdot 10^{134} \lor \neg \left(z \le 7.09460719462282912418965636980792050196 \cdot 10^{134}\right):\\ \;\;\;\;\frac{t}{b} - \frac{a}{b}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, x, \left(-z \cdot a\right) + t \cdot z\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 -2.228767006755458950046405946194866033764 \cdot 10^{134} \lor \neg \left(z \le 7.09460719462282912418965636980792050196 \cdot 10^{134}\right):\\
\;\;\;\;\frac{t}{b} - \frac{a}{b}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, x, \left(-z \cdot a\right) + t \cdot z\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 r676658 = x;
        double r676659 = y;
        double r676660 = r676658 * r676659;
        double r676661 = z;
        double r676662 = t;
        double r676663 = a;
        double r676664 = r676662 - r676663;
        double r676665 = r676661 * r676664;
        double r676666 = r676660 + r676665;
        double r676667 = b;
        double r676668 = r676667 - r676659;
        double r676669 = r676661 * r676668;
        double r676670 = r676659 + r676669;
        double r676671 = r676666 / r676670;
        return r676671;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r676672 = z;
        double r676673 = -2.228767006755459e+134;
        bool r676674 = r676672 <= r676673;
        double r676675 = 7.094607194622829e+134;
        bool r676676 = r676672 <= r676675;
        double r676677 = !r676676;
        bool r676678 = r676674 || r676677;
        double r676679 = t;
        double r676680 = b;
        double r676681 = r676679 / r676680;
        double r676682 = a;
        double r676683 = r676682 / r676680;
        double r676684 = r676681 - r676683;
        double r676685 = y;
        double r676686 = x;
        double r676687 = r676672 * r676682;
        double r676688 = -r676687;
        double r676689 = r676679 * r676672;
        double r676690 = r676688 + r676689;
        double r676691 = fma(r676685, r676686, r676690);
        double r676692 = 1.0;
        double r676693 = r676680 - r676685;
        double r676694 = fma(r676693, r676672, r676685);
        double r676695 = r676692 / r676694;
        double r676696 = r676691 * r676695;
        double r676697 = r676678 ? r676684 : r676696;
        return r676697;
}

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.0
Target17.8
Herbie18.7
\[\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 < -2.228767006755459e+134 or 7.094607194622829e+134 < z

    1. Initial program 48.0

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

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

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

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

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

    if -2.228767006755459e+134 < z < 7.094607194622829e+134

    1. Initial program 13.7

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

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

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

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019194 +o rules:numerics
(FPCore (x y z t a b)
  :name "Development.Shake.Progress:decay from shake-0.15.5"

  :herbie-target
  (- (/ (+ (* z t) (* y x)) (+ y (* z (- b y)))) (/ a (+ (- b y) (/ y z))))

  (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))