(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
:precision binary64
(let* ((t_0 (/ (/ a1 b2) (/ b1 a2))) (t_1 (/ (* a1 a2) (* b1 b2))))
(if (<= t_1 -2e-293)
t_1
(if (<= t_1 0.0) t_0 (if (<= t_1 2e+255) t_1 t_0)))))double code(double a1, double a2, double b1, double b2) {
return (a1 * a2) / (b1 * b2);
}
double code(double a1, double a2, double b1, double b2) {
double t_0 = (a1 / b2) / (b1 / a2);
double t_1 = (a1 * a2) / (b1 * b2);
double tmp;
if (t_1 <= -2e-293) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = t_0;
} else if (t_1 <= 2e+255) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a1, a2, b1, b2)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: b1
real(8), intent (in) :: b2
code = (a1 * a2) / (b1 * b2)
end function
real(8) function code(a1, a2, b1, b2)
real(8), intent (in) :: a1
real(8), intent (in) :: a2
real(8), intent (in) :: b1
real(8), intent (in) :: b2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (a1 / b2) / (b1 / a2)
t_1 = (a1 * a2) / (b1 * b2)
if (t_1 <= (-2d-293)) then
tmp = t_1
else if (t_1 <= 0.0d0) then
tmp = t_0
else if (t_1 <= 2d+255) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a1, double a2, double b1, double b2) {
return (a1 * a2) / (b1 * b2);
}
public static double code(double a1, double a2, double b1, double b2) {
double t_0 = (a1 / b2) / (b1 / a2);
double t_1 = (a1 * a2) / (b1 * b2);
double tmp;
if (t_1 <= -2e-293) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = t_0;
} else if (t_1 <= 2e+255) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(a1, a2, b1, b2): return (a1 * a2) / (b1 * b2)
def code(a1, a2, b1, b2): t_0 = (a1 / b2) / (b1 / a2) t_1 = (a1 * a2) / (b1 * b2) tmp = 0 if t_1 <= -2e-293: tmp = t_1 elif t_1 <= 0.0: tmp = t_0 elif t_1 <= 2e+255: tmp = t_1 else: tmp = t_0 return tmp
function code(a1, a2, b1, b2) return Float64(Float64(a1 * a2) / Float64(b1 * b2)) end
function code(a1, a2, b1, b2) t_0 = Float64(Float64(a1 / b2) / Float64(b1 / a2)) t_1 = Float64(Float64(a1 * a2) / Float64(b1 * b2)) tmp = 0.0 if (t_1 <= -2e-293) tmp = t_1; elseif (t_1 <= 0.0) tmp = t_0; elseif (t_1 <= 2e+255) tmp = t_1; else tmp = t_0; end return tmp end
function tmp = code(a1, a2, b1, b2) tmp = (a1 * a2) / (b1 * b2); end
function tmp_2 = code(a1, a2, b1, b2) t_0 = (a1 / b2) / (b1 / a2); t_1 = (a1 * a2) / (b1 * b2); tmp = 0.0; if (t_1 <= -2e-293) tmp = t_1; elseif (t_1 <= 0.0) tmp = t_0; elseif (t_1 <= 2e+255) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[a1_, a2_, b1_, b2_] := N[(N[(a1 * a2), $MachinePrecision] / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]
code[a1_, a2_, b1_, b2_] := Block[{t$95$0 = N[(N[(a1 / b2), $MachinePrecision] / N[(b1 / a2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a1 * a2), $MachinePrecision] / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-293], t$95$1, If[LessEqual[t$95$1, 0.0], t$95$0, If[LessEqual[t$95$1, 2e+255], t$95$1, t$95$0]]]]]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{\frac{a1}{b2}}{\frac{b1}{a2}}\\
t_1 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{-293}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+255}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}




Bits error versus a1




Bits error versus a2




Bits error versus b1




Bits error versus b2
Results
| Original | 11.3 |
|---|---|
| Target | 11.2 |
| Herbie | 4.4 |
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -2.0000000000000001e-293 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 1.99999999999999998e255Initial program 4.4
if -2.0000000000000001e-293 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0 or 1.99999999999999998e255 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 21.4
Simplified15.0
Applied egg-rr14.4
Applied egg-rr4.3
Applied egg-rr4.3
Final simplification4.4
herbie shell --seed 2022166
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))