Average Error: 7.0 → 3.3
Time: 19.5s
Precision: 64
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1.0}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.0197481473119013 \cdot 10^{+88}:\\ \;\;\;\;\frac{\frac{y}{t} + x}{1.0 + x}\\ \mathbf{elif}\;z \le 6.1748496171283856 \cdot 10^{+57}:\\ \;\;\;\;\frac{x + \frac{\mathsf{fma}\left(z, y, -x\right)}{\mathsf{fma}\left(t, z, -x\right)}}{1.0 + x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{t} + x}{1.0 + x}\\ \end{array}\]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1.0}
\begin{array}{l}
\mathbf{if}\;z \le -1.0197481473119013 \cdot 10^{+88}:\\
\;\;\;\;\frac{\frac{y}{t} + x}{1.0 + x}\\

\mathbf{elif}\;z \le 6.1748496171283856 \cdot 10^{+57}:\\
\;\;\;\;\frac{x + \frac{\mathsf{fma}\left(z, y, -x\right)}{\mathsf{fma}\left(t, z, -x\right)}}{1.0 + x}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{t} + x}{1.0 + x}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r32909913 = x;
        double r32909914 = y;
        double r32909915 = z;
        double r32909916 = r32909914 * r32909915;
        double r32909917 = r32909916 - r32909913;
        double r32909918 = t;
        double r32909919 = r32909918 * r32909915;
        double r32909920 = r32909919 - r32909913;
        double r32909921 = r32909917 / r32909920;
        double r32909922 = r32909913 + r32909921;
        double r32909923 = 1.0;
        double r32909924 = r32909913 + r32909923;
        double r32909925 = r32909922 / r32909924;
        return r32909925;
}

double f(double x, double y, double z, double t) {
        double r32909926 = z;
        double r32909927 = -1.0197481473119013e+88;
        bool r32909928 = r32909926 <= r32909927;
        double r32909929 = y;
        double r32909930 = t;
        double r32909931 = r32909929 / r32909930;
        double r32909932 = x;
        double r32909933 = r32909931 + r32909932;
        double r32909934 = 1.0;
        double r32909935 = r32909934 + r32909932;
        double r32909936 = r32909933 / r32909935;
        double r32909937 = 6.1748496171283856e+57;
        bool r32909938 = r32909926 <= r32909937;
        double r32909939 = -r32909932;
        double r32909940 = fma(r32909926, r32909929, r32909939);
        double r32909941 = fma(r32909930, r32909926, r32909939);
        double r32909942 = r32909940 / r32909941;
        double r32909943 = r32909932 + r32909942;
        double r32909944 = r32909943 / r32909935;
        double r32909945 = r32909938 ? r32909944 : r32909936;
        double r32909946 = r32909928 ? r32909936 : r32909945;
        return r32909946;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original7.0
Target0.2
Herbie3.3
\[\frac{x + \left(\frac{y}{t - \frac{x}{z}} - \frac{x}{t \cdot z - x}\right)}{x + 1.0}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -1.0197481473119013e+88 or 6.1748496171283856e+57 < z

    1. Initial program 18.1

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1.0}\]
    2. Using strategy rm
    3. Applied fma-neg18.1

      \[\leadsto \frac{x + \frac{\color{blue}{\mathsf{fma}\left(y, z, -x\right)}}{t \cdot z - x}}{x + 1.0}\]
    4. Using strategy rm
    5. Applied div-inv18.2

      \[\leadsto \color{blue}{\left(x + \frac{\mathsf{fma}\left(y, z, -x\right)}{t \cdot z - x}\right) \cdot \frac{1}{x + 1.0}}\]
    6. Using strategy rm
    7. Applied associate-*r/18.1

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

      \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(z, y, -x\right)}{\mathsf{fma}\left(t, z, -x\right)} + x}}{x + 1.0}\]
    9. Taylor expanded around inf 7.9

      \[\leadsto \frac{\color{blue}{\frac{y}{t}} + x}{x + 1.0}\]

    if -1.0197481473119013e+88 < z < 6.1748496171283856e+57

    1. Initial program 0.7

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1.0}\]
    2. Using strategy rm
    3. Applied fma-neg0.7

      \[\leadsto \frac{x + \frac{\color{blue}{\mathsf{fma}\left(y, z, -x\right)}}{t \cdot z - x}}{x + 1.0}\]
    4. Using strategy rm
    5. Applied div-inv0.8

      \[\leadsto \color{blue}{\left(x + \frac{\mathsf{fma}\left(y, z, -x\right)}{t \cdot z - x}\right) \cdot \frac{1}{x + 1.0}}\]
    6. Using strategy rm
    7. Applied associate-*r/0.7

      \[\leadsto \color{blue}{\frac{\left(x + \frac{\mathsf{fma}\left(y, z, -x\right)}{t \cdot z - x}\right) \cdot 1}{x + 1.0}}\]
    8. Simplified0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.0197481473119013 \cdot 10^{+88}:\\ \;\;\;\;\frac{\frac{y}{t} + x}{1.0 + x}\\ \mathbf{elif}\;z \le 6.1748496171283856 \cdot 10^{+57}:\\ \;\;\;\;\frac{x + \frac{\mathsf{fma}\left(z, y, -x\right)}{\mathsf{fma}\left(t, z, -x\right)}}{1.0 + x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{t} + x}{1.0 + x}\\ \end{array}\]

Reproduce

herbie shell --seed 2019158 +o rules:numerics
(FPCore (x y z t)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, A"

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

  (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))