Average Error: 16.1 → 15.8
Time: 17.4s
Precision: 64
\[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\]
\[\begin{array}{l} \mathbf{if}\;a \le -9.594945174605233839511108938984402192689 \cdot 10^{-214}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{z}{t}, y, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, 1 + a\right)}\\ \mathbf{elif}\;a \le 1.038908810690689509361798165001599720794 \cdot 10^{-247}:\\ \;\;\;\;\frac{\left(y \cdot z\right) \cdot \frac{1}{t} + x}{\left(1 + a\right) + \frac{b \cdot y}{t}}\\ \mathbf{elif}\;a \le 2.361095285802122901314553004742323363037 \cdot 10^{-84}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{z}{t}, y, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, 1 + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(y \cdot z\right) \cdot \frac{1}{t} + x}{\left(1 + a\right) + \frac{b \cdot y}{t}}\\ \end{array}\]
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\begin{array}{l}
\mathbf{if}\;a \le -9.594945174605233839511108938984402192689 \cdot 10^{-214}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{z}{t}, y, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, 1 + a\right)}\\

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

\mathbf{elif}\;a \le 2.361095285802122901314553004742323363037 \cdot 10^{-84}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{z}{t}, y, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, 1 + a\right)}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r19939768 = x;
        double r19939769 = y;
        double r19939770 = z;
        double r19939771 = r19939769 * r19939770;
        double r19939772 = t;
        double r19939773 = r19939771 / r19939772;
        double r19939774 = r19939768 + r19939773;
        double r19939775 = a;
        double r19939776 = 1.0;
        double r19939777 = r19939775 + r19939776;
        double r19939778 = b;
        double r19939779 = r19939769 * r19939778;
        double r19939780 = r19939779 / r19939772;
        double r19939781 = r19939777 + r19939780;
        double r19939782 = r19939774 / r19939781;
        return r19939782;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r19939783 = a;
        double r19939784 = -9.594945174605234e-214;
        bool r19939785 = r19939783 <= r19939784;
        double r19939786 = z;
        double r19939787 = t;
        double r19939788 = r19939786 / r19939787;
        double r19939789 = y;
        double r19939790 = x;
        double r19939791 = fma(r19939788, r19939789, r19939790);
        double r19939792 = r19939789 / r19939787;
        double r19939793 = b;
        double r19939794 = 1.0;
        double r19939795 = r19939794 + r19939783;
        double r19939796 = fma(r19939792, r19939793, r19939795);
        double r19939797 = r19939791 / r19939796;
        double r19939798 = 1.0389088106906895e-247;
        bool r19939799 = r19939783 <= r19939798;
        double r19939800 = r19939789 * r19939786;
        double r19939801 = 1.0;
        double r19939802 = r19939801 / r19939787;
        double r19939803 = r19939800 * r19939802;
        double r19939804 = r19939803 + r19939790;
        double r19939805 = r19939793 * r19939789;
        double r19939806 = r19939805 / r19939787;
        double r19939807 = r19939795 + r19939806;
        double r19939808 = r19939804 / r19939807;
        double r19939809 = 2.361095285802123e-84;
        bool r19939810 = r19939783 <= r19939809;
        double r19939811 = r19939810 ? r19939797 : r19939808;
        double r19939812 = r19939799 ? r19939808 : r19939811;
        double r19939813 = r19939785 ? r19939797 : r19939812;
        return r19939813;
}

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.1
Target12.9
Herbie15.8
\[\begin{array}{l} \mathbf{if}\;t \lt -1.365908536631008841640163147697088508132 \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.036967103737245906066829435890093573122 \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 2 regimes
  2. if a < -9.594945174605234e-214 or 1.0389088106906895e-247 < a < 2.361095285802123e-84

    1. Initial program 15.9

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

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

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

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

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

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

    if -9.594945174605234e-214 < a < 1.0389088106906895e-247 or 2.361095285802123e-84 < a

    1. Initial program 16.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -9.594945174605233839511108938984402192689 \cdot 10^{-214}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{z}{t}, y, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, 1 + a\right)}\\ \mathbf{elif}\;a \le 1.038908810690689509361798165001599720794 \cdot 10^{-247}:\\ \;\;\;\;\frac{\left(y \cdot z\right) \cdot \frac{1}{t} + x}{\left(1 + a\right) + \frac{b \cdot y}{t}}\\ \mathbf{elif}\;a \le 2.361095285802122901314553004742323363037 \cdot 10^{-84}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{z}{t}, y, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, 1 + a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(y \cdot z\right) \cdot \frac{1}{t} + x}{\left(1 + a\right) + \frac{b \cdot y}{t}}\\ \end{array}\]

Reproduce

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

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

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