Average Error: 23.3 → 19.1
Time: 23.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 r375651 = x;
        double r375652 = y;
        double r375653 = r375651 * r375652;
        double r375654 = z;
        double r375655 = t;
        double r375656 = a;
        double r375657 = r375655 - r375656;
        double r375658 = r375654 * r375657;
        double r375659 = r375653 + r375658;
        double r375660 = b;
        double r375661 = r375660 - r375652;
        double r375662 = r375654 * r375661;
        double r375663 = r375652 + r375662;
        double r375664 = r375659 / r375663;
        return r375664;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r375665 = z;
        double r375666 = -4.98837196482088e+105;
        bool r375667 = r375665 <= r375666;
        double r375668 = 1.2335128510508918e+130;
        bool r375669 = r375665 <= r375668;
        double r375670 = !r375669;
        bool r375671 = r375667 || r375670;
        double r375672 = t;
        double r375673 = b;
        double r375674 = r375672 / r375673;
        double r375675 = a;
        double r375676 = r375675 / r375673;
        double r375677 = r375674 - r375676;
        double r375678 = x;
        double r375679 = y;
        double r375680 = r375672 - r375675;
        double r375681 = r375665 * r375680;
        double r375682 = fma(r375678, r375679, r375681);
        double r375683 = 1.0;
        double r375684 = r375673 - r375679;
        double r375685 = fma(r375665, r375684, r375679);
        double r375686 = r375683 / r375685;
        double r375687 = r375682 * r375686;
        double r375688 = r375671 ? r375677 : r375687;
        return r375688;
}

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)))))