\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
t_1 := t - z \cdot a\\
t_2 := \frac{x - y \cdot z}{t_1}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a \cdot a}, \frac{t}{z}, \frac{y}{a}\right) - \frac{x}{z \cdot a}\\
\mathbf{elif}\;t_2 \leq -5.637 \cdot 10^{-320}:\\
\;\;\;\;\frac{x}{t_1} - \frac{y \cdot z}{t_1}\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;\frac{1}{\frac{a}{y}}\\
\mathbf{elif}\;t_2 \leq 2.3386699643334804 \cdot 10^{+298}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{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 (- t (* z a))) (t_2 (/ (- x (* y z)) t_1)))
(if (<= t_2 (- INFINITY))
(- (fma (/ y (* a a)) (/ t z) (/ y a)) (/ x (* z a)))
(if (<= t_2 -5.637e-320)
(- (/ x t_1) (/ (* y z) t_1))
(if (<= t_2 0.0)
(/ 1.0 (/ a y))
(if (<= t_2 2.3386699643334804e+298) t_2 (/ y 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 = t - (z * a);
double t_2 = (x - (y * z)) / t_1;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = fma((y / (a * a)), (t / z), (y / a)) - (x / (z * a));
} else if (t_2 <= -5.637e-320) {
tmp = (x / t_1) - ((y * z) / t_1);
} else if (t_2 <= 0.0) {
tmp = 1.0 / (a / y);
} else if (t_2 <= 2.3386699643334804e+298) {
tmp = t_2;
} else {
tmp = y / a;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
| Original | 10.9 |
|---|---|
| Target | 1.9 |
| Herbie | 5.6 |
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -inf.0Initial program 64.0
Applied clear-num_binary6464.0
Taylor expanded in z around inf 33.1
Simplified31.7
if -inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -5.63679e-320Initial program 0.2
Applied div-sub_binary640.2
Simplified0.2
Simplified0.2
if -5.63679e-320 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 0.0Initial program 25.8
Applied clear-num_binary6425.9
Taylor expanded in z around inf 24.6
if 0.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 2.33866996433348039e298Initial program 0.2
Applied *-un-lft-identity_binary640.2
Applied add-cube-cbrt_binary641.3
Applied times-frac_binary641.3
Simplified1.3
Simplified1.3
Taylor expanded in x around 0 0.2
Simplified0.2
if 2.33866996433348039e298 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 61.7
Taylor expanded in z around inf 11.9
Final simplification5.6
herbie shell --seed 2022077
(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))))