Average Error: 16.1 → 13.4
Time: 5.1s
Precision: 64
\[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.926561828986015 \cdot 10^{-140} \lor \neg \left(z \le 2.9030980178479713 \cdot 10^{-20}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, a + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y \cdot \frac{z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\ \end{array}\]
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\begin{array}{l}
\mathbf{if}\;z \le -1.926561828986015 \cdot 10^{-140} \lor \neg \left(z \le 2.9030980178479713 \cdot 10^{-20}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, a + 1\right)}\\

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

\end{array}
double code(double x, double y, double z, double t, double a, double b) {
	return ((double) (((double) (x + ((double) (((double) (y * z)) / t)))) / ((double) (((double) (a + 1.0)) + ((double) (((double) (y * b)) / t))))));
}
double code(double x, double y, double z, double t, double a, double b) {
	double VAR;
	if (((z <= -1.9265618289860146e-140) || !(z <= 2.903098017847971e-20))) {
		VAR = ((double) (((double) fma(((double) (y / t)), z, x)) / ((double) fma(((double) (y / t)), b, ((double) (a + 1.0))))));
	} else {
		VAR = ((double) (((double) (x + ((double) (y * ((double) (z / t)))))) / ((double) (((double) (a + 1.0)) + ((double) (((double) (y * b)) / t))))));
	}
	return VAR;
}

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.1
Target13.0
Herbie13.4
\[\begin{array}{l} \mathbf{if}\;t \lt -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 \lt 3.0369671037372459 \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 2 regimes
  2. if z < -1.9265618289860146e-140 or 2.903098017847971e-20 < z

    1. Initial program 20.6

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\]
    2. Using strategy rm
    3. Applied div-inv20.7

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

      \[\leadsto \left(x + \frac{y \cdot z}{t}\right) \cdot \color{blue}{\frac{1}{\mathsf{fma}\left(\frac{y}{t}, b, a + 1\right)}}\]
    5. Using strategy rm
    6. Applied associate-*r/19.6

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

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

    if -1.9265618289860146e-140 < z < 2.903098017847971e-20

    1. Initial program 8.8

      \[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity8.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.926561828986015 \cdot 10^{-140} \lor \neg \left(z \le 2.9030980178479713 \cdot 10^{-20}\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t}, z, x\right)}{\mathsf{fma}\left(\frac{y}{t}, b, a + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y \cdot \frac{z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020120 +o rules:numerics
(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 (* (+ x (* (/ y t) z)) (/ 1 (+ (+ a 1) (* (/ y t) b))))) (if (< t 3.036967103737246e-130) (/ z b) (* 1 (* (+ x (* (/ y t) z)) (/ 1 (+ (+ a 1) (* (/ y t) b)))))))

  (/ (+ x (/ (* y z) t)) (+ (+ a 1) (/ (* y b) t))))