(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 t_1))
(t_3 (- t_2 (* y (/ z t_1))))
(t_4 (/ (- x (* y z)) t_1)))
(if (<= t_4 -1.3626397029500643e-289)
t_3
(if (<= t_4 0.0)
(/ (- y (/ x z)) a)
(if (<= t_4 INFINITY)
t_3
(+ t_2 (fma (/ y (* a a)) (/ t z) (/ 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 / t_1;
double t_3 = t_2 - (y * (z / t_1));
double t_4 = (x - (y * z)) / t_1;
double tmp;
if (t_4 <= -1.3626397029500643e-289) {
tmp = t_3;
} else if (t_4 <= 0.0) {
tmp = (y - (x / z)) / a;
} else if (t_4 <= ((double) INFINITY)) {
tmp = t_3;
} else {
tmp = t_2 + fma((y / (a * a)), (t / z), (y / a));
}
return tmp;
}
function code(x, y, z, t, a) return Float64(Float64(x - Float64(y * z)) / Float64(t - Float64(a * z))) end
function code(x, y, z, t, a) t_1 = Float64(t - Float64(z * a)) t_2 = Float64(x / t_1) t_3 = Float64(t_2 - Float64(y * Float64(z / t_1))) t_4 = Float64(Float64(x - Float64(y * z)) / t_1) tmp = 0.0 if (t_4 <= -1.3626397029500643e-289) tmp = t_3; elseif (t_4 <= 0.0) tmp = Float64(Float64(y - Float64(x / z)) / a); elseif (t_4 <= Inf) tmp = t_3; else tmp = Float64(t_2 + fma(Float64(y / Float64(a * a)), Float64(t / z), Float64(y / a))); end return tmp end
code[x_, y_, z_, t_, a_] := N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(t - N[(a * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 - N[(y * N[(z / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$4, -1.3626397029500643e-289], t$95$3, If[LessEqual[t$95$4, 0.0], N[(N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[t$95$4, Infinity], t$95$3, N[(t$95$2 + N[(N[(y / N[(a * a), $MachinePrecision]), $MachinePrecision] * N[(t / z), $MachinePrecision] + N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
t_1 := t - z \cdot a\\
t_2 := \frac{x}{t_1}\\
t_3 := t_2 - y \cdot \frac{z}{t_1}\\
t_4 := \frac{x - y \cdot z}{t_1}\\
\mathbf{if}\;t_4 \leq -1.3626397029500643 \cdot 10^{-289}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_4 \leq 0:\\
\;\;\;\;\frac{y - \frac{x}{z}}{a}\\
\mathbf{elif}\;t_4 \leq \infty:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;t_2 + \mathsf{fma}\left(\frac{y}{a \cdot a}, \frac{t}{z}, \frac{y}{a}\right)\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
| Original | 10.8 |
|---|---|
| Target | 1.8 |
| Herbie | 4.5 |
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -1.3626397029500643e-289 or 0.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < +inf.0Initial program 5.2
Taylor expanded in x around 0 5.2
Simplified1.8
Applied egg-rr1.9
Applied egg-rr2.3
Applied egg-rr1.8
if -1.3626397029500643e-289 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 0.0Initial program 24.0
Taylor expanded in x around 0 24.0
Simplified24.4
Taylor expanded in t around 0 29.4
Simplified19.5
if +inf.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 64.0
Taylor expanded in x around 0 64.0
Simplified61.9
Applied egg-rr61.9
Taylor expanded in z around inf 18.5
Simplified0
Final simplification4.5
herbie shell --seed 2022151
(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))))