(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 (fma a (- z) t)) (/ y (- (/ t z) a))))
(t_2 (- t (* z a))))
(if (<= z -4.3e+21)
t_1
(if (<= z 4.1e+49) (- (/ x t_2) (/ (* z y) t_2)) 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 = (x / fma(a, -z, t)) - (y / ((t / z) - a));
double t_2 = t - (z * a);
double tmp;
if (z <= -4.3e+21) {
tmp = t_1;
} else if (z <= 4.1e+49) {
tmp = (x / t_2) - ((z * y) / t_2);
} else {
tmp = t_1;
}
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(Float64(x / fma(a, Float64(-z), t)) - Float64(y / Float64(Float64(t / z) - a))) t_2 = Float64(t - Float64(z * a)) tmp = 0.0 if (z <= -4.3e+21) tmp = t_1; elseif (z <= 4.1e+49) tmp = Float64(Float64(x / t_2) - Float64(Float64(z * y) / t_2)); else tmp = t_1; 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[(N[(x / N[(a * (-z) + t), $MachinePrecision]), $MachinePrecision] - N[(y / N[(N[(t / z), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.3e+21], t$95$1, If[LessEqual[z, 4.1e+49], N[(N[(x / t$95$2), $MachinePrecision] - N[(N[(z * y), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\frac{x - y \cdot z}{t - a \cdot z}
\begin{array}{l}
t_1 := \frac{x}{\mathsf{fma}\left(a, -z, t\right)} - \frac{y}{\frac{t}{z} - a}\\
t_2 := t - z \cdot a\\
\mathbf{if}\;z \leq -4.3 \cdot 10^{+21}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 4.1 \cdot 10^{+49}:\\
\;\;\;\;\frac{x}{t_2} - \frac{z \cdot y}{t_2}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
| Original | 10.7 |
|---|---|
| Target | 1.8 |
| Herbie | 1.7 |
if z < -4.3e21 or 4.1e49 < z Initial program 23.4
Taylor expanded in x around 0 23.4
Simplified14.5
Taylor expanded in t around 0 3.2
Taylor expanded in x around 0 3.2
Simplified3.2
if -4.3e21 < z < 4.1e49Initial program 0.5
Taylor expanded in x around 0 0.5
Simplified2.8
Taylor expanded in y around 0 0.5
Final simplification1.7
herbie shell --seed 2022165
(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))))