Average Error: 16.4 → 5.4
Time: 7.8s
Precision: binary64
\[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
\[\begin{array}{l} t_1 := \mathsf{fma}\left(y, b, \mathsf{fma}\left(a, t, t\right)\right)\\ t_2 := x + \frac{y \cdot z}{t}\\ t_3 := \frac{y \cdot b}{t}\\ t_4 := \frac{t_2}{\left(a + 1\right) + t_3}\\ \mathbf{if}\;t_4 \leq -\infty:\\ \;\;\;\;\frac{y}{\frac{t_1}{z}} + \frac{x}{1 + \left(a + t_3\right)}\\ \mathbf{elif}\;t_4 \leq -1.4113307000283498 \cdot 10^{-272}:\\ \;\;\;\;\frac{t_2}{\left(a + 1\right) + \frac{1}{\frac{t}{y \cdot b}}}\\ \mathbf{elif}\;t_4 \leq \infty:\\ \;\;\;\;\frac{y \cdot z}{t_1} + \frac{x}{1 + \mathsf{fma}\left(b, \frac{y}{t}, a\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{b}\\ \end{array} \]
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, b, \mathsf{fma}\left(a, t, t\right)\right)\\
t_2 := x + \frac{y \cdot z}{t}\\
t_3 := \frac{y \cdot b}{t}\\
t_4 := \frac{t_2}{\left(a + 1\right) + t_3}\\
\mathbf{if}\;t_4 \leq -\infty:\\
\;\;\;\;\frac{y}{\frac{t_1}{z}} + \frac{x}{1 + \left(a + t_3\right)}\\

\mathbf{elif}\;t_4 \leq -1.4113307000283498 \cdot 10^{-272}:\\
\;\;\;\;\frac{t_2}{\left(a + 1\right) + \frac{1}{\frac{t}{y \cdot b}}}\\

\mathbf{elif}\;t_4 \leq \infty:\\
\;\;\;\;\frac{y \cdot z}{t_1} + \frac{x}{1 + \mathsf{fma}\left(b, \frac{y}{t}, a\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{z}{b}\\


\end{array}
(FPCore (x y z t a b)
 :precision binary64
 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t))))
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (fma y b (fma a t t)))
        (t_2 (+ x (/ (* y z) t)))
        (t_3 (/ (* y b) t))
        (t_4 (/ t_2 (+ (+ a 1.0) t_3))))
   (if (<= t_4 (- INFINITY))
     (+ (/ y (/ t_1 z)) (/ x (+ 1.0 (+ a t_3))))
     (if (<= t_4 -1.4113307000283498e-272)
       (/ t_2 (+ (+ a 1.0) (/ 1.0 (/ t (* y b)))))
       (if (<= t_4 INFINITY)
         (+ (/ (* y z) t_1) (/ x (+ 1.0 (fma b (/ y t) a))))
         (/ z b))))))
double code(double x, double y, double z, double t, double a, double b) {
	return (x + ((y * z) / t)) / ((a + 1.0) + ((y * b) / t));
}
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fma(y, b, fma(a, t, t));
	double t_2 = x + ((y * z) / t);
	double t_3 = (y * b) / t;
	double t_4 = t_2 / ((a + 1.0) + t_3);
	double tmp;
	if (t_4 <= -((double) INFINITY)) {
		tmp = (y / (t_1 / z)) + (x / (1.0 + (a + t_3)));
	} else if (t_4 <= -1.4113307000283498e-272) {
		tmp = t_2 / ((a + 1.0) + (1.0 / (t / (y * b))));
	} else if (t_4 <= ((double) INFINITY)) {
		tmp = ((y * z) / t_1) + (x / (1.0 + fma(b, (y / t), a)));
	} else {
		tmp = z / b;
	}
	return tmp;
}

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.4
Target13.4
Herbie5.4
\[\begin{array}{l} \mathbf{if}\;t < -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 < 3.036967103737246 \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 4 regimes
  2. if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < -inf.0

    1. Initial program 64.0

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in x around 0 40.1

      \[\leadsto \color{blue}{\frac{y \cdot z}{\left(1 + \left(a + \frac{y \cdot b}{t}\right)\right) \cdot t} + \frac{x}{1 + \left(a + \frac{y \cdot b}{t}\right)}} \]
    3. Taylor expanded in z around inf 40.0

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

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

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

    if -inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < -1.4113307000283498e-272

    1. Initial program 0.4

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Applied clear-num_binary640.4

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

    if -1.4113307000283498e-272 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < +inf.0

    1. Initial program 13.5

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in x around 0 12.4

      \[\leadsto \color{blue}{\frac{y \cdot z}{\left(1 + \left(a + \frac{y \cdot b}{t}\right)\right) \cdot t} + \frac{x}{1 + \left(a + \frac{y \cdot b}{t}\right)}} \]
    3. Taylor expanded in z around inf 10.4

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

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

      \[\leadsto \frac{y \cdot z}{\mathsf{fma}\left(y, b, \mathsf{fma}\left(a, t, t\right)\right)} + \frac{x}{1 + \left(a + \color{blue}{\frac{y}{\frac{t}{b}}}\right)} \]
    6. Taylor expanded in x around 0 10.1

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

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

    if +inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t)))

    1. Initial program 64.0

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Taylor expanded in y around inf 2.6

      \[\leadsto \color{blue}{\frac{z}{b}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification5.4

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

Reproduce

herbie shell --seed 2021275 
(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.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))))