Average Error: 10.8 → 3.4
Time: 8.3s
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:\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{z}{\frac{t - z \cdot a}{y}}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -7.019373338049451 \cdot 10^{-308}:\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y \cdot z}{t - z \cdot a}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 0 \lor \neg \left(\frac{x - y \cdot z}{t - z \cdot a} \leq \infty\right):\\ \;\;\;\;\frac{y - \frac{x}{z}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{z}{\sqrt[3]{t - z \cdot a} \cdot \sqrt[3]{t - z \cdot a}} \cdot \frac{y}{\sqrt[3]{t - 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:\\
\;\;\;\;\frac{x}{t - z \cdot a} - \frac{z}{\frac{t - z \cdot a}{y}}\\

\mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -7.019373338049451 \cdot 10^{-308}:\\
\;\;\;\;\frac{x}{t - z \cdot a} - \frac{y \cdot z}{t - z \cdot a}\\

\mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 0 \lor \neg \left(\frac{x - y \cdot z}{t - z \cdot a} \leq \infty\right):\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{t - z \cdot a} - \frac{z}{\sqrt[3]{t - z \cdot a} \cdot \sqrt[3]{t - z \cdot a}} \cdot \frac{y}{\sqrt[3]{t - 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 (- t (* z a))) (/ z (/ (- t (* z a)) y)))
   (if (<= (/ (- x (* y z)) (- t (* z a))) -7.019373338049451e-308)
     (- (/ x (- t (* z a))) (/ (* y z) (- t (* z a))))
     (if (or (<= (/ (- x (* y z)) (- t (* z a))) 0.0)
             (not (<= (/ (- x (* y z)) (- t (* z a))) INFINITY)))
       (/ (- y (/ x z)) a)
       (-
        (/ x (- t (* z a)))
        (*
         (/ z (* (cbrt (- t (* z a))) (cbrt (- t (* z a)))))
         (/ y (cbrt (- t (* 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 / (t - (z * a))) - (z / ((t - (z * a)) / y));
	} else if (((x - (y * z)) / (t - (z * a))) <= -7.019373338049451e-308) {
		tmp = (x / (t - (z * a))) - ((y * z) / (t - (z * a)));
	} else if ((((x - (y * z)) / (t - (z * a))) <= 0.0) || !(((x - (y * z)) / (t - (z * a))) <= ((double) INFINITY))) {
		tmp = (y - (x / z)) / a;
	} else {
		tmp = (x / (t - (z * a))) - ((z / (cbrt(t - (z * a)) * cbrt(t - (z * a)))) * (y / cbrt(t - (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.9
Herbie3.4
\[\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 4 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_2054364.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_204830.4

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

    if -inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -7.01937333804945066e-308

    1. Initial program 0.2

      \[\frac{x - y \cdot z}{t - a \cdot z}\]
    2. Taylor expanded around 0 0.2

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

    if -7.01937333804945066e-308 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 0.0 or +inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z)))

    1. Initial program 34.2

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

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

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

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

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

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

    1. Initial program 4.8

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

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

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

      \[\leadsto \frac{x}{t - z \cdot a} - \color{blue}{\frac{z \cdot y}{t - z \cdot a}}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt_binary64_205735.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -\infty:\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{z}{\frac{t - z \cdot a}{y}}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -7.019373338049451 \cdot 10^{-308}:\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y \cdot z}{t - z \cdot a}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 0 \lor \neg \left(\frac{x - y \cdot z}{t - z \cdot a} \leq \infty\right):\\ \;\;\;\;\frac{y - \frac{x}{z}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{z}{\sqrt[3]{t - z \cdot a} \cdot \sqrt[3]{t - z \cdot a}} \cdot \frac{y}{\sqrt[3]{t - z \cdot a}}\\ \end{array}\]

Reproduce

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