Average Error: 16.2 → 9.6
Time: 13.8s
Precision: binary64
\[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
\[\begin{array}{l} t_1 := \frac{y \cdot b}{t}\\ t_2 := \frac{x}{1 + \left(a + t_1\right)}\\ t_3 := \frac{z}{b} + t_2\\ \mathbf{if}\;y \leq -6.04812534866938 \cdot 10^{+167}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 3.67379042608604 \cdot 10^{+52}:\\ \;\;\;\;t_2 + \frac{y \cdot z}{\mathsf{fma}\left(y, b, \mathsf{fma}\left(a, t, t\right)\right)}\\ \mathbf{elif}\;y \leq 1.244253742756409 \cdot 10^{+146}:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t}{z}}}{t_1 + \left(1 + a\right)}\\ \mathbf{elif}\;y \leq 5.1233805809014946 \cdot 10^{+247}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{z}{\mathsf{fma}\left(y, b, \mathsf{fma}\left(t, a, t\right)\right)} + \frac{x}{1 + \left(a + \frac{y}{\frac{t}{b}}\right)}\\ \end{array} \]
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\begin{array}{l}
t_1 := \frac{y \cdot b}{t}\\
t_2 := \frac{x}{1 + \left(a + t_1\right)}\\
t_3 := \frac{z}{b} + t_2\\
\mathbf{if}\;y \leq -6.04812534866938 \cdot 10^{+167}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;y \leq 3.67379042608604 \cdot 10^{+52}:\\
\;\;\;\;t_2 + \frac{y \cdot z}{\mathsf{fma}\left(y, b, \mathsf{fma}\left(a, t, t\right)\right)}\\

\mathbf{elif}\;y \leq 1.244253742756409 \cdot 10^{+146}:\\
\;\;\;\;\frac{x + \frac{y}{\frac{t}{z}}}{t_1 + \left(1 + a\right)}\\

\mathbf{elif}\;y \leq 5.1233805809014946 \cdot 10^{+247}:\\
\;\;\;\;t_3\\

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


\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 (/ (* y b) t))
        (t_2 (/ x (+ 1.0 (+ a t_1))))
        (t_3 (+ (/ z b) t_2)))
   (if (<= y -6.04812534866938e+167)
     t_3
     (if (<= y 3.67379042608604e+52)
       (+ t_2 (/ (* y z) (fma y b (fma a t t))))
       (if (<= y 1.244253742756409e+146)
         (/ (+ x (/ y (/ t z))) (+ t_1 (+ 1.0 a)))
         (if (<= y 5.1233805809014946e+247)
           t_3
           (+
            (* y (/ z (fma y b (fma t a t))))
            (/ x (+ 1.0 (+ a (/ y (/ t 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 = (y * b) / t;
	double t_2 = x / (1.0 + (a + t_1));
	double t_3 = (z / b) + t_2;
	double tmp;
	if (y <= -6.04812534866938e+167) {
		tmp = t_3;
	} else if (y <= 3.67379042608604e+52) {
		tmp = t_2 + ((y * z) / fma(y, b, fma(a, t, t)));
	} else if (y <= 1.244253742756409e+146) {
		tmp = (x + (y / (t / z))) / (t_1 + (1.0 + a));
	} else if (y <= 5.1233805809014946e+247) {
		tmp = t_3;
	} else {
		tmp = (y * (z / fma(y, b, fma(t, a, t)))) + (x / (1.0 + (a + (y / (t / 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.2
Target13.1
Herbie9.6
\[\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 y < -6.04812534866938001e167 or 1.24425374275640895e146 < y < 5.12338058090149459e247

    1. Initial program 37.9

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

      \[\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 y around inf 19.6

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

    if -6.04812534866938001e167 < y < 3.6737904260860398e52

    1. Initial program 7.6

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

      \[\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 4.5

      \[\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. Simplified4.5

      \[\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 *-un-lft-identity_binary644.5

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

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

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

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

    if 3.6737904260860398e52 < y < 1.24425374275640895e146

    1. Initial program 23.0

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
    2. Applied associate-/l*_binary6419.7

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

    if 5.12338058090149459e247 < y

    1. Initial program 44.8

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

      \[\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 39.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. Simplified38.9

      \[\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 *-un-lft-identity_binary6438.9

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

      \[\leadsto \color{blue}{\frac{y}{1} \cdot \frac{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)} \]
    7. Simplified32.2

      \[\leadsto \color{blue}{y} \cdot \frac{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)} \]
    8. Simplified32.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.04812534866938 \cdot 10^{+167}:\\ \;\;\;\;\frac{z}{b} + \frac{x}{1 + \left(a + \frac{y \cdot b}{t}\right)}\\ \mathbf{elif}\;y \leq 3.67379042608604 \cdot 10^{+52}:\\ \;\;\;\;\frac{x}{1 + \left(a + \frac{y \cdot b}{t}\right)} + \frac{y \cdot z}{\mathsf{fma}\left(y, b, \mathsf{fma}\left(a, t, t\right)\right)}\\ \mathbf{elif}\;y \leq 1.244253742756409 \cdot 10^{+146}:\\ \;\;\;\;\frac{x + \frac{y}{\frac{t}{z}}}{\frac{y \cdot b}{t} + \left(1 + a\right)}\\ \mathbf{elif}\;y \leq 5.1233805809014946 \cdot 10^{+247}:\\ \;\;\;\;\frac{z}{b} + \frac{x}{1 + \left(a + \frac{y \cdot b}{t}\right)}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{z}{\mathsf{fma}\left(y, b, \mathsf{fma}\left(t, a, t\right)\right)} + \frac{x}{1 + \left(a + \frac{y}{\frac{t}{b}}\right)}\\ \end{array} \]

Reproduce

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