Average Error: 10.9 → 2.2
Time: 4.1s
Precision: binary64
\[\frac{x - y \cdot z}{t - a \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -1.1630780186435354 \cdot 10^{-34} \lor \neg \left(z \leq 1.4508809270850323 \cdot 10^{-194}\right):\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{x - z \cdot y}{t - z \cdot a}} \cdot \left(\sqrt[3]{\frac{x - z \cdot y}{t - z \cdot a}} \cdot \sqrt[3]{\frac{x - z \cdot y}{t - z \cdot a}}\right)\\ \end{array}\]
\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
\mathbf{if}\;z \leq -1.1630780186435354 \cdot 10^{-34} \lor \neg \left(z \leq 1.4508809270850323 \cdot 10^{-194}\right):\\
\;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{\frac{x - z \cdot y}{t - z \cdot a}} \cdot \left(\sqrt[3]{\frac{x - z \cdot y}{t - z \cdot a}} \cdot \sqrt[3]{\frac{x - z \cdot y}{t - z \cdot a}}\right)\\

\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 (or (<= z -1.1630780186435354e-34) (not (<= z 1.4508809270850323e-194)))
   (- (/ x (- t (* z a))) (/ y (- (/ t z) a)))
   (*
    (cbrt (/ (- x (* z y)) (- t (* z a))))
    (*
     (cbrt (/ (- x (* z y)) (- t (* z a))))
     (cbrt (/ (- x (* z y)) (- 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 ((z <= -1.1630780186435354e-34) || !(z <= 1.4508809270850323e-194)) {
		tmp = (x / (t - (z * a))) - (y / ((t / z) - a));
	} else {
		tmp = cbrt((x - (z * y)) / (t - (z * a))) * (cbrt((x - (z * y)) / (t - (z * a))) * cbrt((x - (z * y)) / (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.9
Target1.6
Herbie2.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 2 regimes
  2. if z < -1.1630780186435354e-34 or 1.4508809270850323e-194 < z

    1. Initial program 15.8

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

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

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

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

      \[\leadsto \frac{x}{t - z \cdot a} - \color{blue}{\frac{y}{\frac{t - z \cdot a}{z}}}\]
    8. Using strategy rm
    9. Applied div-sub_binary6410.5

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

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

    if -1.1630780186435354e-34 < z < 1.4508809270850323e-194

    1. Initial program 0.1

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

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{x - y \cdot z}{t - a \cdot z}} \cdot \sqrt[3]{\frac{x - y \cdot z}{t - a \cdot z}}\right) \cdot \sqrt[3]{\frac{x - y \cdot z}{t - a \cdot z}}}\]
    4. Simplified1.2

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{x - y \cdot z}{t - z \cdot a}} \cdot \sqrt[3]{\frac{x - y \cdot z}{t - z \cdot a}}\right)} \cdot \sqrt[3]{\frac{x - y \cdot z}{t - a \cdot z}}\]
    5. Simplified1.2

      \[\leadsto \left(\sqrt[3]{\frac{x - y \cdot z}{t - z \cdot a}} \cdot \sqrt[3]{\frac{x - y \cdot z}{t - z \cdot a}}\right) \cdot \color{blue}{\sqrt[3]{\frac{x - y \cdot z}{t - z \cdot a}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.1630780186435354 \cdot 10^{-34} \lor \neg \left(z \leq 1.4508809270850323 \cdot 10^{-194}\right):\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{x - z \cdot y}{t - z \cdot a}} \cdot \left(\sqrt[3]{\frac{x - z \cdot y}{t - z \cdot a}} \cdot \sqrt[3]{\frac{x - z \cdot y}{t - z \cdot a}}\right)\\ \end{array}\]

Reproduce

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