Average Error: 10.4 → 1.8
Time: 4.5s
Precision: binary64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -2.901768712204357 \cdot 10^{-14} \lor \neg \left(z \leq 5.062448218448348 \cdot 10^{-131}\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.901768712204357 \cdot 10^{-14} \lor \neg \left(z \leq 5.062448218448348 \cdot 10^{-131}\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}
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 VAR;
	if (((z <= -2.901768712204357e-14) || !(z <= 5.062448218448348e-131))) {
		VAR = ((double) ((x / ((double) (t - ((double) (z * a))))) - (y / ((double) ((t / z) - a)))));
	} else {
		VAR = ((double) (((double) (x - ((double) (z * y)))) * (1.0 / ((double) (t - ((double) (z * a)))))));
	}
	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.4
Target1.7
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 < -2.90176871220435715e-14 or 5.06244821844834846e-131 < z

    1. Initial program 16.8

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

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

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

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

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

      \[\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-down11.1

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

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

    if -2.90176871220435715e-14 < z < 5.06244821844834846e-131

    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}}\]
    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 simplification1.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.901768712204357 \cdot 10^{-14} \lor \neg \left(z \leq 5.062448218448348 \cdot 10^{-131}\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 2020199 
(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))))