Average Error: 17.2 → 14.6
Time: 19.3s
Precision: 64
\[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{z \cdot y}{t} + x}{\left(a + 1\right) + \frac{b \cdot y}{t}} \le -2.920289298659490288425480516012074489493 \cdot 10^{-301} \lor \neg \left(\frac{\frac{z \cdot y}{t} + x}{\left(a + 1\right) + \frac{b \cdot y}{t}} \le 2.89887959532284282253392838367813293968 \cdot 10^{-157}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(b, \frac{y}{t}, a + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(a + 1\right) + \frac{y}{\frac{t}{b}}} \cdot \mathsf{fma}\left(\frac{z}{t}, y, x\right)\\ \end{array}\]
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\begin{array}{l}
\mathbf{if}\;\frac{\frac{z \cdot y}{t} + x}{\left(a + 1\right) + \frac{b \cdot y}{t}} \le -2.920289298659490288425480516012074489493 \cdot 10^{-301} \lor \neg \left(\frac{\frac{z \cdot y}{t} + x}{\left(a + 1\right) + \frac{b \cdot y}{t}} \le 2.89887959532284282253392838367813293968 \cdot 10^{-157}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(b, \frac{y}{t}, a + 1\right)}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r471422 = x;
        double r471423 = y;
        double r471424 = z;
        double r471425 = r471423 * r471424;
        double r471426 = t;
        double r471427 = r471425 / r471426;
        double r471428 = r471422 + r471427;
        double r471429 = a;
        double r471430 = 1.0;
        double r471431 = r471429 + r471430;
        double r471432 = b;
        double r471433 = r471423 * r471432;
        double r471434 = r471433 / r471426;
        double r471435 = r471431 + r471434;
        double r471436 = r471428 / r471435;
        return r471436;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r471437 = z;
        double r471438 = y;
        double r471439 = r471437 * r471438;
        double r471440 = t;
        double r471441 = r471439 / r471440;
        double r471442 = x;
        double r471443 = r471441 + r471442;
        double r471444 = a;
        double r471445 = 1.0;
        double r471446 = r471444 + r471445;
        double r471447 = b;
        double r471448 = r471447 * r471438;
        double r471449 = r471448 / r471440;
        double r471450 = r471446 + r471449;
        double r471451 = r471443 / r471450;
        double r471452 = -2.9202892986594903e-301;
        bool r471453 = r471451 <= r471452;
        double r471454 = 2.8988795953228428e-157;
        bool r471455 = r471451 <= r471454;
        double r471456 = !r471455;
        bool r471457 = r471453 || r471456;
        double r471458 = r471438 / r471440;
        double r471459 = fma(r471458, r471437, r471442);
        double r471460 = fma(r471447, r471458, r471446);
        double r471461 = r471459 / r471460;
        double r471462 = 1.0;
        double r471463 = r471440 / r471447;
        double r471464 = r471438 / r471463;
        double r471465 = r471446 + r471464;
        double r471466 = r471462 / r471465;
        double r471467 = r471437 / r471440;
        double r471468 = fma(r471467, r471438, r471442);
        double r471469 = r471466 * r471468;
        double r471470 = r471457 ? r471461 : r471469;
        return r471470;
}

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

Original17.2
Target13.7
Herbie14.6
\[\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 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))) < -2.9202892986594903e-301 or 2.8988795953228428e-157 < (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t)))

    1. Initial program 16.0

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

      \[\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 fma-udef17.2

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

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

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

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

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

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

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

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

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

    if -2.9202892986594903e-301 < (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))) < 2.8988795953228428e-157

    1. Initial program 20.9

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

      \[\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 fma-udef16.1

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

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019179 +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))))