Average Error: 16.4 → 13.3
Time: 7.4s
Precision: binary64
\[\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\]
\[\begin{array}{l} \mathbf{if}\;t \leq -4.843246152437076 \cdot 10^{-92}:\\ \;\;\;\;\left(x + y \cdot \frac{z}{t}\right) \cdot \frac{1}{a + \left(1 + y \cdot \frac{b}{t}\right)}\\ \mathbf{elif}\;t \leq 1.6463407347992611 \cdot 10^{-24}:\\ \;\;\;\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \sqrt{\frac{1}{t}} \cdot \left(y \cdot \left(z \cdot \sqrt{\frac{1}{t}}\right)\right)}{a + \left(1 + y \cdot \frac{b}{t}\right)}\\ \end{array}\]
\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}
\begin{array}{l}
\mathbf{if}\;t \leq -4.843246152437076 \cdot 10^{-92}:\\
\;\;\;\;\left(x + y \cdot \frac{z}{t}\right) \cdot \frac{1}{a + \left(1 + y \cdot \frac{b}{t}\right)}\\

\mathbf{elif}\;t \leq 1.6463407347992611 \cdot 10^{-24}:\\
\;\;\;\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + \sqrt{\frac{1}{t}} \cdot \left(y \cdot \left(z \cdot \sqrt{\frac{1}{t}}\right)\right)}{a + \left(1 + y \cdot \frac{b}{t}\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
 (if (<= t -4.843246152437076e-92)
   (* (+ x (* y (/ z t))) (/ 1.0 (+ a (+ 1.0 (* y (/ b t))))))
   (if (<= t 1.6463407347992611e-24)
     (/ (+ x (/ (* y z) t)) (+ (+ a 1.0) (/ (* y b) t)))
     (/
      (+ x (* (sqrt (/ 1.0 t)) (* y (* z (sqrt (/ 1.0 t))))))
      (+ a (+ 1.0 (* y (/ b t))))))))
double code(double x, double y, double z, double t, double a, double b) {
	return (((double) (x + (((double) (y * z)) / t))) / ((double) (((double) (a + 1.0)) + (((double) (y * b)) / t))));
}
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((t <= -4.843246152437076e-92)) {
		tmp = ((double) (((double) (x + ((double) (y * (z / t))))) * (1.0 / ((double) (a + ((double) (1.0 + ((double) (y * (b / t))))))))));
	} else {
		double tmp_1;
		if ((t <= 1.6463407347992611e-24)) {
			tmp_1 = (((double) (x + (((double) (y * z)) / t))) / ((double) (((double) (a + 1.0)) + (((double) (y * b)) / t))));
		} else {
			tmp_1 = (((double) (x + ((double) (((double) sqrt((1.0 / t))) * ((double) (y * ((double) (z * ((double) sqrt((1.0 / t))))))))))) / ((double) (a + ((double) (1.0 + ((double) (y * (b / t))))))));
		}
		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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original16.4
Target13.1
Herbie13.3
\[\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 t < -4.84324615243707631e-92

    1. Initial program Error: 11.5 bits

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

      \[\leadsto \color{blue}{\frac{x + y \cdot \frac{z}{t}}{a + \left(1 + y \cdot \frac{b}{t}\right)}}\]
    3. Using strategy rm
    4. Applied div-invError: 6.8 bits

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

    if -4.84324615243707631e-92 < t < 1.6463407347992611e-24

    1. Initial program Error: 24.1 bits

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

    if 1.6463407347992611e-24 < t

    1. Initial program Error: 11.4 bits

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

      \[\leadsto \color{blue}{\frac{x + y \cdot \frac{z}{t}}{a + \left(1 + y \cdot \frac{b}{t}\right)}}\]
    3. Using strategy rm
    4. Applied div-invError: 4.4 bits

      \[\leadsto \frac{x + y \cdot \color{blue}{\left(z \cdot \frac{1}{t}\right)}}{a + \left(1 + y \cdot \frac{b}{t}\right)}\]
    5. Applied associate-*r*Error: 8.2 bits

      \[\leadsto \frac{x + \color{blue}{\left(y \cdot z\right) \cdot \frac{1}{t}}}{a + \left(1 + y \cdot \frac{b}{t}\right)}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrtError: 8.2 bits

      \[\leadsto \frac{x + \left(y \cdot z\right) \cdot \color{blue}{\left(\sqrt{\frac{1}{t}} \cdot \sqrt{\frac{1}{t}}\right)}}{a + \left(1 + y \cdot \frac{b}{t}\right)}\]
    8. Applied associate-*r*Error: 8.2 bits

      \[\leadsto \frac{x + \color{blue}{\left(\left(y \cdot z\right) \cdot \sqrt{\frac{1}{t}}\right) \cdot \sqrt{\frac{1}{t}}}}{a + \left(1 + y \cdot \frac{b}{t}\right)}\]
    9. SimplifiedError: 5.5 bits

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -4.843246152437076 \cdot 10^{-92}:\\ \;\;\;\;\left(x + y \cdot \frac{z}{t}\right) \cdot \frac{1}{a + \left(1 + y \cdot \frac{b}{t}\right)}\\ \mathbf{elif}\;t \leq 1.6463407347992611 \cdot 10^{-24}:\\ \;\;\;\;\frac{x + \frac{y \cdot z}{t}}{\left(a + 1\right) + \frac{y \cdot b}{t}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \sqrt{\frac{1}{t}} \cdot \left(y \cdot \left(z \cdot \sqrt{\frac{1}{t}}\right)\right)}{a + \left(1 + y \cdot \frac{b}{t}\right)}\\ \end{array}\]

Reproduce

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