Average Error: 10.3 → 2.5
Time: 3.4s
Precision: 64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.8616407758964315 \cdot 10^{-230} \lor \neg \left(z \le 1.0627976848142006 \cdot 10^{-164}\right):\\ \;\;\;\;\frac{x}{t - a \cdot z} - \frac{1}{\frac{\frac{t}{z} - a}{y}}\\ \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 -2.8616407758964315 \cdot 10^{-230} \lor \neg \left(z \le 1.0627976848142006 \cdot 10^{-164}\right):\\
\;\;\;\;\frac{x}{t - a \cdot z} - \frac{1}{\frac{\frac{t}{z} - a}{y}}\\

\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 ((x - (y * z)) / (t - (a * z)));
}
double code(double x, double y, double z, double t, double a) {
	double VAR;
	if (((z <= -2.8616407758964315e-230) || !(z <= 1.0627976848142006e-164))) {
		VAR = ((x / (t - (a * z))) - (1.0 / (((t / z) - a) / y)));
	} else {
		VAR = ((x - (y * z)) * (1.0 / (t - (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.3
Target1.7
Herbie2.5
\[\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 < -2.8616407758964315e-230 or 1.0627976848142006e-164 < z

    1. Initial program 12.6

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

      \[\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.0

      \[\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.0

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

      \[\leadsto \frac{x}{t - a \cdot z} - \frac{y}{\frac{t}{z} - \color{blue}{a}}\]
    9. Using strategy rm
    10. Applied clear-num3.0

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

    if -2.8616407758964315e-230 < z < 1.0627976848142006e-164

    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.5

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

Reproduce

herbie shell --seed 2020075 
(FPCore (x y z t a)
  :name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, A"
  :precision binary64

  :herbie-target
  (if (< z -32113435955957344) (- (/ x (- t (* a z))) (/ y (- (/ t z) a))) (if (< z 3.5139522372978296e-86) (* (- x (* y z)) (/ 1 (- t (* a z)))) (- (/ x (- t (* a z))) (/ y (- (/ t z) a)))))

  (/ (- x (* y z)) (- t (* a z))))