Average Error: 16.4 → 5.9
Time: 9.6s
Precision: binary64
\[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \]
\[\begin{array}{l} t_1 := \left(a + 1\right) + \frac{y \cdot b}{t}\\ t_2 := \frac{x + \frac{y \cdot z}{t}}{t_1}\\ t_3 := \frac{y}{t_1}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;\frac{z}{t} \cdot t_3\\ \mathbf{elif}\;t_2 \leq -4.472539530856903 \cdot 10^{-289}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;\frac{z + \frac{x}{\frac{y}{t}}}{b}\\ \mathbf{elif}\;t_2 \leq 1.7642758988097463 \cdot 10^{+126}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_2 \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(t_3, \frac{z}{t}, \frac{x}{t_1}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z + x \cdot \frac{t}{y}}{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 (+ (+ a 1.0) (/ (* y b) t)))
        (t_2 (/ (+ x (/ (* y z) t)) t_1))
        (t_3 (/ y t_1)))
   (if (<= t_2 (- INFINITY))
     (* (/ z t) t_3)
     (if (<= t_2 -4.472539530856903e-289)
       t_2
       (if (<= t_2 0.0)
         (/ (+ z (/ x (/ y t))) b)
         (if (<= t_2 1.7642758988097463e+126)
           t_2
           (if (<= t_2 INFINITY)
             (fma t_3 (/ z t) (/ x t_1))
             (/ (+ z (* x (/ t y))) 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 = (a + 1.0) + ((y * b) / t);
	double t_2 = (x + ((y * z) / t)) / t_1;
	double t_3 = y / t_1;
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = (z / t) * t_3;
	} else if (t_2 <= -4.472539530856903e-289) {
		tmp = t_2;
	} else if (t_2 <= 0.0) {
		tmp = (z + (x / (y / t))) / b;
	} else if (t_2 <= 1.7642758988097463e+126) {
		tmp = t_2;
	} else if (t_2 <= ((double) INFINITY)) {
		tmp = fma(t_3, (z / t), (x / t_1));
	} else {
		tmp = (z + (x * (t / y))) / b;
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	return Float64(Float64(x + Float64(Float64(y * z) / t)) / Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t)))
end
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(a + 1.0) + Float64(Float64(y * b) / t))
	t_2 = Float64(Float64(x + Float64(Float64(y * z) / t)) / t_1)
	t_3 = Float64(y / t_1)
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = Float64(Float64(z / t) * t_3);
	elseif (t_2 <= -4.472539530856903e-289)
		tmp = t_2;
	elseif (t_2 <= 0.0)
		tmp = Float64(Float64(z + Float64(x / Float64(y / t))) / b);
	elseif (t_2 <= 1.7642758988097463e+126)
		tmp = t_2;
	elseif (t_2 <= Inf)
		tmp = fma(t_3, Float64(z / t), Float64(x / t_1));
	else
		tmp = Float64(Float64(z + Float64(x * Float64(t / y))) / b);
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a + 1.0), $MachinePrecision] + N[(N[(y * b), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(y / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(z / t), $MachinePrecision] * t$95$3), $MachinePrecision], If[LessEqual[t$95$2, -4.472539530856903e-289], t$95$2, If[LessEqual[t$95$2, 0.0], N[(N[(z + N[(x / N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision], If[LessEqual[t$95$2, 1.7642758988097463e+126], t$95$2, If[LessEqual[t$95$2, Infinity], N[(t$95$3 * N[(z / t), $MachinePrecision] + N[(x / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(z + N[(x * N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]]]]]]]]
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\begin{array}{l}
t_1 := \left(a + 1\right) + \frac{y \cdot b}{t}\\
t_2 := \frac{x + \frac{y \cdot z}{t}}{t_1}\\
t_3 := \frac{y}{t_1}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\frac{z}{t} \cdot t_3\\

\mathbf{elif}\;t_2 \leq -4.472539530856903 \cdot 10^{-289}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;t_2 \leq 1.7642758988097463 \cdot 10^{+126}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(t_3, \frac{z}{t}, \frac{x}{t_1}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{z + x \cdot \frac{t}{y}}{b}\\


\end{array}

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.2
Herbie5.9
\[\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 5 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. Simplified40.7

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

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

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

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

    if -inf.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < -4.4725395308569033e-289 or -0.0 < (/.f64 (+.f64 x (/.f64 (*.f64 y z) t)) (+.f64 (+.f64 a 1) (/.f64 (*.f64 y b) t))) < 1.7642758988097463e126

    1. Initial program 0.5

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

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

    1. Initial program 27.2

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, \frac{z}{t}, x\right)}{a + \mathsf{fma}\left(y, \frac{b}{t}, 1\right)}} \]
    3. Taylor expanded in z around 0 27.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)}} \]
    4. Simplified19.3

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

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

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

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

    1. Initial program 24.5

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

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

      \[\leadsto \frac{\mathsf{fma}\left(y, \frac{z}{t}, x\right)}{a + \color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(y, \frac{b}{t}, 1\right)}\right)}^{3}}} \]
    4. Taylor expanded in z around 0 14.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)}} \]
    5. Simplified10.5

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\sqrt[3]{y}\right)}^{2} \cdot \left(\sqrt[3]{y} \cdot \frac{1}{\mathsf{fma}\left(\frac{y}{t}, b, 1 + a\right)}\right)}, \frac{z}{t}, \frac{x}{\left(1 + a\right) + \frac{y}{t} \cdot b}\right) \]
    6. Taylor expanded in b around inf 4.6

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

      \[\leadsto \color{blue}{\frac{z + \frac{t}{y} \cdot x}{b}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification5.9

    \[\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{z}{t} \cdot \frac{y}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \leq -4.472539530856903 \cdot 10^{-289}:\\ \;\;\;\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \leq 0:\\ \;\;\;\;\frac{z + \frac{x}{\frac{y}{t}}}{b}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \leq 1.7642758988097463 \cdot 10^{+126}:\\ \;\;\;\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}} \leq \infty:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{\left(a + 1\right) + \frac{y \cdot b}{t}}, \frac{z}{t}, \frac{x}{\left(a + 1\right) + \frac{y \cdot b}{t}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{z + x \cdot \frac{t}{y}}{b}\\ \end{array} \]

Reproduce

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