
(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 6 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 (/ (* a1 a2) (* b1 b2))) (t_1 (/ (/ a1 b1) (/ b2 a2))))
(if (<= t_0 (- INFINITY))
t_1
(if (<= t_0 -1e-229)
t_0
(if (<= t_0 5e-222)
t_1
(if (<= t_0 5e+292) t_0 (* (/ a2 b1) (/ a1 b2))))))))assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
double t_0 = (a1 * a2) / (b1 * b2);
double t_1 = (a1 / b1) / (b2 / a2);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_0 <= -1e-229) {
tmp = t_0;
} else if (t_0 <= 5e-222) {
tmp = t_1;
} else if (t_0 <= 5e+292) {
tmp = t_0;
} else {
tmp = (a2 / b1) * (a1 / b2);
}
return tmp;
}
assert a1 < a2;
assert 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) / (b2 / a2);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_0 <= -1e-229) {
tmp = t_0;
} else if (t_0 <= 5e-222) {
tmp = t_1;
} else if (t_0 <= 5e+292) {
tmp = t_0;
} else {
tmp = (a2 / b1) * (a1 / b2);
}
return tmp;
}
[a1, a2] = sort([a1, a2]) [b1, b2] = sort([b1, b2]) def code(a1, a2, b1, b2): t_0 = (a1 * a2) / (b1 * b2) t_1 = (a1 / b1) / (b2 / a2) tmp = 0 if t_0 <= -math.inf: tmp = t_1 elif t_0 <= -1e-229: tmp = t_0 elif t_0 <= 5e-222: tmp = t_1 elif t_0 <= 5e+292: tmp = t_0 else: tmp = (a2 / b1) * (a1 / b2) return tmp
a1, a2 = sort([a1, a2]) b1, b2 = sort([b1, b2]) function code(a1, a2, b1, b2) t_0 = Float64(Float64(a1 * a2) / Float64(b1 * b2)) t_1 = Float64(Float64(a1 / b1) / Float64(b2 / a2)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = t_1; elseif (t_0 <= -1e-229) tmp = t_0; elseif (t_0 <= 5e-222) tmp = t_1; elseif (t_0 <= 5e+292) tmp = t_0; 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)
t_0 = (a1 * a2) / (b1 * b2);
t_1 = (a1 / b1) / (b2 / a2);
tmp = 0.0;
if (t_0 <= -Inf)
tmp = t_1;
elseif (t_0 <= -1e-229)
tmp = t_0;
elseif (t_0 <= 5e-222)
tmp = t_1;
elseif (t_0 <= 5e+292)
tmp = t_0;
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_] := Block[{t$95$0 = N[(N[(a1 * a2), $MachinePrecision] / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a1 / b1), $MachinePrecision] / N[(b2 / a2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, -1e-229], t$95$0, If[LessEqual[t$95$0, 5e-222], t$95$1, If[LessEqual[t$95$0, 5e+292], t$95$0, 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}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
t_1 := \frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq -1 \cdot 10^{-229}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{-222}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+292}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\
\end{array}
\end{array}
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0 or -1.00000000000000007e-229 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 5.00000000000000008e-222Initial program 83.3%
times-frac98.5%
associate-*l/94.5%
associate-*r/96.0%
Simplified96.0%
associate-*r/94.5%
associate-*l/98.5%
clear-num98.5%
un-div-inv98.6%
Applied egg-rr98.6%
if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.00000000000000007e-229 or 5.00000000000000008e-222 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 4.9999999999999996e292Initial program 98.4%
if 4.9999999999999996e292 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 49.1%
times-frac95.4%
associate-*l/91.1%
associate-*r/84.3%
Simplified84.3%
Taylor expanded in a1 around 0 49.1%
*-commutative49.1%
times-frac95.4%
Simplified95.4%
Final simplification98.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
(let* ((t_0 (/ (* a1 a2) (* b1 b2))) (t_1 (* (/ a1 b1) (/ a2 b2))))
(if (<= t_0 (- INFINITY))
t_1
(if (<= t_0 -5e-270)
t_0
(if (<= t_0 5e-222)
t_1
(if (<= t_0 5e+292) t_0 (* (/ a2 b1) (/ a1 b2))))))))assert(a1 < a2);
assert(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 = t_1;
} else if (t_0 <= -5e-270) {
tmp = t_0;
} else if (t_0 <= 5e-222) {
tmp = t_1;
} else if (t_0 <= 5e+292) {
tmp = t_0;
} else {
tmp = (a2 / b1) * (a1 / b2);
}
return tmp;
}
assert a1 < a2;
assert 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 = t_1;
} else if (t_0 <= -5e-270) {
tmp = t_0;
} else if (t_0 <= 5e-222) {
tmp = t_1;
} else if (t_0 <= 5e+292) {
tmp = t_0;
} else {
tmp = (a2 / b1) * (a1 / b2);
}
return tmp;
}
[a1, a2] = sort([a1, a2]) [b1, b2] = sort([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 = t_1 elif t_0 <= -5e-270: tmp = t_0 elif t_0 <= 5e-222: tmp = t_1 elif t_0 <= 5e+292: tmp = t_0 else: tmp = (a2 / b1) * (a1 / b2) return tmp
a1, a2 = sort([a1, a2]) b1, b2 = sort([b1, b2]) 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 = t_1; elseif (t_0 <= -5e-270) tmp = t_0; elseif (t_0 <= 5e-222) tmp = t_1; elseif (t_0 <= 5e+292) tmp = t_0; 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)
t_0 = (a1 * a2) / (b1 * b2);
t_1 = (a1 / b1) * (a2 / b2);
tmp = 0.0;
if (t_0 <= -Inf)
tmp = t_1;
elseif (t_0 <= -5e-270)
tmp = t_0;
elseif (t_0 <= 5e-222)
tmp = t_1;
elseif (t_0 <= 5e+292)
tmp = t_0;
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_] := 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)], t$95$1, If[LessEqual[t$95$0, -5e-270], t$95$0, If[LessEqual[t$95$0, 5e-222], t$95$1, If[LessEqual[t$95$0, 5e+292], t$95$0, 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}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
t_1 := \frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq -5 \cdot 10^{-270}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{-222}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+292}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\
\end{array}
\end{array}
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0 or -4.9999999999999998e-270 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 5.00000000000000008e-222Initial program 83.1%
times-frac98.5%
Simplified98.5%
if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -4.9999999999999998e-270 or 5.00000000000000008e-222 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 4.9999999999999996e292Initial program 98.4%
if 4.9999999999999996e292 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 49.1%
times-frac95.4%
associate-*l/91.1%
associate-*r/84.3%
Simplified84.3%
Taylor expanded in a1 around 0 49.1%
*-commutative49.1%
times-frac95.4%
Simplified95.4%
Final simplification97.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 (<= a2 2.7e-221)
(* (/ a1 b1) (/ a2 b2))
(if (or (<= a2 2.9e-31) (not (<= a2 6.2e+155)))
(* (/ a2 b1) (/ a1 b2))
(/ a2 (* b2 (/ b1 a1))))))assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
double tmp;
if (a2 <= 2.7e-221) {
tmp = (a1 / b1) * (a2 / b2);
} else if ((a2 <= 2.9e-31) || !(a2 <= 6.2e+155)) {
tmp = (a2 / b1) * (a1 / b2);
} else {
tmp = a2 / (b2 * (b1 / a1));
}
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 (a2 <= 2.7d-221) then
tmp = (a1 / b1) * (a2 / b2)
else if ((a2 <= 2.9d-31) .or. (.not. (a2 <= 6.2d+155))) then
tmp = (a2 / b1) * (a1 / b2)
else
tmp = a2 / (b2 * (b1 / a1))
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 (a2 <= 2.7e-221) {
tmp = (a1 / b1) * (a2 / b2);
} else if ((a2 <= 2.9e-31) || !(a2 <= 6.2e+155)) {
tmp = (a2 / b1) * (a1 / b2);
} else {
tmp = a2 / (b2 * (b1 / a1));
}
return tmp;
}
[a1, a2] = sort([a1, a2]) [b1, b2] = sort([b1, b2]) def code(a1, a2, b1, b2): tmp = 0 if a2 <= 2.7e-221: tmp = (a1 / b1) * (a2 / b2) elif (a2 <= 2.9e-31) or not (a2 <= 6.2e+155): tmp = (a2 / b1) * (a1 / b2) else: tmp = a2 / (b2 * (b1 / a1)) return tmp
a1, a2 = sort([a1, a2]) b1, b2 = sort([b1, b2]) function code(a1, a2, b1, b2) tmp = 0.0 if (a2 <= 2.7e-221) tmp = Float64(Float64(a1 / b1) * Float64(a2 / b2)); elseif ((a2 <= 2.9e-31) || !(a2 <= 6.2e+155)) tmp = Float64(Float64(a2 / b1) * Float64(a1 / b2)); else tmp = Float64(a2 / Float64(b2 * Float64(b1 / a1))); 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 (a2 <= 2.7e-221)
tmp = (a1 / b1) * (a2 / b2);
elseif ((a2 <= 2.9e-31) || ~((a2 <= 6.2e+155)))
tmp = (a2 / b1) * (a1 / b2);
else
tmp = a2 / (b2 * (b1 / a1));
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[a2, 2.7e-221], N[(N[(a1 / b1), $MachinePrecision] * N[(a2 / b2), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[a2, 2.9e-31], N[Not[LessEqual[a2, 6.2e+155]], $MachinePrecision]], N[(N[(a2 / b1), $MachinePrecision] * N[(a1 / b2), $MachinePrecision]), $MachinePrecision], N[(a2 / N[(b2 * N[(b1 / a1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
\mathbf{if}\;a2 \leq 2.7 \cdot 10^{-221}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{elif}\;a2 \leq 2.9 \cdot 10^{-31} \lor \neg \left(a2 \leq 6.2 \cdot 10^{+155}\right):\\
\;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\
\mathbf{else}:\\
\;\;\;\;\frac{a2}{b2 \cdot \frac{b1}{a1}}\\
\end{array}
\end{array}
if a2 < 2.7e-221Initial program 86.3%
times-frac85.0%
Simplified85.0%
if 2.7e-221 < a2 < 2.9000000000000001e-31 or 6.19999999999999978e155 < a2 Initial program 79.5%
times-frac88.3%
associate-*l/88.9%
associate-*r/85.1%
Simplified85.1%
Taylor expanded in a1 around 0 79.5%
*-commutative79.5%
times-frac83.4%
Simplified83.4%
if 2.9000000000000001e-31 < a2 < 6.19999999999999978e155Initial program 90.2%
times-frac85.7%
associate-*l/86.0%
associate-*r/88.3%
Simplified88.3%
associate-*r/86.0%
associate-*l/85.7%
clear-num85.6%
frac-times90.3%
*-un-lft-identity90.3%
Applied egg-rr90.3%
Final simplification85.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 (<= a2 1.3e+198) (* (/ a1 b1) (/ a2 b2)) (* a1 (/ (/ a2 b2) b1))))
assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
double tmp;
if (a2 <= 1.3e+198) {
tmp = (a1 / b1) * (a2 / 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 (a2 <= 1.3d+198) then
tmp = (a1 / b1) * (a2 / 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 (a2 <= 1.3e+198) {
tmp = (a1 / b1) * (a2 / 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 a2 <= 1.3e+198: tmp = (a1 / b1) * (a2 / 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 (a2 <= 1.3e+198) tmp = Float64(Float64(a1 / b1) * Float64(a2 / 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 (a2 <= 1.3e+198)
tmp = (a1 / b1) * (a2 / 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[a2, 1.3e+198], N[(N[(a1 / b1), $MachinePrecision] * N[(a2 / 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}\;a2 \leq 1.3 \cdot 10^{+198}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{else}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\
\end{array}
\end{array}
if a2 < 1.2999999999999999e198Initial program 85.8%
times-frac86.0%
Simplified86.0%
if 1.2999999999999999e198 < a2 Initial program 77.6%
times-frac85.8%
associate-*l/90.6%
associate-*r/90.7%
Simplified90.7%
Final simplification86.3%
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 (<= a2 2.6e-221) (* (/ a1 b1) (/ a2 b2)) (* (/ a2 b1) (/ a1 b2))))
assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
double tmp;
if (a2 <= 2.6e-221) {
tmp = (a1 / b1) * (a2 / 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 (a2 <= 2.6d-221) then
tmp = (a1 / b1) * (a2 / 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 (a2 <= 2.6e-221) {
tmp = (a1 / b1) * (a2 / 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 a2 <= 2.6e-221: tmp = (a1 / b1) * (a2 / 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 (a2 <= 2.6e-221) tmp = Float64(Float64(a1 / b1) * Float64(a2 / 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 (a2 <= 2.6e-221)
tmp = (a1 / b1) * (a2 / 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[a2, 2.6e-221], N[(N[(a1 / b1), $MachinePrecision] * N[(a2 / b2), $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}\;a2 \leq 2.6 \cdot 10^{-221}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{else}:\\
\;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\
\end{array}
\end{array}
if a2 < 2.6000000000000002e-221Initial program 86.3%
times-frac85.0%
Simplified85.0%
if 2.6000000000000002e-221 < a2 Initial program 83.6%
times-frac87.3%
associate-*l/87.8%
associate-*r/86.3%
Simplified86.3%
Taylor expanded in a1 around 0 83.6%
*-commutative83.6%
times-frac84.6%
Simplified84.6%
Final simplification84.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 (* 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 85.2%
times-frac86.0%
associate-*l/85.1%
associate-*r/86.2%
Simplified86.2%
Final simplification86.2%
(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 2023314
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))