Average Error: 10.6 → 2.1
Time: 11.1s
Precision: binary64
\[\frac{x - y \cdot z}{t - a \cdot z} \]
\[\begin{array}{l} t_1 := t - z \cdot a\\ \mathbf{if}\;z \leq -4.264720045142372 \cdot 10^{+44} \lor \neg \left(z \leq 3.936325700975888 \cdot 10^{-156}\right):\\ \;\;\;\;\frac{x}{t_1} - \frac{y}{\frac{t}{z} - a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - z \cdot y}{t_1}\\ \end{array} \]
\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
t_1 := t - z \cdot a\\
\mathbf{if}\;z \leq -4.264720045142372 \cdot 10^{+44} \lor \neg \left(z \leq 3.936325700975888 \cdot 10^{-156}\right):\\
\;\;\;\;\frac{x}{t_1} - \frac{y}{\frac{t}{z} - a}\\

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


\end{array}
(FPCore (x y z t a) :precision binary64 (/ (- x (* y z)) (- t (* a z))))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (- t (* z a))))
   (if (or (<= z -4.264720045142372e+44) (not (<= z 3.936325700975888e-156)))
     (- (/ x t_1) (/ y (- (/ t z) a)))
     (/ (- x (* z y)) t_1))))
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 t_1 = t - (z * a);
	double tmp;
	if ((z <= -4.264720045142372e+44) || !(z <= 3.936325700975888e-156)) {
		tmp = (x / t_1) - (y / ((t / z) - a));
	} else {
		tmp = (x - (z * y)) / t_1;
	}
	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.9
Herbie2.1
\[\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 < -4.26472004514237164e44 or 3.9363257009758882e-156 < z

    1. Initial program 17.7

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

      \[\leadsto \color{blue}{\frac{x}{t - a \cdot z} - \frac{y \cdot z}{t - a \cdot z}} \]
    3. Applied *-un-lft-identity_binary6417.7

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

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

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

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

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

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

    if -4.26472004514237164e44 < z < 3.9363257009758882e-156

    1. Initial program 0.4

      \[\frac{x - y \cdot z}{t - a \cdot z} \]
    2. Applied *-un-lft-identity_binary640.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.264720045142372 \cdot 10^{+44} \lor \neg \left(z \leq 3.936325700975888 \cdot 10^{-156}\right):\\ \;\;\;\;\frac{x}{t - z \cdot a} - \frac{y}{\frac{t}{z} - a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - z \cdot y}{t - z \cdot a}\\ \end{array} \]

Reproduce

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