Average Error: 16.7 → 6.6
Time: 9.2s
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 + \frac{y \cdot z}{t}}{\left(a + 1\right) + t_1}\\ t_3 := 1 + \left(a + t_1\right)\\ t_4 := \frac{x}{t_3}\\ \mathbf{if}\;t_2 \leq -2.71191800524137 \cdot 10^{-310}:\\ \;\;\;\;z \cdot \frac{y}{t \cdot t_3} + t_4\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;\frac{z + \frac{x \cdot t}{y}}{b}\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;t_4 + \frac{y}{t} \cdot \frac{z}{t_3}\\ \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 := \frac{y \cdot b}{t}\\
t_2 := \frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + t_1}\\
t_3 := 1 + \left(a + t_1\right)\\
t_4 := \frac{x}{t_3}\\
\mathbf{if}\;t_2 \leq -2.71191800524137 \cdot 10^{-310}:\\
\;\;\;\;z \cdot \frac{y}{t \cdot t_3} + t_4\\

\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\frac{z + \frac{x \cdot t}{y}}{b}\\

\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;t_4 + \frac{y}{t} \cdot \frac{z}{t_3}\\

\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 (/ (* y b) t))
        (t_2 (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) t_1)))
        (t_3 (+ 1.0 (+ a t_1)))
        (t_4 (/ x t_3)))
   (if (<= t_2 -2.71191800524137e-310)
     (+ (* z (/ y (* t t_3))) t_4)
     (if (<= t_2 0.0)
       (/ (+ z (/ (* x t) y)) b)
       (if (<= t_2 INFINITY) (+ t_4 (* (/ y t) (/ z t_3))) (/ 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 = (y * b) / t;
	double t_2 = (x + ((y * z) / t)) / ((a + 1.0) + t_1);
	double t_3 = 1.0 + (a + t_1);
	double t_4 = x / t_3;
	double tmp;
	if (t_2 <= -2.71191800524137e-310) {
		tmp = (z * (y / (t * t_3))) + t_4;
	} else if (t_2 <= 0.0) {
		tmp = (z + ((x * t) / y)) / b;
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = t_4 + ((y / t) * (z / t_3));
	} 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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original16.7
Target13.5
Herbie6.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 (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < -2.71191800524137e-310

    1. Initial program 7.6

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

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

      \[\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 egg-rr2.9

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

    if -2.71191800524137e-310 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < -0.0

    1. Initial program 27.7

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

      \[\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 27.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. Simplified27.7

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

      \[\leadsto \color{blue}{\frac{\frac{t \cdot x}{y} + z}{b}} \]

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

    1. Initial program 7.1

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

      \[\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 5.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)}} \]
    4. Applied egg-rr4.5

      \[\leadsto \color{blue}{\frac{y}{t} \cdot \frac{z}{1 + \left(a + \frac{y \cdot b}{t}\right)}} + \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. Simplified56.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \leq -2.71191800524137 \cdot 10^{-310}:\\ \;\;\;\;z \cdot \frac{y}{t \cdot \left(1 + \left(a + \frac{y \cdot b}{t}\right)\right)} + \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 0:\\ \;\;\;\;\frac{z + \frac{x \cdot t}{y}}{b}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \leq \infty:\\ \;\;\;\;\frac{x}{1 + \left(a + \frac{y \cdot b}{t}\right)} + \frac{y}{t} \cdot \frac{z}{1 + \left(a + \frac{y \cdot b}{t}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{b}\\ \end{array} \]

Reproduce

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