Average Error: 17.1 → 7.2
Time: 7.6s
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(\frac{y}{t}, b, a\right)\\ t_2 := \frac{y \cdot b}{t}\\ t_3 := \frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + t_2}\\ \mathbf{if}\;t_3 \leq 1.1445973513115435 \cdot 10^{+21}:\\ \;\;\;\;\frac{y \cdot z}{\mathsf{fma}\left(y, b, \mathsf{fma}\left(a, t, t\right)\right)} - \frac{x}{-1 - t_1}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_4 := \frac{x}{1 + \left(a + t_2\right)}\\ \mathbf{if}\;t_3 \leq \infty:\\ \;\;\;\;\frac{z \cdot \frac{y}{1 + t_1}}{t} + t_4\\ \mathbf{else}:\\ \;\;\;\;t_4 + \frac{z}{b}\\ \end{array}\\ \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(\frac{y}{t}, b, a\right)\\
t_2 := \frac{y \cdot b}{t}\\
t_3 := \frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + t_2}\\
\mathbf{if}\;t_3 \leq 1.1445973513115435 \cdot 10^{+21}:\\
\;\;\;\;\frac{y \cdot z}{\mathsf{fma}\left(y, b, \mathsf{fma}\left(a, t, t\right)\right)} - \frac{x}{-1 - t_1}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_4 := \frac{x}{1 + \left(a + t_2\right)}\\
\mathbf{if}\;t_3 \leq \infty:\\
\;\;\;\;\frac{z \cdot \frac{y}{1 + t_1}}{t} + t_4\\

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


\end{array}\\


\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 t) b a))
        (t_2 (/ (* y b) t))
        (t_3 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) t_2))))
   (if (<= t_3 1.1445973513115435e+21)
     (- (/ (* y z) (fma y b (fma a t t))) (/ x (- -1.0 t_1)))
     (let* ((t_4 (/ x (+ 1.0 (+ a t_2)))))
       (if (<= t_3 INFINITY)
         (+ (/ (* z (/ y (+ 1.0 t_1))) t) t_4)
         (+ t_4 (/ 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 / t), b, a);
	double t_2 = (y * b) / t;
	double t_3 = (x + ((y * z) / t)) / ((a + 1.0) + t_2);
	double tmp;
	if (t_3 <= 1.1445973513115435e+21) {
		tmp = ((y * z) / fma(y, b, fma(a, t, t))) - (x / (-1.0 - t_1));
	} else {
		double t_4 = x / (1.0 + (a + t_2));
		double tmp_1;
		if (t_3 <= ((double) INFINITY)) {
			tmp_1 = ((z * (y / (1.0 + t_1))) / t) + t_4;
		} else {
			tmp_1 = t_4 + (z / b);
		}
		tmp = tmp_1;
	}
	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

Original17.1
Target13.9
Herbie7.2
\[\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 3 regimes
  2. if (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < 1.1445973513115435e21

    1. Initial program 10.8

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

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

      \[\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)}} \]
    4. Taylor expanded in z around inf 8.9

      \[\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)} \]
    5. Simplified8.7

      \[\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)} \]
    6. Applied frac-2neg_binary648.7

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

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

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

    1. Initial program 14.7

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

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

      \[\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)}} \]
    4. Applied associate-/r*_binary649.7

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

      \[\leadsto \frac{\color{blue}{\frac{y}{1 + \mathsf{fma}\left(\frac{y}{t}, b, a\right)} \cdot z}}{t} + \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. Initial program 64.0

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

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

      \[\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)}} \]
    4. Taylor expanded in y around inf 2.8

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

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

Reproduce

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