Average Error: 10.5 → 2.2
Time: 10.8s
Precision: binary64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -9.6677807359980808 \cdot 10^{-32} \lor \neg \left(z \le 3.3322161377259759 \cdot 10^{-260}\right):\\ \;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\frac{t}{z} - a}\\ \mathbf{else}:\\ \;\;\;\;\left(x - y \cdot z\right) \cdot \frac{1}{t - a \cdot z}\\ \end{array}\]
\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -9.6677807359980808 \cdot 10^{-32} \lor \neg \left(z \le 3.3322161377259759 \cdot 10^{-260}\right):\\
\;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\frac{t}{z} - a}\\

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

\end{array}
double code(double x, double y, double z, double t, double a) {
	return ((double) (((double) (x - ((double) (y * z)))) / ((double) (t - ((double) (a * z))))));
}
double code(double x, double y, double z, double t, double a) {
	double VAR;
	if (((z <= -9.667780735998081e-32) || !(z <= 3.332216137725976e-260))) {
		VAR = ((double) (((double) (x / ((double) (t - ((double) (a * z)))))) - ((double) (y / ((double) (((double) (t / z)) - a))))));
	} else {
		VAR = ((double) (((double) (x - ((double) (y * z)))) * ((double) (1.0 / ((double) (t - ((double) (a * z))))))));
	}
	return VAR;
}

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.5
Target1.7
Herbie2.2
\[\begin{array}{l} \mathbf{if}\;z \lt -32113435955957344:\\ \;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\frac{t}{z} - a}\\ \mathbf{elif}\;z \lt 3.51395223729782958 \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 < -9.6677807359980808e-32 or 3.3322161377259759e-260 < z

    1. Initial program 14.2

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

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

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

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

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

    if -9.6677807359980808e-32 < z < 3.3322161377259759e-260

    1. Initial program 0.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -9.6677807359980808 \cdot 10^{-32} \lor \neg \left(z \le 3.3322161377259759 \cdot 10^{-260}\right):\\ \;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\frac{t}{z} - a}\\ \mathbf{else}:\\ \;\;\;\;\left(x - y \cdot z\right) \cdot \frac{1}{t - a \cdot z}\\ \end{array}\]

Reproduce

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