Average Error: 10.6 → 3.6
Time: 9.1s
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 -2.9564897525780336 \cdot 10^{-253}:\\ \;\;\;\;\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}}\\ \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 4.2228747849827575 \cdot 10^{+273}\right):\\ \;\;\;\;\frac{-y}{\frac{t}{z} - a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y \cdot z}{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 -2.9564897525780336 \cdot 10^{-253}:\\
\;\;\;\;\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}}\\

\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 4.2228747849827575 \cdot 10^{+273}\right):\\
\;\;\;\;\frac{-y}{\frac{t}{z} - a}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{t - z \cdot a} - \frac{y \cdot z}{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))) -2.9564897525780336e-253)
   (-
    (/ x (- t (* z a)))
    (*
     (/ z (* (cbrt (- t (* z a))) (cbrt (- t (* z a)))))
     (/ y (cbrt (- t (* z a))))))
   (if (or (<= (/ (- x (* y z)) (- t (* z a))) 0.0)
           (not (<= (/ (- x (* y z)) (- t (* z a))) 4.2228747849827575e+273)))
     (/ (- y) (- (/ t z) a))
     (- (/ x (- t (* z a))) (/ (* y z) (- 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))) <= -2.9564897525780336e-253) {
		tmp = (x / (t - (z * a))) - ((z / (cbrt(t - (z * a)) * cbrt(t - (z * a)))) * (y / cbrt(t - (z * a))));
	} else if ((((x - (y * z)) / (t - (z * a))) <= 0.0) || !(((x - (y * z)) / (t - (z * a))) <= 4.2228747849827575e+273)) {
		tmp = -y / ((t / z) - a);
	} else {
		tmp = (x / (t - (z * a))) - ((y * z) / (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.6
Target1.6
Herbie3.6
\[\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))) < -2.95648975257803358e-253

    1. Initial program 5.1

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

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

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

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

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

      \[\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}}}\]

    if -2.95648975257803358e-253 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 0.0 or 4.2228747849827575e273 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z)))

    1. Initial program 33.8

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

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

      \[\leadsto \left(x - y \cdot z\right) \cdot \color{blue}{\frac{1}{t - z \cdot a}}\]
    5. Taylor expanded around 0 38.5

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

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

    if 0.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 4.2228747849827575e273

    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}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -2.9564897525780336 \cdot 10^{-253}:\\ \;\;\;\;\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}}\\ \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 4.2228747849827575 \cdot 10^{+273}\right):\\ \;\;\;\;\frac{-y}{\frac{t}{z} - a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y \cdot z}{t - z \cdot a}\\ \end{array}\]

Reproduce

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