\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
t_1 := x - y \cdot z\\
t_2 := t - z \cdot a\\
t_3 := \frac{t_1}{t_2}\\
t_4 := \frac{x}{t_2}\\
\mathbf{if}\;t_3 \leq -1.6490978098404618 \cdot 10^{-72}:\\
\;\;\;\;t_4 - \frac{y}{\frac{t_2}{z}}\\
\mathbf{elif}\;t_3 \leq -1.91994533465 \cdot 10^{-313}:\\
\;\;\;\;t_1 \cdot \frac{1}{t_2}\\
\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\
\mathbf{elif}\;t_3 \leq 1.4642476401666246 \cdot 10^{+25}:\\
\;\;\;\;t_4 - \frac{y \cdot z}{t_2}\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;t_4 - y \cdot \frac{z}{t_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} - \frac{x}{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
(let* ((t_1 (- x (* y z)))
(t_2 (- t (* z a)))
(t_3 (/ t_1 t_2))
(t_4 (/ x t_2)))
(if (<= t_3 -1.6490978098404618e-72)
(- t_4 (/ y (/ t_2 z)))
(if (<= t_3 -1.91994533465e-313)
(* t_1 (/ 1.0 t_2))
(if (<= t_3 0.0)
(/ (- y (/ x z)) a)
(if (<= t_3 1.4642476401666246e+25)
(- t_4 (/ (* y z) t_2))
(if (<= t_3 INFINITY)
(- t_4 (* y (/ z t_2)))
(- (/ y a) (/ x (* 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 t_1 = x - (y * z);
double t_2 = t - (z * a);
double t_3 = t_1 / t_2;
double t_4 = x / t_2;
double tmp;
if (t_3 <= -1.6490978098404618e-72) {
tmp = t_4 - (y / (t_2 / z));
} else if (t_3 <= -1.91994533465e-313) {
tmp = t_1 * (1.0 / t_2);
} else if (t_3 <= 0.0) {
tmp = (y - (x / z)) / a;
} else if (t_3 <= 1.4642476401666246e+25) {
tmp = t_4 - ((y * z) / t_2);
} else if (t_3 <= ((double) INFINITY)) {
tmp = t_4 - (y * (z / t_2));
} else {
tmp = (y / a) - (x / (z * a));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
Results
| Original | 10.2 |
|---|---|
| Target | 1.8 |
| Herbie | 2.6 |
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -1.64909780984046183e-72Initial program 7.0
rmApplied div-sub_binary647.0
Simplified7.0
Simplified7.0
rmApplied associate-/l*_binary640.3
if -1.64909780984046183e-72 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -1.91994533465e-313Initial program 0.2
rmApplied div-inv_binary640.4
Simplified0.4
if -1.91994533465e-313 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 0.0Initial program 25.3
rmApplied div-sub_binary6425.3
Simplified25.3
Simplified25.3
Taylor expanded in a around inf 16.5
if 0.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 1.4642476401666246e25Initial program 0.2
rmApplied div-sub_binary640.2
Simplified0.2
Simplified0.2
rmApplied cancel-sign-sub-inv_binary640.2
if 1.4642476401666246e25 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < +inf.0Initial program 9.6
rmApplied div-sub_binary649.6
Simplified9.6
Simplified9.6
rmApplied *-un-lft-identity_binary649.6
Applied times-frac_binary640.2
Simplified0.2
if +inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 64.0
rmApplied div-sub_binary6464.0
Simplified64.0
Simplified64.0
Taylor expanded in a around inf 0
Simplified0.1
Final simplification2.6
herbie shell --seed 2021206
(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))))