(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 (* (/ a2 b1) (/ a1 b2))))
(if (<= t_0 (- INFINITY))
(/ (* a1 (/ a2 b1)) b2)
(if (<= t_0 -2.5081840773185255e-287)
t_0
(if (<= t_0 0.0) t_1 (if (<= t_0 3.9722919166057204e+277) 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 = (a2 / b1) * (a1 / b2);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (a1 * (a2 / b1)) / b2;
} else if (t_0 <= -2.5081840773185255e-287) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 3.9722919166057204e+277) {
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 = (a2 / b1) * (a1 / b2);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (a1 * (a2 / b1)) / b2;
} else if (t_0 <= -2.5081840773185255e-287) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 3.9722919166057204e+277) {
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 = (a2 / b1) * (a1 / b2) tmp = 0 if t_0 <= -math.inf: tmp = (a1 * (a2 / b1)) / b2 elif t_0 <= -2.5081840773185255e-287: tmp = t_0 elif t_0 <= 0.0: tmp = t_1 elif t_0 <= 3.9722919166057204e+277: 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(a2 / b1) * Float64(a1 / b2)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(a1 * Float64(a2 / b1)) / b2); elseif (t_0 <= -2.5081840773185255e-287) tmp = t_0; elseif (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 3.9722919166057204e+277) 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 = (a2 / b1) * (a1 / b2); tmp = 0.0; if (t_0 <= -Inf) tmp = (a1 * (a2 / b1)) / b2; elseif (t_0 <= -2.5081840773185255e-287) tmp = t_0; elseif (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 3.9722919166057204e+277) 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[(a2 / b1), $MachinePrecision] * N[(a1 / b2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(a1 * N[(a2 / b1), $MachinePrecision]), $MachinePrecision] / b2), $MachinePrecision], If[LessEqual[t$95$0, -2.5081840773185255e-287], t$95$0, If[LessEqual[t$95$0, 0.0], t$95$1, If[LessEqual[t$95$0, 3.9722919166057204e+277], 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{a2}{b1} \cdot \frac{a1}{b2}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{a1 \cdot \frac{a2}{b1}}{b2}\\
\mathbf{elif}\;t_0 \leq -2.5081840773185255 \cdot 10^{-287}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 3.9722919166057204 \cdot 10^{+277}:\\
\;\;\;\;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.2 |
|---|---|
| Target | 11.0 |
| Herbie | 2.8 |
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0Initial program 64.0
Applied associate-/l*_binary6430.1
Simplified16.5
Applied associate-/r/_binary6415.7
Applied associate-/r*_binary6419.5
Simplified19.7
if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -2.5081840773185255e-287 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 3.97229191660572042e277Initial program 0.8
if -2.5081840773185255e-287 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0 or 3.97229191660572042e277 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 21.5
Applied associate-/l*_binary6414.2
Simplified6.5
Applied associate-/r/_binary646.5
Applied *-un-lft-identity_binary646.5
Applied times-frac_binary644.4
Simplified4.2
Applied *-commutative_binary644.2
Final simplification2.8
herbie shell --seed 2022137
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))