(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)))
(if (<= t_3 -5e-248)
(- (/ x t_2) (* z (/ y t_2)))
(if (<= t_3 0.0)
(pow (- (/ t t_1) (* z (/ a t_1))) -1.0)
(if (<= t_3 5e+260) t_3 (/ y (- a (/ t z))))))))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 tmp;
if (t_3 <= -5e-248) {
tmp = (x / t_2) - (z * (y / t_2));
} else if (t_3 <= 0.0) {
tmp = pow(((t / t_1) - (z * (a / t_1))), -1.0);
} else if (t_3 <= 5e+260) {
tmp = t_3;
} else {
tmp = y / (a - (t / z));
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = (x - (y * z)) / (t - (a * z))
end function
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_1 = x - (y * z)
t_2 = t - (z * a)
t_3 = t_1 / t_2
if (t_3 <= (-5d-248)) then
tmp = (x / t_2) - (z * (y / t_2))
else if (t_3 <= 0.0d0) then
tmp = ((t / t_1) - (z * (a / t_1))) ** (-1.0d0)
else if (t_3 <= 5d+260) then
tmp = t_3
else
tmp = y / (a - (t / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
return (x - (y * z)) / (t - (a * z));
}
public static 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 tmp;
if (t_3 <= -5e-248) {
tmp = (x / t_2) - (z * (y / t_2));
} else if (t_3 <= 0.0) {
tmp = Math.pow(((t / t_1) - (z * (a / t_1))), -1.0);
} else if (t_3 <= 5e+260) {
tmp = t_3;
} else {
tmp = y / (a - (t / z));
}
return tmp;
}
def code(x, y, z, t, a): return (x - (y * z)) / (t - (a * z))
def code(x, y, z, t, a): t_1 = x - (y * z) t_2 = t - (z * a) t_3 = t_1 / t_2 tmp = 0 if t_3 <= -5e-248: tmp = (x / t_2) - (z * (y / t_2)) elif t_3 <= 0.0: tmp = math.pow(((t / t_1) - (z * (a / t_1))), -1.0) elif t_3 <= 5e+260: tmp = t_3 else: tmp = y / (a - (t / z)) 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(x - Float64(y * z)) t_2 = Float64(t - Float64(z * a)) t_3 = Float64(t_1 / t_2) tmp = 0.0 if (t_3 <= -5e-248) tmp = Float64(Float64(x / t_2) - Float64(z * Float64(y / t_2))); elseif (t_3 <= 0.0) tmp = Float64(Float64(t / t_1) - Float64(z * Float64(a / t_1))) ^ -1.0; elseif (t_3 <= 5e+260) tmp = t_3; else tmp = Float64(y / Float64(a - Float64(t / z))); end return tmp end
function tmp = code(x, y, z, t, a) tmp = (x - (y * z)) / (t - (a * z)); end
function tmp_2 = code(x, y, z, t, a) t_1 = x - (y * z); t_2 = t - (z * a); t_3 = t_1 / t_2; tmp = 0.0; if (t_3 <= -5e-248) tmp = (x / t_2) - (z * (y / t_2)); elseif (t_3 <= 0.0) tmp = ((t / t_1) - (z * (a / t_1))) ^ -1.0; elseif (t_3 <= 5e+260) tmp = t_3; else tmp = y / (a - (t / z)); end tmp_2 = 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[(x - N[(y * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t - N[(z * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 / t$95$2), $MachinePrecision]}, If[LessEqual[t$95$3, -5e-248], N[(N[(x / t$95$2), $MachinePrecision] - N[(z * N[(y / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.0], N[Power[N[(N[(t / t$95$1), $MachinePrecision] - N[(z * N[(a / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], If[LessEqual[t$95$3, 5e+260], t$95$3, N[(y / N[(a - N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\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}\\
\mathbf{if}\;t_3 \leq -5 \cdot 10^{-248}:\\
\;\;\;\;\frac{x}{t_2} - z \cdot \frac{y}{t_2}\\
\mathbf{elif}\;t_3 \leq 0:\\
\;\;\;\;{\left(\frac{t}{t_1} - z \cdot \frac{a}{t_1}\right)}^{-1}\\
\mathbf{elif}\;t_3 \leq 5 \cdot 10^{+260}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a - \frac{t}{z}}\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
Results
| Original | 10.5 |
|---|---|
| Target | 1.6 |
| Herbie | 3.0 |
if (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < -5.0000000000000001e-248Initial program 5.0
Applied egg-rr5.4
Taylor expanded in x around 0 5.0
Simplified3.5
if -5.0000000000000001e-248 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 0.0Initial program 21.8
Applied egg-rr22.4
Taylor expanded in t around 0 24.1
Simplified5.6
if 0.0 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) < 4.9999999999999996e260Initial program 0.2
Applied egg-rr0.6
Taylor expanded in x around 0 0.2
Simplified0.2
if 4.9999999999999996e260 < (/.f64 (-.f64 x (*.f64 y z)) (-.f64 t (*.f64 a z))) Initial program 53.3
Applied egg-rr53.4
Taylor expanded in t around 0 53.4
Simplified54.9
Taylor expanded in y around inf 7.2
Final simplification3.0
herbie shell --seed 2022156
(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))))