(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
:precision binary64
(let* ((t_0 (/ (* a1 a2) (* b1 b2))) (t_1 (* (/ a1 b1) (/ a2 b2))))
(if (<= t_0 (- INFINITY))
(/ (* a2 (/ a1 b2)) b1)
(if (<= t_0 -3.971449504747777e-256)
t_0
(if (<= t_0 4.3318940274796574e-291)
t_1
(if (<= t_0 1.134688516477658e+283) t_0 t_1))))))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 * a2) / (b1 * b2);
double t_1 = (a1 / b1) * (a2 / b2);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (a2 * (a1 / b2)) / b1;
} else if (t_0 <= -3.971449504747777e-256) {
tmp = t_0;
} else if (t_0 <= 4.3318940274796574e-291) {
tmp = t_1;
} else if (t_0 <= 1.134688516477658e+283) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
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 * a2) / (b1 * b2);
double t_1 = (a1 / b1) * (a2 / b2);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (a2 * (a1 / b2)) / b1;
} else if (t_0 <= -3.971449504747777e-256) {
tmp = t_0;
} else if (t_0 <= 4.3318940274796574e-291) {
tmp = t_1;
} else if (t_0 <= 1.134688516477658e+283) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a1, a2, b1, b2): return (a1 * a2) / (b1 * b2)
def code(a1, a2, b1, b2): t_0 = (a1 * a2) / (b1 * b2) t_1 = (a1 / b1) * (a2 / b2) tmp = 0 if t_0 <= -math.inf: tmp = (a2 * (a1 / b2)) / b1 elif t_0 <= -3.971449504747777e-256: tmp = t_0 elif t_0 <= 4.3318940274796574e-291: tmp = t_1 elif t_0 <= 1.134688516477658e+283: tmp = t_0 else: tmp = t_1 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 * a2) / Float64(b1 * b2)) t_1 = Float64(Float64(a1 / b1) * Float64(a2 / b2)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(a2 * Float64(a1 / b2)) / b1); elseif (t_0 <= -3.971449504747777e-256) tmp = t_0; elseif (t_0 <= 4.3318940274796574e-291) tmp = t_1; elseif (t_0 <= 1.134688516477658e+283) tmp = t_0; else tmp = t_1; 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 * a2) / (b1 * b2); t_1 = (a1 / b1) * (a2 / b2); tmp = 0.0; if (t_0 <= -Inf) tmp = (a2 * (a1 / b2)) / b1; elseif (t_0 <= -3.971449504747777e-256) tmp = t_0; elseif (t_0 <= 4.3318940274796574e-291) tmp = t_1; elseif (t_0 <= 1.134688516477658e+283) tmp = t_0; else tmp = t_1; 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 * a2), $MachinePrecision] / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a1 / b1), $MachinePrecision] * N[(a2 / b2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(a2 * N[(a1 / b2), $MachinePrecision]), $MachinePrecision] / b1), $MachinePrecision], If[LessEqual[t$95$0, -3.971449504747777e-256], t$95$0, If[LessEqual[t$95$0, 4.3318940274796574e-291], t$95$1, If[LessEqual[t$95$0, 1.134688516477658e+283], t$95$0, t$95$1]]]]]]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
t_1 := \frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{a2 \cdot \frac{a1}{b2}}{b1}\\
\mathbf{elif}\;t_0 \leq -3.971449504747777 \cdot 10^{-256}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 4.3318940274796574 \cdot 10^{-291}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 1.134688516477658 \cdot 10^{+283}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}




Bits error versus a1




Bits error versus a2




Bits error versus b1




Bits error versus b2
Results
| Original | 11.3 |
|---|---|
| Target | 11.4 |
| Herbie | 2.8 |
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0Initial program 64.0
Applied egg-rr31.3
Applied egg-rr16.2
Applied egg-rr16.4
if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -3.9714495047477771e-256 or 4.33189402747965744e-291 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 1.1346885164776581e283Initial program 0.8
Applied egg-rr7.3
Applied egg-rr14.8
Applied egg-rr0.8
if -3.9714495047477771e-256 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 4.33189402747965744e-291 or 1.1346885164776581e283 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 20.6
Applied egg-rr4.2
Final simplification2.8
herbie shell --seed 2022134
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))