Average Error: 10.8 → 5.2
Time: 10.7s
Precision: binary64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -\infty:\\ \;\;\;\;\left(-\frac{x}{z \cdot a}\right) - \frac{z}{\frac{t - z \cdot a}{y}}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 1.1791275098182219 \cdot 10^{+269}:\\ \;\;\;\;\frac{x - y \cdot z}{t - z \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} - \frac{x}{z \cdot a}\\ \end{array}\]
\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
\mathbf{if}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -\infty:\\
\;\;\;\;\left(-\frac{x}{z \cdot a}\right) - \frac{z}{\frac{t - z \cdot a}{y}}\\

\mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 1.1791275098182219 \cdot 10^{+269}:\\
\;\;\;\;\frac{x - y \cdot z}{t - z \cdot a}\\

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

\end{array}
(FPCore (x y z t a) :precision binary64 (/ (- x (* y z)) (- t (* a z))))
(FPCore (x y z t a)
 :precision binary64
 (if (<= (/ (- x (* y z)) (- t (* z a))) (- INFINITY))
   (- (- (/ x (* z a))) (/ z (/ (- t (* z a)) y)))
   (if (<= (/ (- x (* y z)) (- t (* z a))) 1.1791275098182219e+269)
     (/ (- x (* y z)) (- t (* z a)))
     (- (/ y a) (/ x (* z a))))))
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 tmp;
	if (((x - (y * z)) / (t - (z * a))) <= -((double) INFINITY)) {
		tmp = -(x / (z * a)) - (z / ((t - (z * a)) / y));
	} else if (((x - (y * z)) / (t - (z * a))) <= 1.1791275098182219e+269) {
		tmp = (x - (y * z)) / (t - (z * a));
	} else {
		tmp = (y / a) - (x / (z * a));
	}
	return tmp;
}

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.8
Target1.8
Herbie5.2
\[\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 3 regimes
  2. if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -inf.0

    1. Initial program 64.0

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

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

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

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

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

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

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

    if -inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 1.1791275098182219e269

    1. Initial program 4.6

      \[\frac{x - y \cdot z}{t - a \cdot z}\]

    if 1.1791275098182219e269 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z)))

    1. Initial program 56.5

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -\infty:\\ \;\;\;\;\left(-\frac{x}{z \cdot a}\right) - \frac{z}{\frac{t - z \cdot a}{y}}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 1.1791275098182219 \cdot 10^{+269}:\\ \;\;\;\;\frac{x - y \cdot z}{t - z \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} - \frac{x}{z \cdot a}\\ \end{array}\]

Reproduce

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