Average Error: 10.7 → 1.7
Time: 8.0s
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 -1.945477398004434 \cdot 10^{+304}:\\ \;\;\;\;\frac{-y}{\frac{t}{z} - a}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -1.3715219134961312 \cdot 10^{-297}:\\ \;\;\;\;\frac{x - y \cdot z}{t - z \cdot a}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 0:\\ \;\;\;\;\frac{-1}{\frac{\frac{t}{z} - a}{y}}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 3.300473813311166 \cdot 10^{+303}:\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y \cdot z}{t - z \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-y}{\frac{t}{z} - 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 -1.945477398004434 \cdot 10^{+304}:\\
\;\;\;\;\frac{-y}{\frac{t}{z} - a}\\

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

\mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 0:\\
\;\;\;\;\frac{-1}{\frac{\frac{t}{z} - a}{y}}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{-y}{\frac{t}{z} - 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))) -1.945477398004434e+304)
   (/ (- y) (- (/ t z) a))
   (if (<= (/ (- x (* y z)) (- t (* z a))) -1.3715219134961312e-297)
     (/ (- x (* y z)) (- t (* z a)))
     (if (<= (/ (- x (* y z)) (- t (* z a))) 0.0)
       (/ -1.0 (/ (- (/ t z) a) y))
       (if (<= (/ (- x (* y z)) (- t (* z a))) 3.300473813311166e+303)
         (- (/ x (- t (* z a))) (/ (* y z) (- t (* z a))))
         (/ (- 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 (((x - (y * z)) / (t - (z * a))) <= -1.945477398004434e+304) {
		tmp = -y / ((t / z) - a);
	} else if (((x - (y * z)) / (t - (z * a))) <= -1.3715219134961312e-297) {
		tmp = (x - (y * z)) / (t - (z * a));
	} else if (((x - (y * z)) / (t - (z * a))) <= 0.0) {
		tmp = -1.0 / (((t / z) - a) / y);
	} else if (((x - (y * z)) / (t - (z * a))) <= 3.300473813311166e+303) {
		tmp = (x / (t - (z * a))) - ((y * z) / (t - (z * a)));
	} else {
		tmp = -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.7
Target1.5
Herbie1.7
\[\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))) < -1.9454773980044341e304 or 3.300473813311166e303 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z)))

    1. Initial program 62.1

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

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

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

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

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

    if -1.9454773980044341e304 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -1.3715219134961312e-297

    1. Initial program 0.2

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

    if -1.3715219134961312e-297 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 0.0

    1. Initial program 24.0

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

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

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

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

      \[\leadsto \color{blue}{\frac{-y}{\frac{t}{z} - a}}\]
    7. Using strategy rm
    8. Applied neg-mul-1_binary64_147379.4

      \[\leadsto \frac{\color{blue}{-1 \cdot y}}{\frac{t}{z} - a}\]
    9. Applied associate-/l*_binary64_1468610.1

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

    if 0.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 3.300473813311166e303

    1. Initial program 0.2

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -1.945477398004434 \cdot 10^{+304}:\\ \;\;\;\;\frac{-y}{\frac{t}{z} - a}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq -1.3715219134961312 \cdot 10^{-297}:\\ \;\;\;\;\frac{x - y \cdot z}{t - z \cdot a}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 0:\\ \;\;\;\;\frac{-1}{\frac{\frac{t}{z} - a}{y}}\\ \mathbf{elif}\;\frac{x - y \cdot z}{t - z \cdot a} \leq 3.300473813311166 \cdot 10^{+303}:\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y \cdot z}{t - z \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-y}{\frac{t}{z} - a}\\ \end{array}\]

Reproduce

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