Average Error: 11.0 → 1.9
Time: 12.7s
Precision: binary64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.12417682228779783 \cdot 10^{-131} \lor \neg \left(z \le 936119.89666916011\right):\\ \;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\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 -5.12417682228779783 \cdot 10^{-131} \lor \neg \left(z \le 936119.89666916011\right):\\
\;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\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 <= -5.124176822287798e-131) || !(z <= 936119.8966691601))) {
		VAR = ((double) ((x / ((double) (t - ((double) (a * z))))) - (y / ((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.9
\[\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 < -5.12417682228779783e-131 or 936119.89666916011 < z

    1. Initial program 18.0

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

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

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

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

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

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

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

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

    if -5.12417682228779783e-131 < z < 936119.89666916011

    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. Simplified3.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.12417682228779783 \cdot 10^{-131} \lor \neg \left(z \le 936119.89666916011\right):\\ \;\;\;\;\frac{x}{t - a \cdot z} - \frac{y}{\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))))