Average Error: 10.2 → 2.2
Time: 4.1s
Precision: binary64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -2.550938907169579 \cdot 10^{-119} \lor \neg \left(z \leq 2.4670334241868483 \cdot 10^{-128}\right):\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}\\ \mathbf{else}:\\ \;\;\;\;\left(x - z \cdot y\right) \cdot \frac{1}{t - z \cdot a}\\ \end{array}\]
\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
\mathbf{if}\;z \leq -2.550938907169579 \cdot 10^{-119} \lor \neg \left(z \leq 2.4670334241868483 \cdot 10^{-128}\right):\\
\;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}\\

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

\end{array}
(FPCore (x y z t a) :precision binary64 (/ (- x (* y z)) (- t (* a z))))
(FPCore (x y z t a)
 :precision binary64
 (if (or (<= z -2.550938907169579e-119) (not (<= z 2.4670334241868483e-128)))
   (- (/ x (- t (* z a))) (/ y (- (/ t z) a)))
   (* (- x (* z y)) (/ 1.0 (- t (* z a))))))
double code(double x, double y, double z, double t, double a) {
	return (x - (y * z)) / (t - (a * z));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((z <= -2.550938907169579e-119) || !(z <= 2.4670334241868483e-128)) {
		tmp = (x / (t - (z * a))) - (y / ((t / z) - a));
	} else {
		tmp = (x - (z * y)) * (1.0 / (t - (z * a)));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.2
Target1.8
Herbie2.2
\[\begin{array}{l} \mathbf{if}\;z < -32113435955957344:\\ \;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\frac{t}{z} - a}\\ \mathbf{elif}\;z < 3.5139522372978296 \cdot 10^{-86}:\\ \;\;\;\;\left(x - y \cdot z\right) \cdot \frac{1}{t - a \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\frac{t}{z} - a}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -2.550938907169579e-119 or 2.4670334241868483e-128 < z

    1. Initial program 14.4

      \[\frac{x - y \cdot z}{t - a \cdot z}\]
    2. Using strategy rm
    3. Applied div-sub_binary6414.4

      \[\leadsto \color{blue}{\frac{x}{t - a \cdot z} - \frac{y \cdot z}{t - a \cdot z}}\]
    4. Simplified14.4

      \[\leadsto \color{blue}{\frac{x}{t - z \cdot a}} - \frac{y \cdot z}{t - a \cdot z}\]
    5. Simplified14.4

      \[\leadsto \frac{x}{t - z \cdot a} - \color{blue}{\frac{y \cdot z}{t - z \cdot a}}\]
    6. Using strategy rm
    7. Applied associate-/l*_binary649.7

      \[\leadsto \frac{x}{t - z \cdot a} - \color{blue}{\frac{y}{\frac{t - z \cdot a}{z}}}\]
    8. Using strategy rm
    9. Applied div-sub_binary649.7

      \[\leadsto \frac{x}{t - z \cdot a} - \frac{y}{\color{blue}{\frac{t}{z} - \frac{z \cdot a}{z}}}\]
    10. Simplified3.0

      \[\leadsto \frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - \color{blue}{a}}\]

    if -2.550938907169579e-119 < z < 2.4670334241868483e-128

    1. Initial program 0.1

      \[\frac{x - y \cdot z}{t - a \cdot z}\]
    2. Using strategy rm
    3. Applied div-inv_binary640.3

      \[\leadsto \color{blue}{\left(x - y \cdot z\right) \cdot \frac{1}{t - a \cdot z}}\]
    4. Simplified0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.550938907169579 \cdot 10^{-119} \lor \neg \left(z \leq 2.4670334241868483 \cdot 10^{-128}\right):\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}\\ \mathbf{else}:\\ \;\;\;\;\left(x - z \cdot y\right) \cdot \frac{1}{t - z \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020224 
(FPCore (x y z t a)
  :name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, A"
  :precision binary64

  :herbie-target
  (if (< z -32113435955957344.0) (- (/ x (- t (* a z))) (/ y (- (/ t z) a))) (if (< z 3.5139522372978296e-86) (* (- x (* y z)) (/ 1.0 (- t (* a z)))) (- (/ x (- t (* a z))) (/ y (- (/ t z) a)))))

  (/ (- x (* y z)) (- t (* a z))))