(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 (/ (- x (* y z)) t_1)))
(if (<= t_3 -1.8021950710243513e-25)
(- t_2 (* y (/ z t_1)))
(if (<= t_3 4.1429951425011623e+307)
(- t_2 (/ (* y z) t_1))
(fma x (/ 1.0 t_1) (/ 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 = (x - (y * z)) / t_1;
double tmp;
if (t_3 <= -1.8021950710243513e-25) {
tmp = t_2 - (y * (z / t_1));
} else if (t_3 <= 4.1429951425011623e+307) {
tmp = t_2 - ((y * z) / t_1);
} else {
tmp = fma(x, (1.0 / t_1), (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(Float64(x - Float64(y * z)) / t_1) tmp = 0.0 if (t_3 <= -1.8021950710243513e-25) tmp = Float64(t_2 - Float64(y * Float64(z / t_1))); elseif (t_3 <= 4.1429951425011623e+307) tmp = Float64(t_2 - Float64(Float64(y * z) / t_1)); else tmp = fma(x, Float64(1.0 / t_1), 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[(N[(x - N[(y * z), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, If[LessEqual[t$95$3, -1.8021950710243513e-25], N[(t$95$2 - N[(y * N[(z / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 4.1429951425011623e+307], N[(t$95$2 - N[(N[(y * z), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 / t$95$1), $MachinePrecision] + N[(y / a), $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 := \frac{x - y \cdot z}{t_1}\\
\mathbf{if}\;t_3 \leq -1.8021950710243513 \cdot 10^{-25}:\\
\;\;\;\;t_2 - y \cdot \frac{z}{t_1}\\
\mathbf{elif}\;t_3 \leq 4.1429951425011623 \cdot 10^{+307}:\\
\;\;\;\;t_2 - \frac{y \cdot z}{t_1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{1}{t_1}, \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.7 |
|---|---|
| Target | 1.9 |
| Herbie | 4.8 |
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -1.80219507102435134e-25Initial program 8.8
Taylor expanded in x around 0 8.8
Applied egg-rr0.2
if -1.80219507102435134e-25 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 4.14299514250116234e307Initial program 5.9
Taylor expanded in x around 0 5.9
if 4.14299514250116234e307 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 63.9
Taylor expanded in x around 0 63.9
Applied egg-rr63.9
Taylor expanded in z around inf 10.4
Final simplification4.8
herbie shell --seed 2022150
(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))))