Average Error: 10.5 → 2.2
Time: 4.2s
Precision: binary64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -4.326946295935711 \cdot 10^{-306}:\\ \;\;\;\;\frac{x}{t - z \cdot a} - y \cdot \frac{z}{t - z \cdot a}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 4.603345585494796 \cdot 10^{-273}:\\ \;\;\;\;\frac{1}{\frac{t}{x - y \cdot z} - z \cdot \frac{a}{x - y \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}\\ \end{array}\]
\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
\mathbf{if}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -4.326946295935711 \cdot 10^{-306}:\\
\;\;\;\;\frac{x}{t - z \cdot a} - y \cdot \frac{z}{t - z \cdot a}\\

\mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 4.603345585494796 \cdot 10^{-273}:\\
\;\;\;\;\frac{1}{\frac{t}{x - y \cdot z} - z \cdot \frac{a}{x - y \cdot z}}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - 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 (<= (/ (- x (* y z)) (- t (* z a))) -4.326946295935711e-306)
   (- (/ x (- t (* z a))) (* y (/ z (- t (* z a)))))
   (if (<= (/ (- x (* y z)) (- t (* z a))) 4.603345585494796e-273)
     (/ 1.0 (- (/ t (- x (* y z))) (* z (/ a (- x (* y z))))))
     (- (/ x (- t (* z a))) (/ y (- (/ t z) a))))))
double code(double x, double y, double z, double t, double a) {
	return (((double) (x - ((double) (y * z)))) / ((double) (t - ((double) (a * z)))));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (((((double) (x - ((double) (y * z)))) / ((double) (t - ((double) (z * a))))) <= -4.326946295935711e-306)) {
		tmp = ((double) ((x / ((double) (t - ((double) (z * a))))) - ((double) (y * (z / ((double) (t - ((double) (z * a)))))))));
	} else {
		double tmp_1;
		if (((((double) (x - ((double) (y * z)))) / ((double) (t - ((double) (z * a))))) <= 4.603345585494796e-273)) {
			tmp_1 = (1.0 / ((double) ((t / ((double) (x - ((double) (y * z))))) - ((double) (z * (a / ((double) (x - ((double) (y * z))))))))));
		} else {
			tmp_1 = ((double) ((x / ((double) (t - ((double) (z * a))))) - (y / ((double) ((t / z) - a)))));
		}
		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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.5
Target1.5
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 3 regimes
  2. if (/ (- x (* y z)) (- t (* a z))) < -4.32694629593571e-306

    1. Initial program Error: 5.1 bits

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

      \[\leadsto \color{blue}{\frac{x}{t - a \cdot z} - \frac{y \cdot z}{t - a \cdot z}}\]
    4. SimplifiedError: 5.1 bits

      \[\leadsto \color{blue}{\frac{x}{t - z \cdot a}} - \frac{y \cdot z}{t - a \cdot z}\]
    5. SimplifiedError: 1.6 bits

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

    if -4.32694629593571e-306 < (/ (- x (* y z)) (- t (* a z))) < 4.603345585494796e-273

    1. Initial program Error: 21.9 bits

      \[\frac{x - y \cdot z}{t - a \cdot z}\]
    2. Using strategy rm
    3. Applied clear-numError: 23.0 bits

      \[\leadsto \color{blue}{\frac{1}{\frac{t - a \cdot z}{x - y \cdot z}}}\]
    4. SimplifiedError: 23.0 bits

      \[\leadsto \frac{1}{\color{blue}{\frac{t - z \cdot a}{x - y \cdot z}}}\]
    5. Using strategy rm
    6. Applied div-subError: 24.1 bits

      \[\leadsto \frac{1}{\color{blue}{\frac{t}{x - y \cdot z} - \frac{z \cdot a}{x - y \cdot z}}}\]
    7. SimplifiedError: 24.1 bits

      \[\leadsto \frac{1}{\color{blue}{\frac{t}{x - z \cdot y}} - \frac{z \cdot a}{x - y \cdot z}}\]
    8. SimplifiedError: 5.5 bits

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

    if 4.603345585494796e-273 < (/ (- x (* y z)) (- t (* a z)))

    1. Initial program Error: 11.3 bits

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

      \[\leadsto \color{blue}{\frac{x}{t - a \cdot z} - \frac{y \cdot z}{t - a \cdot z}}\]
    4. SimplifiedError: 11.3 bits

      \[\leadsto \color{blue}{\frac{x}{t - z \cdot a}} - \frac{y \cdot z}{t - a \cdot z}\]
    5. SimplifiedError: 8.1 bits

      \[\leadsto \frac{x}{t - z \cdot a} - \color{blue}{y \cdot \frac{z}{t - z \cdot a}}\]
    6. Using strategy rm
    7. Applied pow1Error: 8.1 bits

      \[\leadsto \frac{x}{t - z \cdot a} - y \cdot \color{blue}{{\left(\frac{z}{t - z \cdot a}\right)}^{1}}\]
    8. Applied pow1Error: 8.1 bits

      \[\leadsto \frac{x}{t - z \cdot a} - \color{blue}{{y}^{1}} \cdot {\left(\frac{z}{t - z \cdot a}\right)}^{1}\]
    9. Applied pow-prod-downError: 8.1 bits

      \[\leadsto \frac{x}{t - z \cdot a} - \color{blue}{{\left(y \cdot \frac{z}{t - z \cdot a}\right)}^{1}}\]
    10. SimplifiedError: 1.4 bits

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -4.326946295935711 \cdot 10^{-306}:\\ \;\;\;\;\frac{x}{t - z \cdot a} - y \cdot \frac{z}{t - z \cdot a}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 4.603345585494796 \cdot 10^{-273}:\\ \;\;\;\;\frac{1}{\frac{t}{x - y \cdot z} - z \cdot \frac{a}{x - y \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}\\ \end{array}\]

Reproduce

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