
(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 7 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}
b2\_m = (fabs.f64 b2)
b2\_s = (copysign.f64 #s(literal 1 binary64) b2)
b1\_m = (fabs.f64 b1)
b1\_s = (copysign.f64 #s(literal 1 binary64) b1)
a2\_m = (fabs.f64 a2)
a2\_s = (copysign.f64 #s(literal 1 binary64) a2)
a1\_m = (fabs.f64 a1)
a1\_s = (copysign.f64 #s(literal 1 binary64) a1)
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
(FPCore (a1_s a2_s b1_s b2_s a1_m a2_m b1_m b2_m)
:precision binary64
(*
a1_s
(*
a2_s
(*
b1_s
(*
b2_s
(if (<= (* b1_m b2_m) 5e-312)
(* (/ (/ a1_m b2_m) b1_m) a2_m)
(if (<= (* b1_m b2_m) 50000000000000.0)
(* (/ a1_m (* b1_m b2_m)) a2_m)
(* (/ (/ a2_m b2_m) b1_m) a1_m))))))))b2\_m = fabs(b2);
b2\_s = copysign(1.0, b2);
b1\_m = fabs(b1);
b1\_s = copysign(1.0, b1);
a2\_m = fabs(a2);
a2\_s = copysign(1.0, a2);
a1\_m = fabs(a1);
a1\_s = copysign(1.0, a1);
assert(a1_m < a2_m && a2_m < b1_m && b1_m < b2_m);
assert(a1_m < a2_m && a2_m < b1_m && b1_m < b2_m);
double code(double a1_s, double a2_s, double b1_s, double b2_s, double a1_m, double a2_m, double b1_m, double b2_m) {
double tmp;
if ((b1_m * b2_m) <= 5e-312) {
tmp = ((a1_m / b2_m) / b1_m) * a2_m;
} else if ((b1_m * b2_m) <= 50000000000000.0) {
tmp = (a1_m / (b1_m * b2_m)) * a2_m;
} else {
tmp = ((a2_m / b2_m) / b1_m) * a1_m;
}
return a1_s * (a2_s * (b1_s * (b2_s * tmp)));
}
b2\_m = abs(b2)
b2\_s = copysign(1.0d0, b2)
b1\_m = abs(b1)
b1\_s = copysign(1.0d0, b1)
a2\_m = abs(a2)
a2\_s = copysign(1.0d0, a2)
a1\_m = abs(a1)
a1\_s = copysign(1.0d0, a1)
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
real(8) function code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m)
real(8), intent (in) :: a1_s
real(8), intent (in) :: a2_s
real(8), intent (in) :: b1_s
real(8), intent (in) :: b2_s
real(8), intent (in) :: a1_m
real(8), intent (in) :: a2_m
real(8), intent (in) :: b1_m
real(8), intent (in) :: b2_m
real(8) :: tmp
if ((b1_m * b2_m) <= 5d-312) then
tmp = ((a1_m / b2_m) / b1_m) * a2_m
else if ((b1_m * b2_m) <= 50000000000000.0d0) then
tmp = (a1_m / (b1_m * b2_m)) * a2_m
else
tmp = ((a2_m / b2_m) / b1_m) * a1_m
end if
code = a1_s * (a2_s * (b1_s * (b2_s * tmp)))
end function
b2\_m = Math.abs(b2);
b2\_s = Math.copySign(1.0, b2);
b1\_m = Math.abs(b1);
b1\_s = Math.copySign(1.0, b1);
a2\_m = Math.abs(a2);
a2\_s = Math.copySign(1.0, a2);
a1\_m = Math.abs(a1);
a1\_s = Math.copySign(1.0, a1);
assert a1_m < a2_m && a2_m < b1_m && b1_m < b2_m;
assert a1_m < a2_m && a2_m < b1_m && b1_m < b2_m;
public static double code(double a1_s, double a2_s, double b1_s, double b2_s, double a1_m, double a2_m, double b1_m, double b2_m) {
double tmp;
if ((b1_m * b2_m) <= 5e-312) {
tmp = ((a1_m / b2_m) / b1_m) * a2_m;
} else if ((b1_m * b2_m) <= 50000000000000.0) {
tmp = (a1_m / (b1_m * b2_m)) * a2_m;
} else {
tmp = ((a2_m / b2_m) / b1_m) * a1_m;
}
return a1_s * (a2_s * (b1_s * (b2_s * tmp)));
}
b2\_m = math.fabs(b2) b2\_s = math.copysign(1.0, b2) b1\_m = math.fabs(b1) b1\_s = math.copysign(1.0, b1) a2\_m = math.fabs(a2) a2\_s = math.copysign(1.0, a2) a1\_m = math.fabs(a1) a1\_s = math.copysign(1.0, a1) [a1_m, a2_m, b1_m, b2_m] = sort([a1_m, a2_m, b1_m, b2_m]) [a1_m, a2_m, b1_m, b2_m] = sort([a1_m, a2_m, b1_m, b2_m]) def code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m): tmp = 0 if (b1_m * b2_m) <= 5e-312: tmp = ((a1_m / b2_m) / b1_m) * a2_m elif (b1_m * b2_m) <= 50000000000000.0: tmp = (a1_m / (b1_m * b2_m)) * a2_m else: tmp = ((a2_m / b2_m) / b1_m) * a1_m return a1_s * (a2_s * (b1_s * (b2_s * tmp)))
b2\_m = abs(b2) b2\_s = copysign(1.0, b2) b1\_m = abs(b1) b1\_s = copysign(1.0, b1) a2\_m = abs(a2) a2\_s = copysign(1.0, a2) a1\_m = abs(a1) a1\_s = copysign(1.0, a1) a1_m, a2_m, b1_m, b2_m = sort([a1_m, a2_m, b1_m, b2_m]) a1_m, a2_m, b1_m, b2_m = sort([a1_m, a2_m, b1_m, b2_m]) function code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m) tmp = 0.0 if (Float64(b1_m * b2_m) <= 5e-312) tmp = Float64(Float64(Float64(a1_m / b2_m) / b1_m) * a2_m); elseif (Float64(b1_m * b2_m) <= 50000000000000.0) tmp = Float64(Float64(a1_m / Float64(b1_m * b2_m)) * a2_m); else tmp = Float64(Float64(Float64(a2_m / b2_m) / b1_m) * a1_m); end return Float64(a1_s * Float64(a2_s * Float64(b1_s * Float64(b2_s * tmp)))) end
b2\_m = abs(b2);
b2\_s = sign(b2) * abs(1.0);
b1\_m = abs(b1);
b1\_s = sign(b1) * abs(1.0);
a2\_m = abs(a2);
a2\_s = sign(a2) * abs(1.0);
a1\_m = abs(a1);
a1\_s = sign(a1) * abs(1.0);
a1_m, a2_m, b1_m, b2_m = num2cell(sort([a1_m, a2_m, b1_m, b2_m])){:}
a1_m, a2_m, b1_m, b2_m = num2cell(sort([a1_m, a2_m, b1_m, b2_m])){:}
function tmp_2 = code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m)
tmp = 0.0;
if ((b1_m * b2_m) <= 5e-312)
tmp = ((a1_m / b2_m) / b1_m) * a2_m;
elseif ((b1_m * b2_m) <= 50000000000000.0)
tmp = (a1_m / (b1_m * b2_m)) * a2_m;
else
tmp = ((a2_m / b2_m) / b1_m) * a1_m;
end
tmp_2 = a1_s * (a2_s * (b1_s * (b2_s * tmp)));
end
b2\_m = N[Abs[b2], $MachinePrecision]
b2\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[b2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
b1\_m = N[Abs[b1], $MachinePrecision]
b1\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[b1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a2\_m = N[Abs[a2], $MachinePrecision]
a2\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a1\_m = N[Abs[a1], $MachinePrecision]
a1\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
code[a1$95$s_, a2$95$s_, b1$95$s_, b2$95$s_, a1$95$m_, a2$95$m_, b1$95$m_, b2$95$m_] := N[(a1$95$s * N[(a2$95$s * N[(b1$95$s * N[(b2$95$s * If[LessEqual[N[(b1$95$m * b2$95$m), $MachinePrecision], 5e-312], N[(N[(N[(a1$95$m / b2$95$m), $MachinePrecision] / b1$95$m), $MachinePrecision] * a2$95$m), $MachinePrecision], If[LessEqual[N[(b1$95$m * b2$95$m), $MachinePrecision], 50000000000000.0], N[(N[(a1$95$m / N[(b1$95$m * b2$95$m), $MachinePrecision]), $MachinePrecision] * a2$95$m), $MachinePrecision], N[(N[(N[(a2$95$m / b2$95$m), $MachinePrecision] / b1$95$m), $MachinePrecision] * a1$95$m), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b2\_m = \left|b2\right|
\\
b2\_s = \mathsf{copysign}\left(1, b2\right)
\\
b1\_m = \left|b1\right|
\\
b1\_s = \mathsf{copysign}\left(1, b1\right)
\\
a2\_m = \left|a2\right|
\\
a2\_s = \mathsf{copysign}\left(1, a2\right)
\\
a1\_m = \left|a1\right|
\\
a1\_s = \mathsf{copysign}\left(1, a1\right)
\\
[a1_m, a2_m, b1_m, b2_m] = \mathsf{sort}([a1_m, a2_m, b1_m, b2_m])\\\\
[a1_m, a2_m, b1_m, b2_m] = \mathsf{sort}([a1_m, a2_m, b1_m, b2_m])\\
\\
a1\_s \cdot \left(a2\_s \cdot \left(b1\_s \cdot \left(b2\_s \cdot \begin{array}{l}
\mathbf{if}\;b1\_m \cdot b2\_m \leq 5 \cdot 10^{-312}:\\
\;\;\;\;\frac{\frac{a1\_m}{b2\_m}}{b1\_m} \cdot a2\_m\\
\mathbf{elif}\;b1\_m \cdot b2\_m \leq 50000000000000:\\
\;\;\;\;\frac{a1\_m}{b1\_m \cdot b2\_m} \cdot a2\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a2\_m}{b2\_m}}{b1\_m} \cdot a1\_m\\
\end{array}\right)\right)\right)
\end{array}
if (*.f64 b1 b2) < 5.0000000000022e-312Initial program 86.3%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6489.5
Applied rewrites89.5%
if 5.0000000000022e-312 < (*.f64 b1 b2) < 5e13Initial program 94.9%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6486.9
Applied rewrites86.9%
lift-/.f64N/A
lift-/.f64N/A
remove-double-negN/A
associate-/r*N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
remove-double-neg93.4
Applied rewrites93.4%
if 5e13 < (*.f64 b1 b2) Initial program 86.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6484.7
Applied rewrites84.7%
b2\_m = (fabs.f64 b2)
b2\_s = (copysign.f64 #s(literal 1 binary64) b2)
b1\_m = (fabs.f64 b1)
b1\_s = (copysign.f64 #s(literal 1 binary64) b1)
a2\_m = (fabs.f64 a2)
a2\_s = (copysign.f64 #s(literal 1 binary64) a2)
a1\_m = (fabs.f64 a1)
a1\_s = (copysign.f64 #s(literal 1 binary64) a1)
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
(FPCore (a1_s a2_s b1_s b2_s a1_m a2_m b1_m b2_m)
:precision binary64
(let* ((t_0 (/ (* a1_m a2_m) (* b1_m b2_m))))
(*
a1_s
(*
a2_s
(*
b1_s
(*
b2_s
(if (<= t_0 0.0)
(* (/ a2_m b1_m) (/ a1_m b2_m))
(if (<= t_0 2e+232) t_0 (* (/ (/ a1_m b2_m) b1_m) a2_m)))))))))b2\_m = fabs(b2);
b2\_s = copysign(1.0, b2);
b1\_m = fabs(b1);
b1\_s = copysign(1.0, b1);
a2\_m = fabs(a2);
a2\_s = copysign(1.0, a2);
a1\_m = fabs(a1);
a1\_s = copysign(1.0, a1);
assert(a1_m < a2_m && a2_m < b1_m && b1_m < b2_m);
assert(a1_m < a2_m && a2_m < b1_m && b1_m < b2_m);
double code(double a1_s, double a2_s, double b1_s, double b2_s, double a1_m, double a2_m, double b1_m, double b2_m) {
double t_0 = (a1_m * a2_m) / (b1_m * b2_m);
double tmp;
if (t_0 <= 0.0) {
tmp = (a2_m / b1_m) * (a1_m / b2_m);
} else if (t_0 <= 2e+232) {
tmp = t_0;
} else {
tmp = ((a1_m / b2_m) / b1_m) * a2_m;
}
return a1_s * (a2_s * (b1_s * (b2_s * tmp)));
}
b2\_m = abs(b2)
b2\_s = copysign(1.0d0, b2)
b1\_m = abs(b1)
b1\_s = copysign(1.0d0, b1)
a2\_m = abs(a2)
a2\_s = copysign(1.0d0, a2)
a1\_m = abs(a1)
a1\_s = copysign(1.0d0, a1)
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
real(8) function code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m)
real(8), intent (in) :: a1_s
real(8), intent (in) :: a2_s
real(8), intent (in) :: b1_s
real(8), intent (in) :: b2_s
real(8), intent (in) :: a1_m
real(8), intent (in) :: a2_m
real(8), intent (in) :: b1_m
real(8), intent (in) :: b2_m
real(8) :: t_0
real(8) :: tmp
t_0 = (a1_m * a2_m) / (b1_m * b2_m)
if (t_0 <= 0.0d0) then
tmp = (a2_m / b1_m) * (a1_m / b2_m)
else if (t_0 <= 2d+232) then
tmp = t_0
else
tmp = ((a1_m / b2_m) / b1_m) * a2_m
end if
code = a1_s * (a2_s * (b1_s * (b2_s * tmp)))
end function
b2\_m = Math.abs(b2);
b2\_s = Math.copySign(1.0, b2);
b1\_m = Math.abs(b1);
b1\_s = Math.copySign(1.0, b1);
a2\_m = Math.abs(a2);
a2\_s = Math.copySign(1.0, a2);
a1\_m = Math.abs(a1);
a1\_s = Math.copySign(1.0, a1);
assert a1_m < a2_m && a2_m < b1_m && b1_m < b2_m;
assert a1_m < a2_m && a2_m < b1_m && b1_m < b2_m;
public static double code(double a1_s, double a2_s, double b1_s, double b2_s, double a1_m, double a2_m, double b1_m, double b2_m) {
double t_0 = (a1_m * a2_m) / (b1_m * b2_m);
double tmp;
if (t_0 <= 0.0) {
tmp = (a2_m / b1_m) * (a1_m / b2_m);
} else if (t_0 <= 2e+232) {
tmp = t_0;
} else {
tmp = ((a1_m / b2_m) / b1_m) * a2_m;
}
return a1_s * (a2_s * (b1_s * (b2_s * tmp)));
}
b2\_m = math.fabs(b2) b2\_s = math.copysign(1.0, b2) b1\_m = math.fabs(b1) b1\_s = math.copysign(1.0, b1) a2\_m = math.fabs(a2) a2\_s = math.copysign(1.0, a2) a1\_m = math.fabs(a1) a1\_s = math.copysign(1.0, a1) [a1_m, a2_m, b1_m, b2_m] = sort([a1_m, a2_m, b1_m, b2_m]) [a1_m, a2_m, b1_m, b2_m] = sort([a1_m, a2_m, b1_m, b2_m]) def code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m): t_0 = (a1_m * a2_m) / (b1_m * b2_m) tmp = 0 if t_0 <= 0.0: tmp = (a2_m / b1_m) * (a1_m / b2_m) elif t_0 <= 2e+232: tmp = t_0 else: tmp = ((a1_m / b2_m) / b1_m) * a2_m return a1_s * (a2_s * (b1_s * (b2_s * tmp)))
b2\_m = abs(b2) b2\_s = copysign(1.0, b2) b1\_m = abs(b1) b1\_s = copysign(1.0, b1) a2\_m = abs(a2) a2\_s = copysign(1.0, a2) a1\_m = abs(a1) a1\_s = copysign(1.0, a1) a1_m, a2_m, b1_m, b2_m = sort([a1_m, a2_m, b1_m, b2_m]) a1_m, a2_m, b1_m, b2_m = sort([a1_m, a2_m, b1_m, b2_m]) function code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m) t_0 = Float64(Float64(a1_m * a2_m) / Float64(b1_m * b2_m)) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(a2_m / b1_m) * Float64(a1_m / b2_m)); elseif (t_0 <= 2e+232) tmp = t_0; else tmp = Float64(Float64(Float64(a1_m / b2_m) / b1_m) * a2_m); end return Float64(a1_s * Float64(a2_s * Float64(b1_s * Float64(b2_s * tmp)))) end
b2\_m = abs(b2);
b2\_s = sign(b2) * abs(1.0);
b1\_m = abs(b1);
b1\_s = sign(b1) * abs(1.0);
a2\_m = abs(a2);
a2\_s = sign(a2) * abs(1.0);
a1\_m = abs(a1);
a1\_s = sign(a1) * abs(1.0);
a1_m, a2_m, b1_m, b2_m = num2cell(sort([a1_m, a2_m, b1_m, b2_m])){:}
a1_m, a2_m, b1_m, b2_m = num2cell(sort([a1_m, a2_m, b1_m, b2_m])){:}
function tmp_2 = code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m)
t_0 = (a1_m * a2_m) / (b1_m * b2_m);
tmp = 0.0;
if (t_0 <= 0.0)
tmp = (a2_m / b1_m) * (a1_m / b2_m);
elseif (t_0 <= 2e+232)
tmp = t_0;
else
tmp = ((a1_m / b2_m) / b1_m) * a2_m;
end
tmp_2 = a1_s * (a2_s * (b1_s * (b2_s * tmp)));
end
b2\_m = N[Abs[b2], $MachinePrecision]
b2\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[b2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
b1\_m = N[Abs[b1], $MachinePrecision]
b1\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[b1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a2\_m = N[Abs[a2], $MachinePrecision]
a2\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a1\_m = N[Abs[a1], $MachinePrecision]
a1\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
code[a1$95$s_, a2$95$s_, b1$95$s_, b2$95$s_, a1$95$m_, a2$95$m_, b1$95$m_, b2$95$m_] := Block[{t$95$0 = N[(N[(a1$95$m * a2$95$m), $MachinePrecision] / N[(b1$95$m * b2$95$m), $MachinePrecision]), $MachinePrecision]}, N[(a1$95$s * N[(a2$95$s * N[(b1$95$s * N[(b2$95$s * If[LessEqual[t$95$0, 0.0], N[(N[(a2$95$m / b1$95$m), $MachinePrecision] * N[(a1$95$m / b2$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+232], t$95$0, N[(N[(N[(a1$95$m / b2$95$m), $MachinePrecision] / b1$95$m), $MachinePrecision] * a2$95$m), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b2\_m = \left|b2\right|
\\
b2\_s = \mathsf{copysign}\left(1, b2\right)
\\
b1\_m = \left|b1\right|
\\
b1\_s = \mathsf{copysign}\left(1, b1\right)
\\
a2\_m = \left|a2\right|
\\
a2\_s = \mathsf{copysign}\left(1, a2\right)
\\
a1\_m = \left|a1\right|
\\
a1\_s = \mathsf{copysign}\left(1, a1\right)
\\
[a1_m, a2_m, b1_m, b2_m] = \mathsf{sort}([a1_m, a2_m, b1_m, b2_m])\\\\
[a1_m, a2_m, b1_m, b2_m] = \mathsf{sort}([a1_m, a2_m, b1_m, b2_m])\\
\\
\begin{array}{l}
t_0 := \frac{a1\_m \cdot a2\_m}{b1\_m \cdot b2\_m}\\
a1\_s \cdot \left(a2\_s \cdot \left(b1\_s \cdot \left(b2\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\frac{a2\_m}{b1\_m} \cdot \frac{a1\_m}{b2\_m}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+232}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a1\_m}{b2\_m}}{b1\_m} \cdot a2\_m\\
\end{array}\right)\right)\right)
\end{array}
\end{array}
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0Initial program 89.3%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6491.0
Applied rewrites91.0%
if 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 2.00000000000000011e232Initial program 97.4%
if 2.00000000000000011e232 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 72.1%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6488.5
Applied rewrites88.5%
b2\_m = (fabs.f64 b2)
b2\_s = (copysign.f64 #s(literal 1 binary64) b2)
b1\_m = (fabs.f64 b1)
b1\_s = (copysign.f64 #s(literal 1 binary64) b1)
a2\_m = (fabs.f64 a2)
a2\_s = (copysign.f64 #s(literal 1 binary64) a2)
a1\_m = (fabs.f64 a1)
a1\_s = (copysign.f64 #s(literal 1 binary64) a1)
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
(FPCore (a1_s a2_s b1_s b2_s a1_m a2_m b1_m b2_m)
:precision binary64
(let* ((t_0 (* (/ a2_m b1_m) (/ a1_m b2_m))))
(*
a1_s
(*
a2_s
(*
b1_s
(*
b2_s
(if (<= (* b1_m b2_m) 5e-312)
t_0
(if (<= (* b1_m b2_m) 2e-31)
(* (/ a1_m (* b1_m b2_m)) a2_m)
(if (<= (* b1_m b2_m) 2e+301)
(* (/ a2_m (* b1_m b2_m)) a1_m)
t_0)))))))))b2\_m = fabs(b2);
b2\_s = copysign(1.0, b2);
b1\_m = fabs(b1);
b1\_s = copysign(1.0, b1);
a2\_m = fabs(a2);
a2\_s = copysign(1.0, a2);
a1\_m = fabs(a1);
a1\_s = copysign(1.0, a1);
assert(a1_m < a2_m && a2_m < b1_m && b1_m < b2_m);
assert(a1_m < a2_m && a2_m < b1_m && b1_m < b2_m);
double code(double a1_s, double a2_s, double b1_s, double b2_s, double a1_m, double a2_m, double b1_m, double b2_m) {
double t_0 = (a2_m / b1_m) * (a1_m / b2_m);
double tmp;
if ((b1_m * b2_m) <= 5e-312) {
tmp = t_0;
} else if ((b1_m * b2_m) <= 2e-31) {
tmp = (a1_m / (b1_m * b2_m)) * a2_m;
} else if ((b1_m * b2_m) <= 2e+301) {
tmp = (a2_m / (b1_m * b2_m)) * a1_m;
} else {
tmp = t_0;
}
return a1_s * (a2_s * (b1_s * (b2_s * tmp)));
}
b2\_m = abs(b2)
b2\_s = copysign(1.0d0, b2)
b1\_m = abs(b1)
b1\_s = copysign(1.0d0, b1)
a2\_m = abs(a2)
a2\_s = copysign(1.0d0, a2)
a1\_m = abs(a1)
a1\_s = copysign(1.0d0, a1)
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
real(8) function code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m)
real(8), intent (in) :: a1_s
real(8), intent (in) :: a2_s
real(8), intent (in) :: b1_s
real(8), intent (in) :: b2_s
real(8), intent (in) :: a1_m
real(8), intent (in) :: a2_m
real(8), intent (in) :: b1_m
real(8), intent (in) :: b2_m
real(8) :: t_0
real(8) :: tmp
t_0 = (a2_m / b1_m) * (a1_m / b2_m)
if ((b1_m * b2_m) <= 5d-312) then
tmp = t_0
else if ((b1_m * b2_m) <= 2d-31) then
tmp = (a1_m / (b1_m * b2_m)) * a2_m
else if ((b1_m * b2_m) <= 2d+301) then
tmp = (a2_m / (b1_m * b2_m)) * a1_m
else
tmp = t_0
end if
code = a1_s * (a2_s * (b1_s * (b2_s * tmp)))
end function
b2\_m = Math.abs(b2);
b2\_s = Math.copySign(1.0, b2);
b1\_m = Math.abs(b1);
b1\_s = Math.copySign(1.0, b1);
a2\_m = Math.abs(a2);
a2\_s = Math.copySign(1.0, a2);
a1\_m = Math.abs(a1);
a1\_s = Math.copySign(1.0, a1);
assert a1_m < a2_m && a2_m < b1_m && b1_m < b2_m;
assert a1_m < a2_m && a2_m < b1_m && b1_m < b2_m;
public static double code(double a1_s, double a2_s, double b1_s, double b2_s, double a1_m, double a2_m, double b1_m, double b2_m) {
double t_0 = (a2_m / b1_m) * (a1_m / b2_m);
double tmp;
if ((b1_m * b2_m) <= 5e-312) {
tmp = t_0;
} else if ((b1_m * b2_m) <= 2e-31) {
tmp = (a1_m / (b1_m * b2_m)) * a2_m;
} else if ((b1_m * b2_m) <= 2e+301) {
tmp = (a2_m / (b1_m * b2_m)) * a1_m;
} else {
tmp = t_0;
}
return a1_s * (a2_s * (b1_s * (b2_s * tmp)));
}
b2\_m = math.fabs(b2) b2\_s = math.copysign(1.0, b2) b1\_m = math.fabs(b1) b1\_s = math.copysign(1.0, b1) a2\_m = math.fabs(a2) a2\_s = math.copysign(1.0, a2) a1\_m = math.fabs(a1) a1\_s = math.copysign(1.0, a1) [a1_m, a2_m, b1_m, b2_m] = sort([a1_m, a2_m, b1_m, b2_m]) [a1_m, a2_m, b1_m, b2_m] = sort([a1_m, a2_m, b1_m, b2_m]) def code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m): t_0 = (a2_m / b1_m) * (a1_m / b2_m) tmp = 0 if (b1_m * b2_m) <= 5e-312: tmp = t_0 elif (b1_m * b2_m) <= 2e-31: tmp = (a1_m / (b1_m * b2_m)) * a2_m elif (b1_m * b2_m) <= 2e+301: tmp = (a2_m / (b1_m * b2_m)) * a1_m else: tmp = t_0 return a1_s * (a2_s * (b1_s * (b2_s * tmp)))
b2\_m = abs(b2) b2\_s = copysign(1.0, b2) b1\_m = abs(b1) b1\_s = copysign(1.0, b1) a2\_m = abs(a2) a2\_s = copysign(1.0, a2) a1\_m = abs(a1) a1\_s = copysign(1.0, a1) a1_m, a2_m, b1_m, b2_m = sort([a1_m, a2_m, b1_m, b2_m]) a1_m, a2_m, b1_m, b2_m = sort([a1_m, a2_m, b1_m, b2_m]) function code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m) t_0 = Float64(Float64(a2_m / b1_m) * Float64(a1_m / b2_m)) tmp = 0.0 if (Float64(b1_m * b2_m) <= 5e-312) tmp = t_0; elseif (Float64(b1_m * b2_m) <= 2e-31) tmp = Float64(Float64(a1_m / Float64(b1_m * b2_m)) * a2_m); elseif (Float64(b1_m * b2_m) <= 2e+301) tmp = Float64(Float64(a2_m / Float64(b1_m * b2_m)) * a1_m); else tmp = t_0; end return Float64(a1_s * Float64(a2_s * Float64(b1_s * Float64(b2_s * tmp)))) end
b2\_m = abs(b2);
b2\_s = sign(b2) * abs(1.0);
b1\_m = abs(b1);
b1\_s = sign(b1) * abs(1.0);
a2\_m = abs(a2);
a2\_s = sign(a2) * abs(1.0);
a1\_m = abs(a1);
a1\_s = sign(a1) * abs(1.0);
a1_m, a2_m, b1_m, b2_m = num2cell(sort([a1_m, a2_m, b1_m, b2_m])){:}
a1_m, a2_m, b1_m, b2_m = num2cell(sort([a1_m, a2_m, b1_m, b2_m])){:}
function tmp_2 = code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m)
t_0 = (a2_m / b1_m) * (a1_m / b2_m);
tmp = 0.0;
if ((b1_m * b2_m) <= 5e-312)
tmp = t_0;
elseif ((b1_m * b2_m) <= 2e-31)
tmp = (a1_m / (b1_m * b2_m)) * a2_m;
elseif ((b1_m * b2_m) <= 2e+301)
tmp = (a2_m / (b1_m * b2_m)) * a1_m;
else
tmp = t_0;
end
tmp_2 = a1_s * (a2_s * (b1_s * (b2_s * tmp)));
end
b2\_m = N[Abs[b2], $MachinePrecision]
b2\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[b2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
b1\_m = N[Abs[b1], $MachinePrecision]
b1\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[b1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a2\_m = N[Abs[a2], $MachinePrecision]
a2\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a1\_m = N[Abs[a1], $MachinePrecision]
a1\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
code[a1$95$s_, a2$95$s_, b1$95$s_, b2$95$s_, a1$95$m_, a2$95$m_, b1$95$m_, b2$95$m_] := Block[{t$95$0 = N[(N[(a2$95$m / b1$95$m), $MachinePrecision] * N[(a1$95$m / b2$95$m), $MachinePrecision]), $MachinePrecision]}, N[(a1$95$s * N[(a2$95$s * N[(b1$95$s * N[(b2$95$s * If[LessEqual[N[(b1$95$m * b2$95$m), $MachinePrecision], 5e-312], t$95$0, If[LessEqual[N[(b1$95$m * b2$95$m), $MachinePrecision], 2e-31], N[(N[(a1$95$m / N[(b1$95$m * b2$95$m), $MachinePrecision]), $MachinePrecision] * a2$95$m), $MachinePrecision], If[LessEqual[N[(b1$95$m * b2$95$m), $MachinePrecision], 2e+301], N[(N[(a2$95$m / N[(b1$95$m * b2$95$m), $MachinePrecision]), $MachinePrecision] * a1$95$m), $MachinePrecision], t$95$0]]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
b2\_m = \left|b2\right|
\\
b2\_s = \mathsf{copysign}\left(1, b2\right)
\\
b1\_m = \left|b1\right|
\\
b1\_s = \mathsf{copysign}\left(1, b1\right)
\\
a2\_m = \left|a2\right|
\\
a2\_s = \mathsf{copysign}\left(1, a2\right)
\\
a1\_m = \left|a1\right|
\\
a1\_s = \mathsf{copysign}\left(1, a1\right)
\\
[a1_m, a2_m, b1_m, b2_m] = \mathsf{sort}([a1_m, a2_m, b1_m, b2_m])\\\\
[a1_m, a2_m, b1_m, b2_m] = \mathsf{sort}([a1_m, a2_m, b1_m, b2_m])\\
\\
\begin{array}{l}
t_0 := \frac{a2\_m}{b1\_m} \cdot \frac{a1\_m}{b2\_m}\\
a1\_s \cdot \left(a2\_s \cdot \left(b1\_s \cdot \left(b2\_s \cdot \begin{array}{l}
\mathbf{if}\;b1\_m \cdot b2\_m \leq 5 \cdot 10^{-312}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b1\_m \cdot b2\_m \leq 2 \cdot 10^{-31}:\\
\;\;\;\;\frac{a1\_m}{b1\_m \cdot b2\_m} \cdot a2\_m\\
\mathbf{elif}\;b1\_m \cdot b2\_m \leq 2 \cdot 10^{+301}:\\
\;\;\;\;\frac{a2\_m}{b1\_m \cdot b2\_m} \cdot a1\_m\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}\right)\right)\right)
\end{array}
\end{array}
if (*.f64 b1 b2) < 5.0000000000022e-312 or 2.00000000000000011e301 < (*.f64 b1 b2) Initial program 85.3%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6491.1
Applied rewrites91.1%
if 5.0000000000022e-312 < (*.f64 b1 b2) < 2e-31Initial program 94.1%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.3
Applied rewrites87.3%
lift-/.f64N/A
lift-/.f64N/A
remove-double-negN/A
associate-/r*N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
remove-double-neg92.3
Applied rewrites92.3%
if 2e-31 < (*.f64 b1 b2) < 2.00000000000000011e301Initial program 91.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6481.1
Applied rewrites81.1%
lift-/.f64N/A
lift-/.f64N/A
remove-double-negN/A
associate-/r*N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
remove-double-neg93.7
Applied rewrites93.7%
b2\_m = (fabs.f64 b2)
b2\_s = (copysign.f64 #s(literal 1 binary64) b2)
b1\_m = (fabs.f64 b1)
b1\_s = (copysign.f64 #s(literal 1 binary64) b1)
a2\_m = (fabs.f64 a2)
a2\_s = (copysign.f64 #s(literal 1 binary64) a2)
a1\_m = (fabs.f64 a1)
a1\_s = (copysign.f64 #s(literal 1 binary64) a1)
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
(FPCore (a1_s a2_s b1_s b2_s a1_m a2_m b1_m b2_m)
:precision binary64
(*
a1_s
(*
a2_s
(*
b1_s
(*
b2_s
(if (<= (* b1_m b2_m) 50000000000000.0)
(* (/ (/ a1_m b1_m) b2_m) a2_m)
(* (/ (/ a2_m b2_m) b1_m) a1_m)))))))b2\_m = fabs(b2);
b2\_s = copysign(1.0, b2);
b1\_m = fabs(b1);
b1\_s = copysign(1.0, b1);
a2\_m = fabs(a2);
a2\_s = copysign(1.0, a2);
a1\_m = fabs(a1);
a1\_s = copysign(1.0, a1);
assert(a1_m < a2_m && a2_m < b1_m && b1_m < b2_m);
assert(a1_m < a2_m && a2_m < b1_m && b1_m < b2_m);
double code(double a1_s, double a2_s, double b1_s, double b2_s, double a1_m, double a2_m, double b1_m, double b2_m) {
double tmp;
if ((b1_m * b2_m) <= 50000000000000.0) {
tmp = ((a1_m / b1_m) / b2_m) * a2_m;
} else {
tmp = ((a2_m / b2_m) / b1_m) * a1_m;
}
return a1_s * (a2_s * (b1_s * (b2_s * tmp)));
}
b2\_m = abs(b2)
b2\_s = copysign(1.0d0, b2)
b1\_m = abs(b1)
b1\_s = copysign(1.0d0, b1)
a2\_m = abs(a2)
a2\_s = copysign(1.0d0, a2)
a1\_m = abs(a1)
a1\_s = copysign(1.0d0, a1)
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
real(8) function code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m)
real(8), intent (in) :: a1_s
real(8), intent (in) :: a2_s
real(8), intent (in) :: b1_s
real(8), intent (in) :: b2_s
real(8), intent (in) :: a1_m
real(8), intent (in) :: a2_m
real(8), intent (in) :: b1_m
real(8), intent (in) :: b2_m
real(8) :: tmp
if ((b1_m * b2_m) <= 50000000000000.0d0) then
tmp = ((a1_m / b1_m) / b2_m) * a2_m
else
tmp = ((a2_m / b2_m) / b1_m) * a1_m
end if
code = a1_s * (a2_s * (b1_s * (b2_s * tmp)))
end function
b2\_m = Math.abs(b2);
b2\_s = Math.copySign(1.0, b2);
b1\_m = Math.abs(b1);
b1\_s = Math.copySign(1.0, b1);
a2\_m = Math.abs(a2);
a2\_s = Math.copySign(1.0, a2);
a1\_m = Math.abs(a1);
a1\_s = Math.copySign(1.0, a1);
assert a1_m < a2_m && a2_m < b1_m && b1_m < b2_m;
assert a1_m < a2_m && a2_m < b1_m && b1_m < b2_m;
public static double code(double a1_s, double a2_s, double b1_s, double b2_s, double a1_m, double a2_m, double b1_m, double b2_m) {
double tmp;
if ((b1_m * b2_m) <= 50000000000000.0) {
tmp = ((a1_m / b1_m) / b2_m) * a2_m;
} else {
tmp = ((a2_m / b2_m) / b1_m) * a1_m;
}
return a1_s * (a2_s * (b1_s * (b2_s * tmp)));
}
b2\_m = math.fabs(b2) b2\_s = math.copysign(1.0, b2) b1\_m = math.fabs(b1) b1\_s = math.copysign(1.0, b1) a2\_m = math.fabs(a2) a2\_s = math.copysign(1.0, a2) a1\_m = math.fabs(a1) a1\_s = math.copysign(1.0, a1) [a1_m, a2_m, b1_m, b2_m] = sort([a1_m, a2_m, b1_m, b2_m]) [a1_m, a2_m, b1_m, b2_m] = sort([a1_m, a2_m, b1_m, b2_m]) def code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m): tmp = 0 if (b1_m * b2_m) <= 50000000000000.0: tmp = ((a1_m / b1_m) / b2_m) * a2_m else: tmp = ((a2_m / b2_m) / b1_m) * a1_m return a1_s * (a2_s * (b1_s * (b2_s * tmp)))
b2\_m = abs(b2) b2\_s = copysign(1.0, b2) b1\_m = abs(b1) b1\_s = copysign(1.0, b1) a2\_m = abs(a2) a2\_s = copysign(1.0, a2) a1\_m = abs(a1) a1\_s = copysign(1.0, a1) a1_m, a2_m, b1_m, b2_m = sort([a1_m, a2_m, b1_m, b2_m]) a1_m, a2_m, b1_m, b2_m = sort([a1_m, a2_m, b1_m, b2_m]) function code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m) tmp = 0.0 if (Float64(b1_m * b2_m) <= 50000000000000.0) tmp = Float64(Float64(Float64(a1_m / b1_m) / b2_m) * a2_m); else tmp = Float64(Float64(Float64(a2_m / b2_m) / b1_m) * a1_m); end return Float64(a1_s * Float64(a2_s * Float64(b1_s * Float64(b2_s * tmp)))) end
b2\_m = abs(b2);
b2\_s = sign(b2) * abs(1.0);
b1\_m = abs(b1);
b1\_s = sign(b1) * abs(1.0);
a2\_m = abs(a2);
a2\_s = sign(a2) * abs(1.0);
a1\_m = abs(a1);
a1\_s = sign(a1) * abs(1.0);
a1_m, a2_m, b1_m, b2_m = num2cell(sort([a1_m, a2_m, b1_m, b2_m])){:}
a1_m, a2_m, b1_m, b2_m = num2cell(sort([a1_m, a2_m, b1_m, b2_m])){:}
function tmp_2 = code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m)
tmp = 0.0;
if ((b1_m * b2_m) <= 50000000000000.0)
tmp = ((a1_m / b1_m) / b2_m) * a2_m;
else
tmp = ((a2_m / b2_m) / b1_m) * a1_m;
end
tmp_2 = a1_s * (a2_s * (b1_s * (b2_s * tmp)));
end
b2\_m = N[Abs[b2], $MachinePrecision]
b2\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[b2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
b1\_m = N[Abs[b1], $MachinePrecision]
b1\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[b1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a2\_m = N[Abs[a2], $MachinePrecision]
a2\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a1\_m = N[Abs[a1], $MachinePrecision]
a1\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
code[a1$95$s_, a2$95$s_, b1$95$s_, b2$95$s_, a1$95$m_, a2$95$m_, b1$95$m_, b2$95$m_] := N[(a1$95$s * N[(a2$95$s * N[(b1$95$s * N[(b2$95$s * If[LessEqual[N[(b1$95$m * b2$95$m), $MachinePrecision], 50000000000000.0], N[(N[(N[(a1$95$m / b1$95$m), $MachinePrecision] / b2$95$m), $MachinePrecision] * a2$95$m), $MachinePrecision], N[(N[(N[(a2$95$m / b2$95$m), $MachinePrecision] / b1$95$m), $MachinePrecision] * a1$95$m), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b2\_m = \left|b2\right|
\\
b2\_s = \mathsf{copysign}\left(1, b2\right)
\\
b1\_m = \left|b1\right|
\\
b1\_s = \mathsf{copysign}\left(1, b1\right)
\\
a2\_m = \left|a2\right|
\\
a2\_s = \mathsf{copysign}\left(1, a2\right)
\\
a1\_m = \left|a1\right|
\\
a1\_s = \mathsf{copysign}\left(1, a1\right)
\\
[a1_m, a2_m, b1_m, b2_m] = \mathsf{sort}([a1_m, a2_m, b1_m, b2_m])\\\\
[a1_m, a2_m, b1_m, b2_m] = \mathsf{sort}([a1_m, a2_m, b1_m, b2_m])\\
\\
a1\_s \cdot \left(a2\_s \cdot \left(b1\_s \cdot \left(b2\_s \cdot \begin{array}{l}
\mathbf{if}\;b1\_m \cdot b2\_m \leq 50000000000000:\\
\;\;\;\;\frac{\frac{a1\_m}{b1\_m}}{b2\_m} \cdot a2\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a2\_m}{b2\_m}}{b1\_m} \cdot a1\_m\\
\end{array}\right)\right)\right)
\end{array}
if (*.f64 b1 b2) < 5e13Initial program 88.2%
lift-/.f64N/A
frac-2negN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
associate-*l/N/A
lower-*.f64N/A
frac-2neg-revN/A
remove-double-negN/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-neg.f6487.1
Applied rewrites87.1%
if 5e13 < (*.f64 b1 b2) Initial program 86.1%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6484.7
Applied rewrites84.7%
Final simplification86.5%
b2\_m = (fabs.f64 b2)
b2\_s = (copysign.f64 #s(literal 1 binary64) b2)
b1\_m = (fabs.f64 b1)
b1\_s = (copysign.f64 #s(literal 1 binary64) b1)
a2\_m = (fabs.f64 a2)
a2\_s = (copysign.f64 #s(literal 1 binary64) a2)
a1\_m = (fabs.f64 a1)
a1\_s = (copysign.f64 #s(literal 1 binary64) a1)
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
(FPCore (a1_s a2_s b1_s b2_s a1_m a2_m b1_m b2_m)
:precision binary64
(*
a1_s
(*
a2_s
(*
b1_s
(*
b2_s
(if (<= (* a1_m a2_m) 2e+87)
(/ (* (/ a1_m b1_m) a2_m) b2_m)
(* (/ (/ a2_m b2_m) b1_m) a1_m)))))))b2\_m = fabs(b2);
b2\_s = copysign(1.0, b2);
b1\_m = fabs(b1);
b1\_s = copysign(1.0, b1);
a2\_m = fabs(a2);
a2\_s = copysign(1.0, a2);
a1\_m = fabs(a1);
a1\_s = copysign(1.0, a1);
assert(a1_m < a2_m && a2_m < b1_m && b1_m < b2_m);
assert(a1_m < a2_m && a2_m < b1_m && b1_m < b2_m);
double code(double a1_s, double a2_s, double b1_s, double b2_s, double a1_m, double a2_m, double b1_m, double b2_m) {
double tmp;
if ((a1_m * a2_m) <= 2e+87) {
tmp = ((a1_m / b1_m) * a2_m) / b2_m;
} else {
tmp = ((a2_m / b2_m) / b1_m) * a1_m;
}
return a1_s * (a2_s * (b1_s * (b2_s * tmp)));
}
b2\_m = abs(b2)
b2\_s = copysign(1.0d0, b2)
b1\_m = abs(b1)
b1\_s = copysign(1.0d0, b1)
a2\_m = abs(a2)
a2\_s = copysign(1.0d0, a2)
a1\_m = abs(a1)
a1\_s = copysign(1.0d0, a1)
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
real(8) function code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m)
real(8), intent (in) :: a1_s
real(8), intent (in) :: a2_s
real(8), intent (in) :: b1_s
real(8), intent (in) :: b2_s
real(8), intent (in) :: a1_m
real(8), intent (in) :: a2_m
real(8), intent (in) :: b1_m
real(8), intent (in) :: b2_m
real(8) :: tmp
if ((a1_m * a2_m) <= 2d+87) then
tmp = ((a1_m / b1_m) * a2_m) / b2_m
else
tmp = ((a2_m / b2_m) / b1_m) * a1_m
end if
code = a1_s * (a2_s * (b1_s * (b2_s * tmp)))
end function
b2\_m = Math.abs(b2);
b2\_s = Math.copySign(1.0, b2);
b1\_m = Math.abs(b1);
b1\_s = Math.copySign(1.0, b1);
a2\_m = Math.abs(a2);
a2\_s = Math.copySign(1.0, a2);
a1\_m = Math.abs(a1);
a1\_s = Math.copySign(1.0, a1);
assert a1_m < a2_m && a2_m < b1_m && b1_m < b2_m;
assert a1_m < a2_m && a2_m < b1_m && b1_m < b2_m;
public static double code(double a1_s, double a2_s, double b1_s, double b2_s, double a1_m, double a2_m, double b1_m, double b2_m) {
double tmp;
if ((a1_m * a2_m) <= 2e+87) {
tmp = ((a1_m / b1_m) * a2_m) / b2_m;
} else {
tmp = ((a2_m / b2_m) / b1_m) * a1_m;
}
return a1_s * (a2_s * (b1_s * (b2_s * tmp)));
}
b2\_m = math.fabs(b2) b2\_s = math.copysign(1.0, b2) b1\_m = math.fabs(b1) b1\_s = math.copysign(1.0, b1) a2\_m = math.fabs(a2) a2\_s = math.copysign(1.0, a2) a1\_m = math.fabs(a1) a1\_s = math.copysign(1.0, a1) [a1_m, a2_m, b1_m, b2_m] = sort([a1_m, a2_m, b1_m, b2_m]) [a1_m, a2_m, b1_m, b2_m] = sort([a1_m, a2_m, b1_m, b2_m]) def code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m): tmp = 0 if (a1_m * a2_m) <= 2e+87: tmp = ((a1_m / b1_m) * a2_m) / b2_m else: tmp = ((a2_m / b2_m) / b1_m) * a1_m return a1_s * (a2_s * (b1_s * (b2_s * tmp)))
b2\_m = abs(b2) b2\_s = copysign(1.0, b2) b1\_m = abs(b1) b1\_s = copysign(1.0, b1) a2\_m = abs(a2) a2\_s = copysign(1.0, a2) a1\_m = abs(a1) a1\_s = copysign(1.0, a1) a1_m, a2_m, b1_m, b2_m = sort([a1_m, a2_m, b1_m, b2_m]) a1_m, a2_m, b1_m, b2_m = sort([a1_m, a2_m, b1_m, b2_m]) function code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m) tmp = 0.0 if (Float64(a1_m * a2_m) <= 2e+87) tmp = Float64(Float64(Float64(a1_m / b1_m) * a2_m) / b2_m); else tmp = Float64(Float64(Float64(a2_m / b2_m) / b1_m) * a1_m); end return Float64(a1_s * Float64(a2_s * Float64(b1_s * Float64(b2_s * tmp)))) end
b2\_m = abs(b2);
b2\_s = sign(b2) * abs(1.0);
b1\_m = abs(b1);
b1\_s = sign(b1) * abs(1.0);
a2\_m = abs(a2);
a2\_s = sign(a2) * abs(1.0);
a1\_m = abs(a1);
a1\_s = sign(a1) * abs(1.0);
a1_m, a2_m, b1_m, b2_m = num2cell(sort([a1_m, a2_m, b1_m, b2_m])){:}
a1_m, a2_m, b1_m, b2_m = num2cell(sort([a1_m, a2_m, b1_m, b2_m])){:}
function tmp_2 = code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m)
tmp = 0.0;
if ((a1_m * a2_m) <= 2e+87)
tmp = ((a1_m / b1_m) * a2_m) / b2_m;
else
tmp = ((a2_m / b2_m) / b1_m) * a1_m;
end
tmp_2 = a1_s * (a2_s * (b1_s * (b2_s * tmp)));
end
b2\_m = N[Abs[b2], $MachinePrecision]
b2\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[b2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
b1\_m = N[Abs[b1], $MachinePrecision]
b1\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[b1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a2\_m = N[Abs[a2], $MachinePrecision]
a2\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a1\_m = N[Abs[a1], $MachinePrecision]
a1\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
code[a1$95$s_, a2$95$s_, b1$95$s_, b2$95$s_, a1$95$m_, a2$95$m_, b1$95$m_, b2$95$m_] := N[(a1$95$s * N[(a2$95$s * N[(b1$95$s * N[(b2$95$s * If[LessEqual[N[(a1$95$m * a2$95$m), $MachinePrecision], 2e+87], N[(N[(N[(a1$95$m / b1$95$m), $MachinePrecision] * a2$95$m), $MachinePrecision] / b2$95$m), $MachinePrecision], N[(N[(N[(a2$95$m / b2$95$m), $MachinePrecision] / b1$95$m), $MachinePrecision] * a1$95$m), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b2\_m = \left|b2\right|
\\
b2\_s = \mathsf{copysign}\left(1, b2\right)
\\
b1\_m = \left|b1\right|
\\
b1\_s = \mathsf{copysign}\left(1, b1\right)
\\
a2\_m = \left|a2\right|
\\
a2\_s = \mathsf{copysign}\left(1, a2\right)
\\
a1\_m = \left|a1\right|
\\
a1\_s = \mathsf{copysign}\left(1, a1\right)
\\
[a1_m, a2_m, b1_m, b2_m] = \mathsf{sort}([a1_m, a2_m, b1_m, b2_m])\\\\
[a1_m, a2_m, b1_m, b2_m] = \mathsf{sort}([a1_m, a2_m, b1_m, b2_m])\\
\\
a1\_s \cdot \left(a2\_s \cdot \left(b1\_s \cdot \left(b2\_s \cdot \begin{array}{l}
\mathbf{if}\;a1\_m \cdot a2\_m \leq 2 \cdot 10^{+87}:\\
\;\;\;\;\frac{\frac{a1\_m}{b1\_m} \cdot a2\_m}{b2\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a2\_m}{b2\_m}}{b1\_m} \cdot a1\_m\\
\end{array}\right)\right)\right)
\end{array}
if (*.f64 a1 a2) < 1.9999999999999999e87Initial program 88.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f6485.1
Applied rewrites85.1%
if 1.9999999999999999e87 < (*.f64 a1 a2) Initial program 84.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6487.9
Applied rewrites87.9%
b2\_m = (fabs.f64 b2)
b2\_s = (copysign.f64 #s(literal 1 binary64) b2)
b1\_m = (fabs.f64 b1)
b1\_s = (copysign.f64 #s(literal 1 binary64) b1)
a2\_m = (fabs.f64 a2)
a2\_s = (copysign.f64 #s(literal 1 binary64) a2)
a1\_m = (fabs.f64 a1)
a1\_s = (copysign.f64 #s(literal 1 binary64) a1)
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
(FPCore (a1_s a2_s b1_s b2_s a1_m a2_m b1_m b2_m)
:precision binary64
(*
a1_s
(*
a2_s
(*
b1_s
(*
b2_s
(if (<= (* b1_m b2_m) 1e-29)
(* (/ a1_m (* b1_m b2_m)) a2_m)
(* (/ a2_m (* b1_m b2_m)) a1_m)))))))b2\_m = fabs(b2);
b2\_s = copysign(1.0, b2);
b1\_m = fabs(b1);
b1\_s = copysign(1.0, b1);
a2\_m = fabs(a2);
a2\_s = copysign(1.0, a2);
a1\_m = fabs(a1);
a1\_s = copysign(1.0, a1);
assert(a1_m < a2_m && a2_m < b1_m && b1_m < b2_m);
assert(a1_m < a2_m && a2_m < b1_m && b1_m < b2_m);
double code(double a1_s, double a2_s, double b1_s, double b2_s, double a1_m, double a2_m, double b1_m, double b2_m) {
double tmp;
if ((b1_m * b2_m) <= 1e-29) {
tmp = (a1_m / (b1_m * b2_m)) * a2_m;
} else {
tmp = (a2_m / (b1_m * b2_m)) * a1_m;
}
return a1_s * (a2_s * (b1_s * (b2_s * tmp)));
}
b2\_m = abs(b2)
b2\_s = copysign(1.0d0, b2)
b1\_m = abs(b1)
b1\_s = copysign(1.0d0, b1)
a2\_m = abs(a2)
a2\_s = copysign(1.0d0, a2)
a1\_m = abs(a1)
a1\_s = copysign(1.0d0, a1)
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
real(8) function code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m)
real(8), intent (in) :: a1_s
real(8), intent (in) :: a2_s
real(8), intent (in) :: b1_s
real(8), intent (in) :: b2_s
real(8), intent (in) :: a1_m
real(8), intent (in) :: a2_m
real(8), intent (in) :: b1_m
real(8), intent (in) :: b2_m
real(8) :: tmp
if ((b1_m * b2_m) <= 1d-29) then
tmp = (a1_m / (b1_m * b2_m)) * a2_m
else
tmp = (a2_m / (b1_m * b2_m)) * a1_m
end if
code = a1_s * (a2_s * (b1_s * (b2_s * tmp)))
end function
b2\_m = Math.abs(b2);
b2\_s = Math.copySign(1.0, b2);
b1\_m = Math.abs(b1);
b1\_s = Math.copySign(1.0, b1);
a2\_m = Math.abs(a2);
a2\_s = Math.copySign(1.0, a2);
a1\_m = Math.abs(a1);
a1\_s = Math.copySign(1.0, a1);
assert a1_m < a2_m && a2_m < b1_m && b1_m < b2_m;
assert a1_m < a2_m && a2_m < b1_m && b1_m < b2_m;
public static double code(double a1_s, double a2_s, double b1_s, double b2_s, double a1_m, double a2_m, double b1_m, double b2_m) {
double tmp;
if ((b1_m * b2_m) <= 1e-29) {
tmp = (a1_m / (b1_m * b2_m)) * a2_m;
} else {
tmp = (a2_m / (b1_m * b2_m)) * a1_m;
}
return a1_s * (a2_s * (b1_s * (b2_s * tmp)));
}
b2\_m = math.fabs(b2) b2\_s = math.copysign(1.0, b2) b1\_m = math.fabs(b1) b1\_s = math.copysign(1.0, b1) a2\_m = math.fabs(a2) a2\_s = math.copysign(1.0, a2) a1\_m = math.fabs(a1) a1\_s = math.copysign(1.0, a1) [a1_m, a2_m, b1_m, b2_m] = sort([a1_m, a2_m, b1_m, b2_m]) [a1_m, a2_m, b1_m, b2_m] = sort([a1_m, a2_m, b1_m, b2_m]) def code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m): tmp = 0 if (b1_m * b2_m) <= 1e-29: tmp = (a1_m / (b1_m * b2_m)) * a2_m else: tmp = (a2_m / (b1_m * b2_m)) * a1_m return a1_s * (a2_s * (b1_s * (b2_s * tmp)))
b2\_m = abs(b2) b2\_s = copysign(1.0, b2) b1\_m = abs(b1) b1\_s = copysign(1.0, b1) a2\_m = abs(a2) a2\_s = copysign(1.0, a2) a1\_m = abs(a1) a1\_s = copysign(1.0, a1) a1_m, a2_m, b1_m, b2_m = sort([a1_m, a2_m, b1_m, b2_m]) a1_m, a2_m, b1_m, b2_m = sort([a1_m, a2_m, b1_m, b2_m]) function code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m) tmp = 0.0 if (Float64(b1_m * b2_m) <= 1e-29) tmp = Float64(Float64(a1_m / Float64(b1_m * b2_m)) * a2_m); else tmp = Float64(Float64(a2_m / Float64(b1_m * b2_m)) * a1_m); end return Float64(a1_s * Float64(a2_s * Float64(b1_s * Float64(b2_s * tmp)))) end
b2\_m = abs(b2);
b2\_s = sign(b2) * abs(1.0);
b1\_m = abs(b1);
b1\_s = sign(b1) * abs(1.0);
a2\_m = abs(a2);
a2\_s = sign(a2) * abs(1.0);
a1\_m = abs(a1);
a1\_s = sign(a1) * abs(1.0);
a1_m, a2_m, b1_m, b2_m = num2cell(sort([a1_m, a2_m, b1_m, b2_m])){:}
a1_m, a2_m, b1_m, b2_m = num2cell(sort([a1_m, a2_m, b1_m, b2_m])){:}
function tmp_2 = code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m)
tmp = 0.0;
if ((b1_m * b2_m) <= 1e-29)
tmp = (a1_m / (b1_m * b2_m)) * a2_m;
else
tmp = (a2_m / (b1_m * b2_m)) * a1_m;
end
tmp_2 = a1_s * (a2_s * (b1_s * (b2_s * tmp)));
end
b2\_m = N[Abs[b2], $MachinePrecision]
b2\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[b2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
b1\_m = N[Abs[b1], $MachinePrecision]
b1\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[b1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a2\_m = N[Abs[a2], $MachinePrecision]
a2\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a1\_m = N[Abs[a1], $MachinePrecision]
a1\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
code[a1$95$s_, a2$95$s_, b1$95$s_, b2$95$s_, a1$95$m_, a2$95$m_, b1$95$m_, b2$95$m_] := N[(a1$95$s * N[(a2$95$s * N[(b1$95$s * N[(b2$95$s * If[LessEqual[N[(b1$95$m * b2$95$m), $MachinePrecision], 1e-29], N[(N[(a1$95$m / N[(b1$95$m * b2$95$m), $MachinePrecision]), $MachinePrecision] * a2$95$m), $MachinePrecision], N[(N[(a2$95$m / N[(b1$95$m * b2$95$m), $MachinePrecision]), $MachinePrecision] * a1$95$m), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b2\_m = \left|b2\right|
\\
b2\_s = \mathsf{copysign}\left(1, b2\right)
\\
b1\_m = \left|b1\right|
\\
b1\_s = \mathsf{copysign}\left(1, b1\right)
\\
a2\_m = \left|a2\right|
\\
a2\_s = \mathsf{copysign}\left(1, a2\right)
\\
a1\_m = \left|a1\right|
\\
a1\_s = \mathsf{copysign}\left(1, a1\right)
\\
[a1_m, a2_m, b1_m, b2_m] = \mathsf{sort}([a1_m, a2_m, b1_m, b2_m])\\\\
[a1_m, a2_m, b1_m, b2_m] = \mathsf{sort}([a1_m, a2_m, b1_m, b2_m])\\
\\
a1\_s \cdot \left(a2\_s \cdot \left(b1\_s \cdot \left(b2\_s \cdot \begin{array}{l}
\mathbf{if}\;b1\_m \cdot b2\_m \leq 10^{-29}:\\
\;\;\;\;\frac{a1\_m}{b1\_m \cdot b2\_m} \cdot a2\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{a2\_m}{b1\_m \cdot b2\_m} \cdot a1\_m\\
\end{array}\right)\right)\right)
\end{array}
if (*.f64 b1 b2) < 9.99999999999999943e-30Initial program 87.9%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6489.0
Applied rewrites89.0%
lift-/.f64N/A
lift-/.f64N/A
remove-double-negN/A
associate-/r*N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
remove-double-neg87.6
Applied rewrites87.6%
if 9.99999999999999943e-30 < (*.f64 b1 b2) Initial program 87.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6484.7
Applied rewrites84.7%
lift-/.f64N/A
lift-/.f64N/A
remove-double-negN/A
associate-/r*N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
remove-double-neg88.9
Applied rewrites88.9%
b2\_m = (fabs.f64 b2) b2\_s = (copysign.f64 #s(literal 1 binary64) b2) b1\_m = (fabs.f64 b1) b1\_s = (copysign.f64 #s(literal 1 binary64) b1) a2\_m = (fabs.f64 a2) a2\_s = (copysign.f64 #s(literal 1 binary64) a2) a1\_m = (fabs.f64 a1) a1\_s = (copysign.f64 #s(literal 1 binary64) a1) NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function. NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function. (FPCore (a1_s a2_s b1_s b2_s a1_m a2_m b1_m b2_m) :precision binary64 (* a1_s (* a2_s (* b1_s (* b2_s (* (/ a1_m (* b1_m b2_m)) a2_m))))))
b2\_m = fabs(b2);
b2\_s = copysign(1.0, b2);
b1\_m = fabs(b1);
b1\_s = copysign(1.0, b1);
a2\_m = fabs(a2);
a2\_s = copysign(1.0, a2);
a1\_m = fabs(a1);
a1\_s = copysign(1.0, a1);
assert(a1_m < a2_m && a2_m < b1_m && b1_m < b2_m);
assert(a1_m < a2_m && a2_m < b1_m && b1_m < b2_m);
double code(double a1_s, double a2_s, double b1_s, double b2_s, double a1_m, double a2_m, double b1_m, double b2_m) {
return a1_s * (a2_s * (b1_s * (b2_s * ((a1_m / (b1_m * b2_m)) * a2_m))));
}
b2\_m = abs(b2)
b2\_s = copysign(1.0d0, b2)
b1\_m = abs(b1)
b1\_s = copysign(1.0d0, b1)
a2\_m = abs(a2)
a2\_s = copysign(1.0d0, a2)
a1\_m = abs(a1)
a1\_s = copysign(1.0d0, a1)
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
real(8) function code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m)
real(8), intent (in) :: a1_s
real(8), intent (in) :: a2_s
real(8), intent (in) :: b1_s
real(8), intent (in) :: b2_s
real(8), intent (in) :: a1_m
real(8), intent (in) :: a2_m
real(8), intent (in) :: b1_m
real(8), intent (in) :: b2_m
code = a1_s * (a2_s * (b1_s * (b2_s * ((a1_m / (b1_m * b2_m)) * a2_m))))
end function
b2\_m = Math.abs(b2);
b2\_s = Math.copySign(1.0, b2);
b1\_m = Math.abs(b1);
b1\_s = Math.copySign(1.0, b1);
a2\_m = Math.abs(a2);
a2\_s = Math.copySign(1.0, a2);
a1\_m = Math.abs(a1);
a1\_s = Math.copySign(1.0, a1);
assert a1_m < a2_m && a2_m < b1_m && b1_m < b2_m;
assert a1_m < a2_m && a2_m < b1_m && b1_m < b2_m;
public static double code(double a1_s, double a2_s, double b1_s, double b2_s, double a1_m, double a2_m, double b1_m, double b2_m) {
return a1_s * (a2_s * (b1_s * (b2_s * ((a1_m / (b1_m * b2_m)) * a2_m))));
}
b2\_m = math.fabs(b2) b2\_s = math.copysign(1.0, b2) b1\_m = math.fabs(b1) b1\_s = math.copysign(1.0, b1) a2\_m = math.fabs(a2) a2\_s = math.copysign(1.0, a2) a1\_m = math.fabs(a1) a1\_s = math.copysign(1.0, a1) [a1_m, a2_m, b1_m, b2_m] = sort([a1_m, a2_m, b1_m, b2_m]) [a1_m, a2_m, b1_m, b2_m] = sort([a1_m, a2_m, b1_m, b2_m]) def code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m): return a1_s * (a2_s * (b1_s * (b2_s * ((a1_m / (b1_m * b2_m)) * a2_m))))
b2\_m = abs(b2) b2\_s = copysign(1.0, b2) b1\_m = abs(b1) b1\_s = copysign(1.0, b1) a2\_m = abs(a2) a2\_s = copysign(1.0, a2) a1\_m = abs(a1) a1\_s = copysign(1.0, a1) a1_m, a2_m, b1_m, b2_m = sort([a1_m, a2_m, b1_m, b2_m]) a1_m, a2_m, b1_m, b2_m = sort([a1_m, a2_m, b1_m, b2_m]) function code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m) return Float64(a1_s * Float64(a2_s * Float64(b1_s * Float64(b2_s * Float64(Float64(a1_m / Float64(b1_m * b2_m)) * a2_m))))) end
b2\_m = abs(b2);
b2\_s = sign(b2) * abs(1.0);
b1\_m = abs(b1);
b1\_s = sign(b1) * abs(1.0);
a2\_m = abs(a2);
a2\_s = sign(a2) * abs(1.0);
a1\_m = abs(a1);
a1\_s = sign(a1) * abs(1.0);
a1_m, a2_m, b1_m, b2_m = num2cell(sort([a1_m, a2_m, b1_m, b2_m])){:}
a1_m, a2_m, b1_m, b2_m = num2cell(sort([a1_m, a2_m, b1_m, b2_m])){:}
function tmp = code(a1_s, a2_s, b1_s, b2_s, a1_m, a2_m, b1_m, b2_m)
tmp = a1_s * (a2_s * (b1_s * (b2_s * ((a1_m / (b1_m * b2_m)) * a2_m))));
end
b2\_m = N[Abs[b2], $MachinePrecision]
b2\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[b2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
b1\_m = N[Abs[b1], $MachinePrecision]
b1\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[b1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a2\_m = N[Abs[a2], $MachinePrecision]
a2\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a2]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
a1\_m = N[Abs[a1], $MachinePrecision]
a1\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a1]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
NOTE: a1_m, a2_m, b1_m, and b2_m should be sorted in increasing order before calling this function.
code[a1$95$s_, a2$95$s_, b1$95$s_, b2$95$s_, a1$95$m_, a2$95$m_, b1$95$m_, b2$95$m_] := N[(a1$95$s * N[(a2$95$s * N[(b1$95$s * N[(b2$95$s * N[(N[(a1$95$m / N[(b1$95$m * b2$95$m), $MachinePrecision]), $MachinePrecision] * a2$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
b2\_m = \left|b2\right|
\\
b2\_s = \mathsf{copysign}\left(1, b2\right)
\\
b1\_m = \left|b1\right|
\\
b1\_s = \mathsf{copysign}\left(1, b1\right)
\\
a2\_m = \left|a2\right|
\\
a2\_s = \mathsf{copysign}\left(1, a2\right)
\\
a1\_m = \left|a1\right|
\\
a1\_s = \mathsf{copysign}\left(1, a1\right)
\\
[a1_m, a2_m, b1_m, b2_m] = \mathsf{sort}([a1_m, a2_m, b1_m, b2_m])\\\\
[a1_m, a2_m, b1_m, b2_m] = \mathsf{sort}([a1_m, a2_m, b1_m, b2_m])\\
\\
a1\_s \cdot \left(a2\_s \cdot \left(b1\_s \cdot \left(b2\_s \cdot \left(\frac{a1\_m}{b1\_m \cdot b2\_m} \cdot a2\_m\right)\right)\right)\right)
\end{array}
Initial program 87.7%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6490.1
Applied rewrites90.1%
lift-/.f64N/A
lift-/.f64N/A
remove-double-negN/A
associate-/r*N/A
*-commutativeN/A
lower-/.f64N/A
lower-*.f64N/A
remove-double-neg88.7
Applied rewrites88.7%
(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 2024332
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:alt
(! :herbie-platform default (* (/ a1 b1) (/ a2 b2)))
(/ (* a1 a2) (* b1 b2)))