Average Error: 16.0 → 14.3
Time: 4.8s
Precision: 64
\[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.2271249360064273 \cdot 10^{68}:\\ \;\;\;\;\left(x + \frac{y \cdot z}{t}\right) \cdot \frac{1}{\mathsf{fma}\left(\frac{y}{t}, b, a + 1\right)}\\ \mathbf{elif}\;b \le -8.62961878188986081 \cdot 10^{-237}:\\ \;\;\;\;\frac{x + y \cdot \frac{z}{t}}{\left(a + 1\right) + \frac{1}{\frac{t}{y \cdot b}}}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, a + 1\right)}\\ \end{array}\]
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\begin{array}{l}
\mathbf{if}\;b \le -1.2271249360064273 \cdot 10^{68}:\\
\;\;\;\;\left(x + \frac{y \cdot z}{t}\right) \cdot \frac{1}{\mathsf{fma}\left(\frac{y}{t}, b, a + 1\right)}\\

\mathbf{elif}\;b \le -8.62961878188986081 \cdot 10^{-237}:\\
\;\;\;\;\frac{x + y \cdot \frac{z}{t}}{\left(a + 1\right) + \frac{1}{\frac{t}{y \cdot b}}}\\

\mathbf{else}:\\
\;\;\;\;1 \cdot \frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, a + 1\right)}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r738044 = x;
        double r738045 = y;
        double r738046 = z;
        double r738047 = r738045 * r738046;
        double r738048 = t;
        double r738049 = r738047 / r738048;
        double r738050 = r738044 + r738049;
        double r738051 = a;
        double r738052 = 1.0;
        double r738053 = r738051 + r738052;
        double r738054 = b;
        double r738055 = r738045 * r738054;
        double r738056 = r738055 / r738048;
        double r738057 = r738053 + r738056;
        double r738058 = r738050 / r738057;
        return r738058;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r738059 = b;
        double r738060 = -1.2271249360064273e+68;
        bool r738061 = r738059 <= r738060;
        double r738062 = x;
        double r738063 = y;
        double r738064 = z;
        double r738065 = r738063 * r738064;
        double r738066 = t;
        double r738067 = r738065 / r738066;
        double r738068 = r738062 + r738067;
        double r738069 = 1.0;
        double r738070 = r738063 / r738066;
        double r738071 = a;
        double r738072 = 1.0;
        double r738073 = r738071 + r738072;
        double r738074 = fma(r738070, r738059, r738073);
        double r738075 = r738069 / r738074;
        double r738076 = r738068 * r738075;
        double r738077 = -8.629618781889861e-237;
        bool r738078 = r738059 <= r738077;
        double r738079 = r738064 / r738066;
        double r738080 = r738063 * r738079;
        double r738081 = r738062 + r738080;
        double r738082 = r738063 * r738059;
        double r738083 = r738066 / r738082;
        double r738084 = r738069 / r738083;
        double r738085 = r738073 + r738084;
        double r738086 = r738081 / r738085;
        double r738087 = fma(r738070, r738064, r738062);
        double r738088 = r738087 / r738074;
        double r738089 = r738069 * r738088;
        double r738090 = r738078 ? r738086 : r738089;
        double r738091 = r738061 ? r738076 : r738090;
        return r738091;
}

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

Original16.0
Target13.3
Herbie14.3
\[\begin{array}{l} \mathbf{if}\;t \lt -1.3659085366310088 \cdot 10^{-271}:\\ \;\;\;\;1 \cdot \left(\left(x + \frac{y}{t} \cdot z\right) \cdot \frac{1}{\left(a + 1\right) + \frac{y}{t} \cdot b}\right)\\ \mathbf{elif}\;t \lt 3.0369671037372459 \cdot 10^{-130}:\\ \;\;\;\;\frac{z}{b}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(\left(x + \frac{y}{t} \cdot z\right) \cdot \frac{1}{\left(a + 1\right) + \frac{y}{t} \cdot b}\right)\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if b < -1.2271249360064273e+68

    1. Initial program 22.3

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\]
    2. Using strategy rm
    3. Applied div-inv22.3

      \[\leadsto \color{blue}{\left(x + \frac{y \cdot z}{t}\right) \cdot \frac{1}{\left(a + 1\right) + \frac{y \cdot b}{t}}}\]
    4. Simplified18.9

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

    if -1.2271249360064273e+68 < b < -8.629618781889861e-237

    1. Initial program 12.6

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\]
    2. Using strategy rm
    3. Applied clear-num12.6

      \[\leadsto \frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \color{blue}{\frac{1}{\frac{t}{y \cdot b}}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity12.6

      \[\leadsto \frac{x + \frac{y \cdot z}{\color{blue}{1 \cdot t}}}{\left(a + 1\right) + \frac{1}{\frac{t}{y \cdot b}}}\]
    6. Applied times-frac13.1

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

      \[\leadsto \frac{x + \color{blue}{y} \cdot \frac{z}{t}}{\left(a + 1\right) + \frac{1}{\frac{t}{y \cdot b}}}\]

    if -8.629618781889861e-237 < b

    1. Initial program 15.3

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\]
    2. Using strategy rm
    3. Applied div-inv15.4

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.2271249360064273 \cdot 10^{68}:\\ \;\;\;\;\left(x + \frac{y \cdot z}{t}\right) \cdot \frac{1}{\mathsf{fma}\left(\frac{y}{t}, b, a + 1\right)}\\ \mathbf{elif}\;b \le -8.62961878188986081 \cdot 10^{-237}:\\ \;\;\;\;\frac{x + y \cdot \frac{z}{t}}{\left(a + 1\right) + \frac{1}{\frac{t}{y \cdot b}}}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, a + 1\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2020062 +o rules:numerics
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Tridiagonal:solveCyclicTriDiagonal from diagrams-solve-0.1, B"
  :precision binary64

  :herbie-target
  (if (< t -1.3659085366310088e-271) (* 1 (* (+ x (* (/ y t) z)) (/ 1 (+ (+ a 1) (* (/ y t) b))))) (if (< t 3.036967103737246e-130) (/ z b) (* 1 (* (+ x (* (/ y t) z)) (/ 1 (+ (+ a 1) (* (/ y t) b)))))))

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