(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 (- (/ t z) a)))))
(if (<= z -1.22074817042731e+59)
t_3
(if (<= z 3.163945609906825e-168)
(- t_2 (pow (/ t_1 (* z y)) -1.0))
t_3))))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 / ((t / z) - a));
double tmp;
if (z <= -1.22074817042731e+59) {
tmp = t_3;
} else if (z <= 3.163945609906825e-168) {
tmp = t_2 - pow((t_1 / (z * y)), -1.0);
} else {
tmp = t_3;
}
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 = t - (z * a)
t_2 = x / t_1
t_3 = t_2 - (y / ((t / z) - a))
if (z <= (-1.22074817042731d+59)) then
tmp = t_3
else if (z <= 3.163945609906825d-168) then
tmp = t_2 - ((t_1 / (z * y)) ** (-1.0d0))
else
tmp = t_3
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 = t - (z * a);
double t_2 = x / t_1;
double t_3 = t_2 - (y / ((t / z) - a));
double tmp;
if (z <= -1.22074817042731e+59) {
tmp = t_3;
} else if (z <= 3.163945609906825e-168) {
tmp = t_2 - Math.pow((t_1 / (z * y)), -1.0);
} else {
tmp = t_3;
}
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 = t - (z * a) t_2 = x / t_1 t_3 = t_2 - (y / ((t / z) - a)) tmp = 0 if z <= -1.22074817042731e+59: tmp = t_3 elif z <= 3.163945609906825e-168: tmp = t_2 - math.pow((t_1 / (z * y)), -1.0) else: tmp = t_3 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(Float64(t / z) - a))) tmp = 0.0 if (z <= -1.22074817042731e+59) tmp = t_3; elseif (z <= 3.163945609906825e-168) tmp = Float64(t_2 - (Float64(t_1 / Float64(z * y)) ^ -1.0)); else tmp = t_3; 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 = t - (z * a); t_2 = x / t_1; t_3 = t_2 - (y / ((t / z) - a)); tmp = 0.0; if (z <= -1.22074817042731e+59) tmp = t_3; elseif (z <= 3.163945609906825e-168) tmp = t_2 - ((t_1 / (z * y)) ^ -1.0); else tmp = t_3; 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[(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[(N[(t / z), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.22074817042731e+59], t$95$3, If[LessEqual[z, 3.163945609906825e-168], N[(t$95$2 - N[Power[N[(t$95$1 / N[(z * y), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision], t$95$3]]]]]
\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 - \frac{y}{\frac{t}{z} - a}\\
\mathbf{if}\;z \leq -1.22074817042731 \cdot 10^{+59}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;z \leq 3.163945609906825 \cdot 10^{-168}:\\
\;\;\;\;t_2 - {\left(\frac{t_1}{z \cdot y}\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\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.8 |
|---|---|
| Target | 1.9 |
| Herbie | 2.3 |
if z < -1.22074817042731008e59 or 3.163945609906825e-168 < z Initial program 17.8
Applied egg-rr17.8
Applied egg-rr12.2
Applied egg-rr12.3
Taylor expanded in y around 0 17.8
Simplified3.3
if -1.22074817042731008e59 < z < 3.163945609906825e-168Initial program 0.6
Applied egg-rr0.6
Applied egg-rr0.8
Final simplification2.3
herbie shell --seed 2022153
(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))))