Average Error: 10.5 → 2.0
Time: 5.6s
Precision: binary64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -355843.91148429969 \lor \neg \left(z \le 1.29298757069359832 \cdot 10^{-148}\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 \le -355843.91148429969 \lor \neg \left(z \le 1.29298757069359832 \cdot 10^{-148}\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}
double code(double x, double y, double z, double t, double a) {
	return ((double) (((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 <= -355843.9114842997) || !(z <= 1.2929875706935983e-148))) {
		VAR = ((double) (((double) (x / ((double) (t - ((double) (z * a)))))) - ((double) (y / ((double) (((double) (t / z)) - a))))));
	} else {
		VAR = ((double) (((double) (x - ((double) (z * y)))) / ((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.5
Target1.9
Herbie2.0
\[\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 < -355843.91148429969 or 1.29298757069359832e-148 < z

    1. Initial program 16.7

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

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

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

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

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

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

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

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

    if -355843.91148429969 < z < 1.29298757069359832e-148

    1. Initial program 0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -355843.91148429969 \lor \neg \left(z \le 1.29298757069359832 \cdot 10^{-148}\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 2020184 
(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))))