
(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
double code(double a1, double a2, double b1, double b2) {
return (a1 * a2) / (b1 * b2);
}
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
public static double code(double a1, double a2, double b1, double b2) {
return (a1 * a2) / (b1 * b2);
}
def code(a1, a2, b1, b2): return (a1 * a2) / (b1 * b2)
function code(a1, a2, b1, b2) return Float64(Float64(a1 * a2) / Float64(b1 * b2)) end
function tmp = code(a1, a2, b1, b2) tmp = (a1 * a2) / (b1 * b2); end
code[a1_, a2_, b1_, b2_] := N[(N[(a1 * a2), $MachinePrecision] / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a1 \cdot a2}{b1 \cdot b2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
double code(double a1, double a2, double b1, double b2) {
return (a1 * a2) / (b1 * b2);
}
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
public static double code(double a1, double a2, double b1, double b2) {
return (a1 * a2) / (b1 * b2);
}
def code(a1, a2, b1, b2): return (a1 * a2) / (b1 * b2)
function code(a1, a2, b1, b2) return Float64(Float64(a1 * a2) / Float64(b1 * b2)) end
function tmp = code(a1, a2, b1, b2) tmp = (a1 * a2) / (b1 * b2); end
code[a1_, a2_, b1_, b2_] := N[(N[(a1 * a2), $MachinePrecision] / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a1 \cdot a2}{b1 \cdot b2}
\end{array}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
(FPCore (a1 a2 b1 b2)
:precision binary64
(let* ((t_0 (/ (* a2 a1) (* b1 b2))) (t_1 (* (/ a2 b1) (/ a1 b2))))
(if (<= t_0 (- INFINITY))
t_1
(if (<= t_0 -1e-315)
t_0
(if (<= t_0 0.0)
(* a1 (/ (/ a2 b2) b1))
(if (<= t_0 5e+303) t_0 t_1))))))assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
double t_0 = (a2 * a1) / (b1 * b2);
double t_1 = (a2 / b1) * (a1 / b2);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_0 <= -1e-315) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = a1 * ((a2 / b2) / b1);
} else if (t_0 <= 5e+303) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
double t_0 = (a2 * a1) / (b1 * b2);
double t_1 = (a2 / b1) * (a1 / b2);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_0 <= -1e-315) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = a1 * ((a2 / b2) / b1);
} else if (t_0 <= 5e+303) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
[a1, a2] = sort([a1, a2]) [b1, b2] = sort([b1, b2]) def code(a1, a2, b1, b2): t_0 = (a2 * a1) / (b1 * b2) t_1 = (a2 / b1) * (a1 / b2) tmp = 0 if t_0 <= -math.inf: tmp = t_1 elif t_0 <= -1e-315: tmp = t_0 elif t_0 <= 0.0: tmp = a1 * ((a2 / b2) / b1) elif t_0 <= 5e+303: tmp = t_0 else: tmp = t_1 return tmp
a1, a2 = sort([a1, a2]) b1, b2 = sort([b1, b2]) function code(a1, a2, b1, b2) t_0 = Float64(Float64(a2 * a1) / Float64(b1 * b2)) t_1 = Float64(Float64(a2 / b1) * Float64(a1 / b2)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = t_1; elseif (t_0 <= -1e-315) tmp = t_0; elseif (t_0 <= 0.0) tmp = Float64(a1 * Float64(Float64(a2 / b2) / b1)); elseif (t_0 <= 5e+303) tmp = t_0; else tmp = t_1; end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp_2 = code(a1, a2, b1, b2)
t_0 = (a2 * a1) / (b1 * b2);
t_1 = (a2 / b1) * (a1 / b2);
tmp = 0.0;
if (t_0 <= -Inf)
tmp = t_1;
elseif (t_0 <= -1e-315)
tmp = t_0;
elseif (t_0 <= 0.0)
tmp = a1 * ((a2 / b2) / b1);
elseif (t_0 <= 5e+303)
tmp = t_0;
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
code[a1_, a2_, b1_, b2_] := Block[{t$95$0 = N[(N[(a2 * a1), $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)], t$95$1, If[LessEqual[t$95$0, -1e-315], t$95$0, If[LessEqual[t$95$0, 0.0], N[(a1 * N[(N[(a2 / b2), $MachinePrecision] / b1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+303], t$95$0, t$95$1]]]]]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
t_0 := \frac{a2 \cdot a1}{b1 \cdot b2}\\
t_1 := \frac{a2}{b1} \cdot \frac{a1}{b2}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq -1 \cdot 10^{-315}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+303}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0 or 4.9999999999999997e303 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 75.0%
*-commutative75.0%
times-frac96.2%
Applied egg-rr96.2%
if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -9.999999985e-316 or -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 4.9999999999999997e303Initial program 99.4%
if -9.999999985e-316 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0Initial program 69.0%
times-frac94.9%
associate-*l/90.3%
associate-*r/93.2%
Simplified93.2%
Final simplification96.9%
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
(FPCore (a1 a2 b1 b2)
:precision binary64
(if (<= (* b1 b2) -5e+214)
(/ (/ (* a2 (/ a1 b1)) (sqrt b2)) (sqrt b2))
(if (or (<= (* b1 b2) -5e-308) (not (<= (* b1 b2) 5e-171)))
(* a1 (/ a2 (* b1 b2)))
(* (/ a2 b1) (/ a1 b2)))))assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
double tmp;
if ((b1 * b2) <= -5e+214) {
tmp = ((a2 * (a1 / b1)) / sqrt(b2)) / sqrt(b2);
} else if (((b1 * b2) <= -5e-308) || !((b1 * b2) <= 5e-171)) {
tmp = a1 * (a2 / (b1 * b2));
} else {
tmp = (a2 / b1) * (a1 / b2);
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this 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) :: tmp
if ((b1 * b2) <= (-5d+214)) then
tmp = ((a2 * (a1 / b1)) / sqrt(b2)) / sqrt(b2)
else if (((b1 * b2) <= (-5d-308)) .or. (.not. ((b1 * b2) <= 5d-171))) then
tmp = a1 * (a2 / (b1 * b2))
else
tmp = (a2 / b1) * (a1 / b2)
end if
code = tmp
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
double tmp;
if ((b1 * b2) <= -5e+214) {
tmp = ((a2 * (a1 / b1)) / Math.sqrt(b2)) / Math.sqrt(b2);
} else if (((b1 * b2) <= -5e-308) || !((b1 * b2) <= 5e-171)) {
tmp = a1 * (a2 / (b1 * b2));
} else {
tmp = (a2 / b1) * (a1 / b2);
}
return tmp;
}
[a1, a2] = sort([a1, a2]) [b1, b2] = sort([b1, b2]) def code(a1, a2, b1, b2): tmp = 0 if (b1 * b2) <= -5e+214: tmp = ((a2 * (a1 / b1)) / math.sqrt(b2)) / math.sqrt(b2) elif ((b1 * b2) <= -5e-308) or not ((b1 * b2) <= 5e-171): tmp = a1 * (a2 / (b1 * b2)) else: tmp = (a2 / b1) * (a1 / b2) return tmp
a1, a2 = sort([a1, a2]) b1, b2 = sort([b1, b2]) function code(a1, a2, b1, b2) tmp = 0.0 if (Float64(b1 * b2) <= -5e+214) tmp = Float64(Float64(Float64(a2 * Float64(a1 / b1)) / sqrt(b2)) / sqrt(b2)); elseif ((Float64(b1 * b2) <= -5e-308) || !(Float64(b1 * b2) <= 5e-171)) tmp = Float64(a1 * Float64(a2 / Float64(b1 * b2))); else tmp = Float64(Float64(a2 / b1) * Float64(a1 / b2)); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp_2 = code(a1, a2, b1, b2)
tmp = 0.0;
if ((b1 * b2) <= -5e+214)
tmp = ((a2 * (a1 / b1)) / sqrt(b2)) / sqrt(b2);
elseif (((b1 * b2) <= -5e-308) || ~(((b1 * b2) <= 5e-171)))
tmp = a1 * (a2 / (b1 * b2));
else
tmp = (a2 / b1) * (a1 / b2);
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. NOTE: b1 and b2 should be sorted in increasing order before calling this function. code[a1_, a2_, b1_, b2_] := If[LessEqual[N[(b1 * b2), $MachinePrecision], -5e+214], N[(N[(N[(a2 * N[(a1 / b1), $MachinePrecision]), $MachinePrecision] / N[Sqrt[b2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[b2], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(b1 * b2), $MachinePrecision], -5e-308], N[Not[LessEqual[N[(b1 * b2), $MachinePrecision], 5e-171]], $MachinePrecision]], N[(a1 * N[(a2 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a2 / b1), $MachinePrecision] * N[(a1 / b2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \leq -5 \cdot 10^{+214}:\\
\;\;\;\;\frac{\frac{a2 \cdot \frac{a1}{b1}}{\sqrt{b2}}}{\sqrt{b2}}\\
\mathbf{elif}\;b1 \cdot b2 \leq -5 \cdot 10^{-308} \lor \neg \left(b1 \cdot b2 \leq 5 \cdot 10^{-171}\right):\\
\;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\
\mathbf{else}:\\
\;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\
\end{array}
\end{array}
if (*.f64 b1 b2) < -4.99999999999999953e214Initial program 64.9%
times-frac81.0%
associate-*l/92.9%
associate-*r/83.8%
Simplified83.8%
associate-/l/65.2%
associate-*r/64.9%
associate-/r*92.5%
add-sqr-sqrt55.4%
associate-/r*55.4%
associate-*l/50.2%
*-commutative50.2%
Applied egg-rr50.2%
if -4.99999999999999953e214 < (*.f64 b1 b2) < -4.99999999999999955e-308 or 4.99999999999999992e-171 < (*.f64 b1 b2) Initial program 89.6%
*-commutative89.6%
associate-*l/96.8%
*-commutative96.8%
Applied egg-rr96.8%
if -4.99999999999999955e-308 < (*.f64 b1 b2) < 4.99999999999999992e-171Initial program 76.2%
*-commutative76.2%
times-frac92.1%
Applied egg-rr92.1%
Final simplification91.0%
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
(FPCore (a1 a2 b1 b2)
:precision binary64
(if (<= (* b1 b2) -1e+272)
(/ (/ a1 b1) (/ b2 a2))
(if (or (<= (* b1 b2) -5e-308) (not (<= (* b1 b2) 5e-171)))
(* a1 (/ a2 (* b1 b2)))
(* (/ a2 b1) (/ a1 b2)))))assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
double tmp;
if ((b1 * b2) <= -1e+272) {
tmp = (a1 / b1) / (b2 / a2);
} else if (((b1 * b2) <= -5e-308) || !((b1 * b2) <= 5e-171)) {
tmp = a1 * (a2 / (b1 * b2));
} else {
tmp = (a2 / b1) * (a1 / b2);
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this 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) :: tmp
if ((b1 * b2) <= (-1d+272)) then
tmp = (a1 / b1) / (b2 / a2)
else if (((b1 * b2) <= (-5d-308)) .or. (.not. ((b1 * b2) <= 5d-171))) then
tmp = a1 * (a2 / (b1 * b2))
else
tmp = (a2 / b1) * (a1 / b2)
end if
code = tmp
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
double tmp;
if ((b1 * b2) <= -1e+272) {
tmp = (a1 / b1) / (b2 / a2);
} else if (((b1 * b2) <= -5e-308) || !((b1 * b2) <= 5e-171)) {
tmp = a1 * (a2 / (b1 * b2));
} else {
tmp = (a2 / b1) * (a1 / b2);
}
return tmp;
}
[a1, a2] = sort([a1, a2]) [b1, b2] = sort([b1, b2]) def code(a1, a2, b1, b2): tmp = 0 if (b1 * b2) <= -1e+272: tmp = (a1 / b1) / (b2 / a2) elif ((b1 * b2) <= -5e-308) or not ((b1 * b2) <= 5e-171): tmp = a1 * (a2 / (b1 * b2)) else: tmp = (a2 / b1) * (a1 / b2) return tmp
a1, a2 = sort([a1, a2]) b1, b2 = sort([b1, b2]) function code(a1, a2, b1, b2) tmp = 0.0 if (Float64(b1 * b2) <= -1e+272) tmp = Float64(Float64(a1 / b1) / Float64(b2 / a2)); elseif ((Float64(b1 * b2) <= -5e-308) || !(Float64(b1 * b2) <= 5e-171)) tmp = Float64(a1 * Float64(a2 / Float64(b1 * b2))); else tmp = Float64(Float64(a2 / b1) * Float64(a1 / b2)); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp_2 = code(a1, a2, b1, b2)
tmp = 0.0;
if ((b1 * b2) <= -1e+272)
tmp = (a1 / b1) / (b2 / a2);
elseif (((b1 * b2) <= -5e-308) || ~(((b1 * b2) <= 5e-171)))
tmp = a1 * (a2 / (b1 * b2));
else
tmp = (a2 / b1) * (a1 / b2);
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. NOTE: b1 and b2 should be sorted in increasing order before calling this function. code[a1_, a2_, b1_, b2_] := If[LessEqual[N[(b1 * b2), $MachinePrecision], -1e+272], N[(N[(a1 / b1), $MachinePrecision] / N[(b2 / a2), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(b1 * b2), $MachinePrecision], -5e-308], N[Not[LessEqual[N[(b1 * b2), $MachinePrecision], 5e-171]], $MachinePrecision]], N[(a1 * N[(a2 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a2 / b1), $MachinePrecision] * N[(a1 / b2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \leq -1 \cdot 10^{+272}:\\
\;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\
\mathbf{elif}\;b1 \cdot b2 \leq -5 \cdot 10^{-308} \lor \neg \left(b1 \cdot b2 \leq 5 \cdot 10^{-171}\right):\\
\;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\
\mathbf{else}:\\
\;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\
\end{array}
\end{array}
if (*.f64 b1 b2) < -1.0000000000000001e272Initial program 54.9%
times-frac84.2%
associate-*l/95.3%
associate-*r/83.6%
Simplified83.6%
associate-*r/95.3%
associate-*l/84.2%
clear-num84.2%
un-div-inv84.3%
Applied egg-rr84.3%
if -1.0000000000000001e272 < (*.f64 b1 b2) < -4.99999999999999955e-308 or 4.99999999999999992e-171 < (*.f64 b1 b2) Initial program 89.9%
*-commutative89.9%
associate-*l/96.4%
*-commutative96.4%
Applied egg-rr96.4%
if -4.99999999999999955e-308 < (*.f64 b1 b2) < 4.99999999999999992e-171Initial program 76.2%
*-commutative76.2%
times-frac92.1%
Applied egg-rr92.1%
Final simplification94.6%
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
(FPCore (a1 a2 b1 b2)
:precision binary64
(if (<= b1 -2.7e+256)
(* a2 (/ a1 (* b1 b2)))
(if (or (<= b1 -1.45e+63) (not (<= b1 1.6e-253)))
(* a1 (/ (/ a2 b2) b1))
(* (/ a2 b1) (/ a1 b2)))))assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
double tmp;
if (b1 <= -2.7e+256) {
tmp = a2 * (a1 / (b1 * b2));
} else if ((b1 <= -1.45e+63) || !(b1 <= 1.6e-253)) {
tmp = a1 * ((a2 / b2) / b1);
} else {
tmp = (a2 / b1) * (a1 / b2);
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this 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) :: tmp
if (b1 <= (-2.7d+256)) then
tmp = a2 * (a1 / (b1 * b2))
else if ((b1 <= (-1.45d+63)) .or. (.not. (b1 <= 1.6d-253))) then
tmp = a1 * ((a2 / b2) / b1)
else
tmp = (a2 / b1) * (a1 / b2)
end if
code = tmp
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
double tmp;
if (b1 <= -2.7e+256) {
tmp = a2 * (a1 / (b1 * b2));
} else if ((b1 <= -1.45e+63) || !(b1 <= 1.6e-253)) {
tmp = a1 * ((a2 / b2) / b1);
} else {
tmp = (a2 / b1) * (a1 / b2);
}
return tmp;
}
[a1, a2] = sort([a1, a2]) [b1, b2] = sort([b1, b2]) def code(a1, a2, b1, b2): tmp = 0 if b1 <= -2.7e+256: tmp = a2 * (a1 / (b1 * b2)) elif (b1 <= -1.45e+63) or not (b1 <= 1.6e-253): tmp = a1 * ((a2 / b2) / b1) else: tmp = (a2 / b1) * (a1 / b2) return tmp
a1, a2 = sort([a1, a2]) b1, b2 = sort([b1, b2]) function code(a1, a2, b1, b2) tmp = 0.0 if (b1 <= -2.7e+256) tmp = Float64(a2 * Float64(a1 / Float64(b1 * b2))); elseif ((b1 <= -1.45e+63) || !(b1 <= 1.6e-253)) tmp = Float64(a1 * Float64(Float64(a2 / b2) / b1)); else tmp = Float64(Float64(a2 / b1) * Float64(a1 / b2)); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp_2 = code(a1, a2, b1, b2)
tmp = 0.0;
if (b1 <= -2.7e+256)
tmp = a2 * (a1 / (b1 * b2));
elseif ((b1 <= -1.45e+63) || ~((b1 <= 1.6e-253)))
tmp = a1 * ((a2 / b2) / b1);
else
tmp = (a2 / b1) * (a1 / b2);
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. NOTE: b1 and b2 should be sorted in increasing order before calling this function. code[a1_, a2_, b1_, b2_] := If[LessEqual[b1, -2.7e+256], N[(a2 * N[(a1 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[b1, -1.45e+63], N[Not[LessEqual[b1, 1.6e-253]], $MachinePrecision]], N[(a1 * N[(N[(a2 / b2), $MachinePrecision] / b1), $MachinePrecision]), $MachinePrecision], N[(N[(a2 / b1), $MachinePrecision] * N[(a1 / b2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
\mathbf{if}\;b1 \leq -2.7 \cdot 10^{+256}:\\
\;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\
\mathbf{elif}\;b1 \leq -1.45 \cdot 10^{+63} \lor \neg \left(b1 \leq 1.6 \cdot 10^{-253}\right):\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\
\mathbf{else}:\\
\;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\
\end{array}
\end{array}
if b1 < -2.69999999999999995e256Initial program 83.9%
associate-/l*99.2%
associate-/r/84.3%
*-commutative84.3%
Applied egg-rr84.3%
if -2.69999999999999995e256 < b1 < -1.45e63 or 1.5999999999999999e-253 < b1 Initial program 85.5%
times-frac85.1%
associate-*l/88.2%
associate-*r/89.2%
Simplified89.2%
if -1.45e63 < b1 < 1.5999999999999999e-253Initial program 82.0%
*-commutative82.0%
times-frac91.6%
Applied egg-rr91.6%
Final simplification89.8%
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
(FPCore (a1 a2 b1 b2)
:precision binary64
(if (<= b1 -4e+256)
(* a2 (/ a1 (* b1 b2)))
(if (<= b1 -5e+60)
(* a1 (/ (/ a2 b2) b1))
(if (<= b1 -1.52e-290) (* (/ a2 b1) (/ a1 b2)) (* a1 (/ a2 (* b1 b2)))))))assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
double tmp;
if (b1 <= -4e+256) {
tmp = a2 * (a1 / (b1 * b2));
} else if (b1 <= -5e+60) {
tmp = a1 * ((a2 / b2) / b1);
} else if (b1 <= -1.52e-290) {
tmp = (a2 / b1) * (a1 / b2);
} else {
tmp = a1 * (a2 / (b1 * b2));
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this 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) :: tmp
if (b1 <= (-4d+256)) then
tmp = a2 * (a1 / (b1 * b2))
else if (b1 <= (-5d+60)) then
tmp = a1 * ((a2 / b2) / b1)
else if (b1 <= (-1.52d-290)) then
tmp = (a2 / b1) * (a1 / b2)
else
tmp = a1 * (a2 / (b1 * b2))
end if
code = tmp
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
double tmp;
if (b1 <= -4e+256) {
tmp = a2 * (a1 / (b1 * b2));
} else if (b1 <= -5e+60) {
tmp = a1 * ((a2 / b2) / b1);
} else if (b1 <= -1.52e-290) {
tmp = (a2 / b1) * (a1 / b2);
} else {
tmp = a1 * (a2 / (b1 * b2));
}
return tmp;
}
[a1, a2] = sort([a1, a2]) [b1, b2] = sort([b1, b2]) def code(a1, a2, b1, b2): tmp = 0 if b1 <= -4e+256: tmp = a2 * (a1 / (b1 * b2)) elif b1 <= -5e+60: tmp = a1 * ((a2 / b2) / b1) elif b1 <= -1.52e-290: tmp = (a2 / b1) * (a1 / b2) else: tmp = a1 * (a2 / (b1 * b2)) return tmp
a1, a2 = sort([a1, a2]) b1, b2 = sort([b1, b2]) function code(a1, a2, b1, b2) tmp = 0.0 if (b1 <= -4e+256) tmp = Float64(a2 * Float64(a1 / Float64(b1 * b2))); elseif (b1 <= -5e+60) tmp = Float64(a1 * Float64(Float64(a2 / b2) / b1)); elseif (b1 <= -1.52e-290) tmp = Float64(Float64(a2 / b1) * Float64(a1 / b2)); else tmp = Float64(a1 * Float64(a2 / Float64(b1 * b2))); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp_2 = code(a1, a2, b1, b2)
tmp = 0.0;
if (b1 <= -4e+256)
tmp = a2 * (a1 / (b1 * b2));
elseif (b1 <= -5e+60)
tmp = a1 * ((a2 / b2) / b1);
elseif (b1 <= -1.52e-290)
tmp = (a2 / b1) * (a1 / b2);
else
tmp = a1 * (a2 / (b1 * b2));
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. NOTE: b1 and b2 should be sorted in increasing order before calling this function. code[a1_, a2_, b1_, b2_] := If[LessEqual[b1, -4e+256], N[(a2 * N[(a1 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b1, -5e+60], N[(a1 * N[(N[(a2 / b2), $MachinePrecision] / b1), $MachinePrecision]), $MachinePrecision], If[LessEqual[b1, -1.52e-290], N[(N[(a2 / b1), $MachinePrecision] * N[(a1 / b2), $MachinePrecision]), $MachinePrecision], N[(a1 * N[(a2 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
\mathbf{if}\;b1 \leq -4 \cdot 10^{+256}:\\
\;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\
\mathbf{elif}\;b1 \leq -5 \cdot 10^{+60}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\
\mathbf{elif}\;b1 \leq -1.52 \cdot 10^{-290}:\\
\;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\
\mathbf{else}:\\
\;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\
\end{array}
\end{array}
if b1 < -4.0000000000000001e256Initial program 83.9%
associate-/l*99.2%
associate-/r/84.3%
*-commutative84.3%
Applied egg-rr84.3%
if -4.0000000000000001e256 < b1 < -4.99999999999999975e60Initial program 80.1%
times-frac78.6%
associate-*l/83.8%
associate-*r/82.5%
Simplified82.5%
if -4.99999999999999975e60 < b1 < -1.5199999999999999e-290Initial program 82.7%
*-commutative82.7%
times-frac91.9%
Applied egg-rr91.9%
if -1.5199999999999999e-290 < b1 Initial program 86.6%
*-commutative86.6%
associate-*l/91.6%
*-commutative91.6%
Applied egg-rr91.6%
Final simplification89.8%
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
(FPCore (a1 a2 b1 b2)
:precision binary64
(if (<= b1 -9.4e+257)
(* a2 (/ a1 (* b1 b2)))
(if (<= b1 -1.28e+51)
(* a1 (/ (/ a2 b2) b1))
(if (<= b1 -1.15e-159) (/ a2 (* b1 (/ b2 a1))) (* a1 (/ a2 (* b1 b2)))))))assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
double tmp;
if (b1 <= -9.4e+257) {
tmp = a2 * (a1 / (b1 * b2));
} else if (b1 <= -1.28e+51) {
tmp = a1 * ((a2 / b2) / b1);
} else if (b1 <= -1.15e-159) {
tmp = a2 / (b1 * (b2 / a1));
} else {
tmp = a1 * (a2 / (b1 * b2));
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this 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) :: tmp
if (b1 <= (-9.4d+257)) then
tmp = a2 * (a1 / (b1 * b2))
else if (b1 <= (-1.28d+51)) then
tmp = a1 * ((a2 / b2) / b1)
else if (b1 <= (-1.15d-159)) then
tmp = a2 / (b1 * (b2 / a1))
else
tmp = a1 * (a2 / (b1 * b2))
end if
code = tmp
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
double tmp;
if (b1 <= -9.4e+257) {
tmp = a2 * (a1 / (b1 * b2));
} else if (b1 <= -1.28e+51) {
tmp = a1 * ((a2 / b2) / b1);
} else if (b1 <= -1.15e-159) {
tmp = a2 / (b1 * (b2 / a1));
} else {
tmp = a1 * (a2 / (b1 * b2));
}
return tmp;
}
[a1, a2] = sort([a1, a2]) [b1, b2] = sort([b1, b2]) def code(a1, a2, b1, b2): tmp = 0 if b1 <= -9.4e+257: tmp = a2 * (a1 / (b1 * b2)) elif b1 <= -1.28e+51: tmp = a1 * ((a2 / b2) / b1) elif b1 <= -1.15e-159: tmp = a2 / (b1 * (b2 / a1)) else: tmp = a1 * (a2 / (b1 * b2)) return tmp
a1, a2 = sort([a1, a2]) b1, b2 = sort([b1, b2]) function code(a1, a2, b1, b2) tmp = 0.0 if (b1 <= -9.4e+257) tmp = Float64(a2 * Float64(a1 / Float64(b1 * b2))); elseif (b1 <= -1.28e+51) tmp = Float64(a1 * Float64(Float64(a2 / b2) / b1)); elseif (b1 <= -1.15e-159) tmp = Float64(a2 / Float64(b1 * Float64(b2 / a1))); else tmp = Float64(a1 * Float64(a2 / Float64(b1 * b2))); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp_2 = code(a1, a2, b1, b2)
tmp = 0.0;
if (b1 <= -9.4e+257)
tmp = a2 * (a1 / (b1 * b2));
elseif (b1 <= -1.28e+51)
tmp = a1 * ((a2 / b2) / b1);
elseif (b1 <= -1.15e-159)
tmp = a2 / (b1 * (b2 / a1));
else
tmp = a1 * (a2 / (b1 * b2));
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. NOTE: b1 and b2 should be sorted in increasing order before calling this function. code[a1_, a2_, b1_, b2_] := If[LessEqual[b1, -9.4e+257], N[(a2 * N[(a1 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b1, -1.28e+51], N[(a1 * N[(N[(a2 / b2), $MachinePrecision] / b1), $MachinePrecision]), $MachinePrecision], If[LessEqual[b1, -1.15e-159], N[(a2 / N[(b1 * N[(b2 / a1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a1 * N[(a2 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
\mathbf{if}\;b1 \leq -9.4 \cdot 10^{+257}:\\
\;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\
\mathbf{elif}\;b1 \leq -1.28 \cdot 10^{+51}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\
\mathbf{elif}\;b1 \leq -1.15 \cdot 10^{-159}:\\
\;\;\;\;\frac{a2}{b1 \cdot \frac{b2}{a1}}\\
\mathbf{else}:\\
\;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\
\end{array}
\end{array}
if b1 < -9.4e257Initial program 83.9%
associate-/l*99.2%
associate-/r/84.3%
*-commutative84.3%
Applied egg-rr84.3%
if -9.4e257 < b1 < -1.27999999999999993e51Initial program 80.4%
times-frac79.1%
associate-*l/84.1%
associate-*r/82.8%
Simplified82.8%
if -1.27999999999999993e51 < b1 < -1.14999999999999989e-159Initial program 78.7%
*-commutative78.7%
associate-*l/93.1%
*-commutative93.1%
Applied egg-rr93.1%
associate-*l/78.7%
*-commutative78.7%
frac-times97.0%
clear-num97.1%
frac-times96.1%
*-commutative96.1%
*-un-lft-identity96.1%
Applied egg-rr96.1%
if -1.14999999999999989e-159 < b1 Initial program 86.8%
*-commutative86.8%
associate-*l/91.6%
*-commutative91.6%
Applied egg-rr91.6%
Final simplification90.4%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. NOTE: b1 and b2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 b1 b2) :precision binary64 (if (<= b2 2.2e-157) (* a2 (/ (/ a1 b1) b2)) (* a1 (/ (/ a2 b2) b1))))
assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
double tmp;
if (b2 <= 2.2e-157) {
tmp = a2 * ((a1 / b1) / b2);
} else {
tmp = a1 * ((a2 / b2) / b1);
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this 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) :: tmp
if (b2 <= 2.2d-157) then
tmp = a2 * ((a1 / b1) / b2)
else
tmp = a1 * ((a2 / b2) / b1)
end if
code = tmp
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
double tmp;
if (b2 <= 2.2e-157) {
tmp = a2 * ((a1 / b1) / b2);
} else {
tmp = a1 * ((a2 / b2) / b1);
}
return tmp;
}
[a1, a2] = sort([a1, a2]) [b1, b2] = sort([b1, b2]) def code(a1, a2, b1, b2): tmp = 0 if b2 <= 2.2e-157: tmp = a2 * ((a1 / b1) / b2) else: tmp = a1 * ((a2 / b2) / b1) return tmp
a1, a2 = sort([a1, a2]) b1, b2 = sort([b1, b2]) function code(a1, a2, b1, b2) tmp = 0.0 if (b2 <= 2.2e-157) tmp = Float64(a2 * Float64(Float64(a1 / b1) / b2)); else tmp = Float64(a1 * Float64(Float64(a2 / b2) / b1)); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp_2 = code(a1, a2, b1, b2)
tmp = 0.0;
if (b2 <= 2.2e-157)
tmp = a2 * ((a1 / b1) / b2);
else
tmp = a1 * ((a2 / b2) / b1);
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. NOTE: b1 and b2 should be sorted in increasing order before calling this function. code[a1_, a2_, b1_, b2_] := If[LessEqual[b2, 2.2e-157], N[(a2 * N[(N[(a1 / b1), $MachinePrecision] / b2), $MachinePrecision]), $MachinePrecision], N[(a1 * N[(N[(a2 / b2), $MachinePrecision] / b1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
\mathbf{if}\;b2 \leq 2.2 \cdot 10^{-157}:\\
\;\;\;\;a2 \cdot \frac{\frac{a1}{b1}}{b2}\\
\mathbf{else}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\
\end{array}
\end{array}
if b2 < 2.2000000000000001e-157Initial program 84.3%
times-frac84.9%
associate-*l/86.0%
associate-*r/89.0%
Simplified89.0%
Taylor expanded in a1 around 0 84.3%
times-frac84.9%
*-commutative84.9%
associate-*l/81.6%
associate-*r/85.4%
Simplified85.4%
if 2.2000000000000001e-157 < b2 Initial program 84.6%
times-frac88.1%
associate-*l/90.6%
associate-*r/91.7%
Simplified91.7%
Final simplification87.9%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. NOTE: b1 and b2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 b1 b2) :precision binary64 (if (<= b1 -4.8e+256) (* a2 (/ a1 (* b1 b2))) (* a1 (/ (/ a2 b2) b1))))
assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
double tmp;
if (b1 <= -4.8e+256) {
tmp = a2 * (a1 / (b1 * b2));
} else {
tmp = a1 * ((a2 / b2) / b1);
}
return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this 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) :: tmp
if (b1 <= (-4.8d+256)) then
tmp = a2 * (a1 / (b1 * b2))
else
tmp = a1 * ((a2 / b2) / b1)
end if
code = tmp
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
double tmp;
if (b1 <= -4.8e+256) {
tmp = a2 * (a1 / (b1 * b2));
} else {
tmp = a1 * ((a2 / b2) / b1);
}
return tmp;
}
[a1, a2] = sort([a1, a2]) [b1, b2] = sort([b1, b2]) def code(a1, a2, b1, b2): tmp = 0 if b1 <= -4.8e+256: tmp = a2 * (a1 / (b1 * b2)) else: tmp = a1 * ((a2 / b2) / b1) return tmp
a1, a2 = sort([a1, a2]) b1, b2 = sort([b1, b2]) function code(a1, a2, b1, b2) tmp = 0.0 if (b1 <= -4.8e+256) tmp = Float64(a2 * Float64(a1 / Float64(b1 * b2))); else tmp = Float64(a1 * Float64(Float64(a2 / b2) / b1)); end return tmp end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp_2 = code(a1, a2, b1, b2)
tmp = 0.0;
if (b1 <= -4.8e+256)
tmp = a2 * (a1 / (b1 * b2));
else
tmp = a1 * ((a2 / b2) / b1);
end
tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. NOTE: b1 and b2 should be sorted in increasing order before calling this function. code[a1_, a2_, b1_, b2_] := If[LessEqual[b1, -4.8e+256], N[(a2 * N[(a1 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a1 * N[(N[(a2 / b2), $MachinePrecision] / b1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
\mathbf{if}\;b1 \leq -4.8 \cdot 10^{+256}:\\
\;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\
\mathbf{else}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\
\end{array}
\end{array}
if b1 < -4.80000000000000028e256Initial program 83.9%
associate-/l*99.2%
associate-/r/84.3%
*-commutative84.3%
Applied egg-rr84.3%
if -4.80000000000000028e256 < b1 Initial program 84.4%
times-frac86.6%
associate-*l/87.9%
associate-*r/89.8%
Simplified89.8%
Final simplification89.7%
NOTE: a1 and a2 should be sorted in increasing order before calling this function. NOTE: b1 and b2 should be sorted in increasing order before calling this function. (FPCore (a1 a2 b1 b2) :precision binary64 (* a1 (/ (/ a2 b2) b1)))
assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
return a1 * ((a2 / b2) / b1);
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this 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
code = a1 * ((a2 / b2) / b1)
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
return a1 * ((a2 / b2) / b1);
}
[a1, a2] = sort([a1, a2]) [b1, b2] = sort([b1, b2]) def code(a1, a2, b1, b2): return a1 * ((a2 / b2) / b1)
a1, a2 = sort([a1, a2]) b1, b2 = sort([b1, b2]) function code(a1, a2, b1, b2) return Float64(a1 * Float64(Float64(a2 / b2) / b1)) end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp = code(a1, a2, b1, b2)
tmp = a1 * ((a2 / b2) / b1);
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function. NOTE: b1 and b2 should be sorted in increasing order before calling this function. code[a1_, a2_, b1_, b2_] := N[(a1 * N[(N[(a2 / b2), $MachinePrecision] / b1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
a1 \cdot \frac{\frac{a2}{b2}}{b1}
\end{array}
Initial program 84.4%
times-frac86.2%
associate-*l/87.8%
associate-*r/90.1%
Simplified90.1%
Final simplification90.1%
(FPCore (a1 a2 b1 b2) :precision binary64 (* (/ a1 b1) (/ a2 b2)))
double code(double a1, double a2, double b1, double b2) {
return (a1 / b1) * (a2 / b2);
}
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 / b1) * (a2 / b2)
end function
public static double code(double a1, double a2, double b1, double b2) {
return (a1 / b1) * (a2 / b2);
}
def code(a1, a2, b1, b2): return (a1 / b1) * (a2 / b2)
function code(a1, a2, b1, b2) return Float64(Float64(a1 / b1) * Float64(a2 / b2)) end
function tmp = code(a1, a2, b1, b2) tmp = (a1 / b1) * (a2 / b2); end
code[a1_, a2_, b1_, b2_] := N[(N[(a1 / b1), $MachinePrecision] * N[(a2 / b2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a1}{b1} \cdot \frac{a2}{b2}
\end{array}
herbie shell --seed 2023307
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))