Average Error: 10.9 → 1.8
Time: 5.3s
Precision: binary64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -3.490398922392778 \cdot 10^{-57} \lor \neg \left(z \leq 2.045405544225239 \cdot 10^{+16}\right):\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - z \cdot y}{t - z \cdot a}\\ \end{array}\]
\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
\mathbf{if}\;z \leq -3.490398922392778 \cdot 10^{-57} \lor \neg \left(z \leq 2.045405544225239 \cdot 10^{+16}\right):\\
\;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}\\

\mathbf{else}:\\
\;\;\;\;\frac{x - z \cdot y}{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 -3.490398922392778e-57) (not (<= z 2.045405544225239e+16)))
   (- (/ x (- t (* z a))) (/ y (- (/ t z) a)))
   (/ (- x (* z 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 (((z <= -3.490398922392778e-57) || !(z <= 2.045405544225239e+16))) {
		tmp = ((double) ((x / ((double) (t - ((double) (z * a))))) - (y / ((double) ((t / z) - a)))));
	} else {
		tmp = (((double) (x - ((double) (z * y)))) / ((double) (t - ((double) (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.9
Target1.9
Herbie1.8
\[\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 < -3.49039892239277772e-57 or 20454055442252392 < z

    1. Initial program Error: 20.7 bits

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

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

      \[\leadsto \color{blue}{\frac{x}{t - z \cdot a}} - \frac{y \cdot z}{t - a \cdot z}\]
    5. SimplifiedError: 13.0 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: 13.0 bits

      \[\leadsto \frac{x}{t - z \cdot a} - y \cdot \color{blue}{{\left(\frac{z}{t - z \cdot a}\right)}^{1}}\]
    8. Applied pow1Error: 13.0 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: 13.0 bits

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

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

    if -3.49039892239277772e-57 < z < 20454055442252392

    1. Initial program Error: 0.1 bits

      \[\frac{x - y \cdot z}{t - a \cdot z}\]
  3. Recombined 2 regimes into one program.
  4. Final simplificationError: 1.8 bits

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.490398922392778 \cdot 10^{-57} \lor \neg \left(z \leq 2.045405544225239 \cdot 10^{+16}\right):\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - z \cdot y}{t - z \cdot a}\\ \end{array}\]

Reproduce

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