Average Error: 11.0 → 1.8
Time: 6.9s
Precision: binary64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.7721167568229886 \cdot 10^{-25} \lor \neg \left(z \le 1147648.3091264321\right):\\ \;\;\;\;\frac{x}{t - a \cdot z} - y \cdot \frac{1}{\frac{t}{z} - a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t - a \cdot z} - \frac{y \cdot z}{t - a \cdot z}\\ \end{array}\]
\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -3.7721167568229886 \cdot 10^{-25} \lor \neg \left(z \le 1147648.3091264321\right):\\
\;\;\;\;\frac{x}{t - a \cdot z} - y \cdot \frac{1}{\frac{t}{z} - a}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{t - a \cdot z} - \frac{y \cdot z}{t - a \cdot z}\\

\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 <= -3.7721167568229886e-25) || !(z <= 1147648.309126432))) {
		VAR = ((double) ((x / ((double) (t - ((double) (a * z))))) - ((double) (y * (1.0 / ((double) ((t / z) - a)))))));
	} else {
		VAR = ((double) ((x / ((double) (t - ((double) (a * z))))) - (((double) (y * z)) / ((double) (t - ((double) (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

Original11.0
Target1.9
Herbie1.8
\[\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 < -3.7721167568229886e-25 or 1147648.3091264321 < z

    1. Initial program 20.9

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

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

      \[\leadsto \frac{x}{t - a \cdot z} - \color{blue}{y \cdot \frac{z}{t - a \cdot z}}\]
    5. Using strategy rm
    6. Applied clear-num13.6

      \[\leadsto \frac{x}{t - a \cdot z} - y \cdot \color{blue}{\frac{1}{\frac{t - a \cdot z}{z}}}\]
    7. Taylor expanded around 0 3.2

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

    if -3.7721167568229886e-25 < z < 1147648.3091264321

    1. Initial program 0.1

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

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

      \[\leadsto \frac{x}{t - a \cdot z} - \color{blue}{y \cdot \frac{z}{t - a \cdot z}}\]
    5. Using strategy rm
    6. Applied associate-*r/0.1

      \[\leadsto \frac{x}{t - a \cdot z} - \color{blue}{\frac{y \cdot z}{t - a \cdot z}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.8

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

Reproduce

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