Average Error: 10.6 → 7.0
Time: 3.9s
Precision: binary64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -2.7861430682011674 \cdot 10^{-150} \lor \neg \left(z \leq 6.438744086964507 \cdot 10^{-43}\right):\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t - z \cdot a}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{t - z \cdot a}{x - z \cdot y}}\\ \end{array}\]
\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
\mathbf{if}\;z \leq -2.7861430682011674 \cdot 10^{-150} \lor \neg \left(z \leq 6.438744086964507 \cdot 10^{-43}\right):\\
\;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t - z \cdot a}{z}}\\

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

\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.7861430682011674e-150) (not (<= z 6.438744086964507e-43)))
   (- (/ x (- t (* z a))) (/ y (/ (- t (* z a)) z)))
   (/ 1.0 (/ (- t (* z a)) (- x (* z y))))))
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.7861430682011674e-150) || !(z <= 6.438744086964507e-43)) {
		tmp = (x / (t - (z * a))) - (y / ((t - (z * a)) / z));
	} else {
		tmp = 1.0 / ((t - (z * a)) / (x - (z * y)));
	}
	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.6
Target1.7
Herbie7.0
\[\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.7861430682011674e-150 or 6.4387440869645068e-43 < z

    1. Initial program 16.1

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

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

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

      \[\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*_binary6410.4

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

    if -2.7861430682011674e-150 < z < 6.4387440869645068e-43

    1. Initial program 0.1

      \[\frac{x - y \cdot z}{t - a \cdot z}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity_binary640.1

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x - y \cdot z\right)}}{t - a \cdot z}\]
    4. Applied associate-/l*_binary640.7

      \[\leadsto \color{blue}{\frac{1}{\frac{t - a \cdot z}{x - y \cdot z}}}\]
    5. Simplified0.7

      \[\leadsto \frac{1}{\color{blue}{\frac{t - z \cdot a}{x - y \cdot z}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification7.0

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

Reproduce

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