
(FPCore (x y z t a b) :precision binary64 (+ (+ (* x y) (* z t)) (* a b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * b);
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x * y) + (z * t)) + (a * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * b);
}
def code(x, y, z, t, a, b): return ((x * y) + (z * t)) + (a * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * t)) + (a * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y + z \cdot t\right) + a \cdot b
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (+ (+ (* x y) (* z t)) (* a b)))
double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * b);
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((x * y) + (z * t)) + (a * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * t)) + (a * b);
}
def code(x, y, z, t, a, b): return ((x * y) + (z * t)) + (a * b)
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * t)) + (a * b); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot y + z \cdot t\right) + a \cdot b
\end{array}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (if (<= (+ (+ (* x y) (* z t)) (* a b)) INFINITY) (+ (fma x y (* z t)) (* a b)) (* a (+ (+ b (* t (/ z a))) (* x (/ y a))))))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((((x * y) + (z * t)) + (a * b)) <= ((double) INFINITY)) {
tmp = fma(x, y, (z * t)) + (a * b);
} else {
tmp = a * ((b + (t * (z / a))) + (x * (y / a)));
}
return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) <= Inf) tmp = Float64(fma(x, y, Float64(z * t)) + Float64(a * b)); else tmp = Float64(a * Float64(Float64(b + Float64(t * Float64(z / a))) + Float64(x * Float64(y / a)))); end return tmp end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], N[(a * N[(N[(b + N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;\left(x \cdot y + z \cdot t\right) + a \cdot b \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(x, y, z \cdot t\right) + a \cdot b\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(\left(b + t \cdot \frac{z}{a}\right) + x \cdot \frac{y}{a}\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) < +inf.0Initial program 100.0%
fma-define100.0%
Simplified100.0%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
fma-define16.7%
Simplified16.7%
Taylor expanded in a around inf 66.7%
associate-+r+66.7%
associate-/l*66.7%
associate-/l*66.7%
Simplified66.7%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (fma a b (fma x y (* z t))))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
return fma(a, b, fma(x, y, (z * t)));
}
x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) return fma(a, b, fma(x, y, Float64(z * t))) end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := N[(a * b + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\mathsf{fma}\left(a, b, \mathsf{fma}\left(x, y, z \cdot t\right)\right)
\end{array}
Initial program 97.6%
+-commutative97.6%
fma-define99.2%
fma-define99.6%
Simplified99.6%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
:precision binary64
(if (<= (* x y) -2e+157)
(* x y)
(if (<= (* x y) -2e-125)
(* a b)
(if (<= (* x y) 4e-21) (* z t) (if (<= (* x y) 5e+79) (* a b) (* x y))))))assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -2e+157) {
tmp = x * y;
} else if ((x * y) <= -2e-125) {
tmp = a * b;
} else if ((x * y) <= 4e-21) {
tmp = z * t;
} else if ((x * y) <= 5e+79) {
tmp = a * b;
} else {
tmp = x * y;
}
return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((x * y) <= (-2d+157)) then
tmp = x * y
else if ((x * y) <= (-2d-125)) then
tmp = a * b
else if ((x * y) <= 4d-21) then
tmp = z * t
else if ((x * y) <= 5d+79) then
tmp = a * b
else
tmp = x * y
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -2e+157) {
tmp = x * y;
} else if ((x * y) <= -2e-125) {
tmp = a * b;
} else if ((x * y) <= 4e-21) {
tmp = z * t;
} else if ((x * y) <= 5e+79) {
tmp = a * b;
} else {
tmp = x * y;
}
return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b]) def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -2e+157: tmp = x * y elif (x * y) <= -2e-125: tmp = a * b elif (x * y) <= 4e-21: tmp = z * t elif (x * y) <= 5e+79: tmp = a * b else: tmp = x * y return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -2e+157) tmp = Float64(x * y); elseif (Float64(x * y) <= -2e-125) tmp = Float64(a * b); elseif (Float64(x * y) <= 4e-21) tmp = Float64(z * t); elseif (Float64(x * y) <= 5e+79) tmp = Float64(a * b); else tmp = Float64(x * y); end return tmp end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
tmp = 0.0;
if ((x * y) <= -2e+157)
tmp = x * y;
elseif ((x * y) <= -2e-125)
tmp = a * b;
elseif ((x * y) <= 4e-21)
tmp = z * t;
elseif ((x * y) <= 5e+79)
tmp = a * b;
else
tmp = x * y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -2e+157], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -2e-125], N[(a * b), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 4e-21], N[(z * t), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e+79], N[(a * b), $MachinePrecision], N[(x * y), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+157}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq -2 \cdot 10^{-125}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{-21}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{+79}:\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -1.99999999999999997e157 or 5e79 < (*.f64 x y) Initial program 94.0%
Taylor expanded in x around inf 83.4%
Taylor expanded in a around inf 77.1%
associate-/l*76.3%
Simplified76.3%
Taylor expanded in a around 0 77.9%
if -1.99999999999999997e157 < (*.f64 x y) < -2.00000000000000002e-125 or 3.99999999999999963e-21 < (*.f64 x y) < 5e79Initial program 100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in a around inf 54.2%
if -2.00000000000000002e-125 < (*.f64 x y) < 3.99999999999999963e-21Initial program 99.0%
fma-define99.0%
Simplified99.0%
Taylor expanded in x around 0 87.4%
Taylor expanded in t around inf 81.9%
associate-/l*77.3%
Simplified77.3%
Taylor expanded in t around inf 53.8%
Final simplification61.8%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (+ (* x y) (* z t)) (* a b)))) (if (<= t_1 INFINITY) t_1 (* a (+ (+ b (* t (/ z a))) (* x (/ y a)))))))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x * y) + (z * t)) + (a * b);
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = a * ((b + (t * (z / a))) + (x * (y / a)));
}
return tmp;
}
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x * y) + (z * t)) + (a * b);
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = a * ((b + (t * (z / a))) + (x * (y / a)));
}
return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b]) def code(x, y, z, t, a, b): t_1 = ((x * y) + (z * t)) + (a * b) tmp = 0 if t_1 <= math.inf: tmp = t_1 else: tmp = a * ((b + (t * (z / a))) + (x * (y / a))) return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = Float64(a * Float64(Float64(b + Float64(t * Float64(z / a))) + Float64(x * Float64(y / a)))); end return tmp end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
t_1 = ((x * y) + (z * t)) + (a * b);
tmp = 0.0;
if (t_1 <= Inf)
tmp = t_1;
else
tmp = a * ((b + (t * (z / a))) + (x * (y / a)));
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(a * N[(N[(b + N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \left(x \cdot y + z \cdot t\right) + a \cdot b\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(\left(b + t \cdot \frac{z}{a}\right) + x \cdot \frac{y}{a}\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) < +inf.0Initial program 100.0%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
fma-define16.7%
Simplified16.7%
Taylor expanded in a around inf 66.7%
associate-+r+66.7%
associate-/l*66.7%
associate-/l*66.7%
Simplified66.7%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (+ (* x y) (* z t)) (* a b)))) (if (<= t_1 INFINITY) t_1 (* x y))))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x * y) + (z * t)) + (a * b);
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = x * y;
}
return tmp;
}
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = ((x * y) + (z * t)) + (a * b);
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = x * y;
}
return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b]) def code(x, y, z, t, a, b): t_1 = ((x * y) + (z * t)) + (a * b) tmp = 0 if t_1 <= math.inf: tmp = t_1 else: tmp = x * y return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) t_1 = Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = Float64(x * y); end return tmp end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
t_1 = ((x * y) + (z * t)) + (a * b);
tmp = 0.0;
if (t_1 <= Inf)
tmp = t_1;
else
tmp = x * y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(x * y), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \left(x \cdot y + z \cdot t\right) + a \cdot b\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) < +inf.0Initial program 100.0%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
Taylor expanded in x around inf 16.7%
Taylor expanded in a around inf 66.7%
associate-/l*66.7%
Simplified66.7%
Taylor expanded in a around 0 67.1%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (if (or (<= (* x y) -5e+24) (not (<= (* x y) 5e+80))) (+ (* x y) (* a b)) (+ (* a b) (* z t))))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((x * y) <= -5e+24) || !((x * y) <= 5e+80)) {
tmp = (x * y) + (a * b);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (((x * y) <= (-5d+24)) .or. (.not. ((x * y) <= 5d+80))) then
tmp = (x * y) + (a * b)
else
tmp = (a * b) + (z * t)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((x * y) <= -5e+24) || !((x * y) <= 5e+80)) {
tmp = (x * y) + (a * b);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b]) def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -5e+24) or not ((x * y) <= 5e+80): tmp = (x * y) + (a * b) else: tmp = (a * b) + (z * t) return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(x * y) <= -5e+24) || !(Float64(x * y) <= 5e+80)) tmp = Float64(Float64(x * y) + Float64(a * b)); else tmp = Float64(Float64(a * b) + Float64(z * t)); end return tmp end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
tmp = 0.0;
if (((x * y) <= -5e+24) || ~(((x * y) <= 5e+80)))
tmp = (x * y) + (a * b);
else
tmp = (a * b) + (z * t);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -5e+24], N[Not[LessEqual[N[(x * y), $MachinePrecision], 5e+80]], $MachinePrecision]], N[(N[(x * y), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+24} \lor \neg \left(x \cdot y \leq 5 \cdot 10^{+80}\right):\\
\;\;\;\;x \cdot y + a \cdot b\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -5.00000000000000045e24 or 4.99999999999999961e80 < (*.f64 x y) Initial program 95.1%
Taylor expanded in x around inf 84.7%
if -5.00000000000000045e24 < (*.f64 x y) < 4.99999999999999961e80Initial program 99.3%
fma-define99.3%
Simplified99.3%
Taylor expanded in x around 0 86.3%
Final simplification85.7%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (if (or (<= (* x y) -1e+170) (not (<= (* x y) 5e+80))) (* x y) (+ (* a b) (* z t))))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((x * y) <= -1e+170) || !((x * y) <= 5e+80)) {
tmp = x * y;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (((x * y) <= (-1d+170)) .or. (.not. ((x * y) <= 5d+80))) then
tmp = x * y
else
tmp = (a * b) + (z * t)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((x * y) <= -1e+170) || !((x * y) <= 5e+80)) {
tmp = x * y;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b]) def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -1e+170) or not ((x * y) <= 5e+80): tmp = x * y else: tmp = (a * b) + (z * t) return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(x * y) <= -1e+170) || !(Float64(x * y) <= 5e+80)) tmp = Float64(x * y); else tmp = Float64(Float64(a * b) + Float64(z * t)); end return tmp end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
tmp = 0.0;
if (((x * y) <= -1e+170) || ~(((x * y) <= 5e+80)))
tmp = x * y;
else
tmp = (a * b) + (z * t);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -1e+170], N[Not[LessEqual[N[(x * y), $MachinePrecision], 5e+80]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+170} \lor \neg \left(x \cdot y \leq 5 \cdot 10^{+80}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -1.00000000000000003e170 or 4.99999999999999961e80 < (*.f64 x y) Initial program 93.5%
Taylor expanded in x around inf 85.9%
Taylor expanded in a around inf 79.2%
associate-/l*78.2%
Simplified78.2%
Taylor expanded in a around 0 81.2%
if -1.00000000000000003e170 < (*.f64 x y) < 4.99999999999999961e80Initial program 99.4%
fma-define99.4%
Simplified99.4%
Taylor expanded in x around 0 82.9%
Final simplification82.4%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -5.9e+147) (not (<= (* a b) 1.05e+49))) (* a b) (* z t)))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -5.9e+147) || !((a * b) <= 1.05e+49)) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (((a * b) <= (-5.9d+147)) .or. (.not. ((a * b) <= 1.05d+49))) then
tmp = a * b
else
tmp = z * t
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -5.9e+147) || !((a * b) <= 1.05e+49)) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b]) def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -5.9e+147) or not ((a * b) <= 1.05e+49): tmp = a * b else: tmp = z * t return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -5.9e+147) || !(Float64(a * b) <= 1.05e+49)) tmp = Float64(a * b); else tmp = Float64(z * t); end return tmp end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
tmp = 0.0;
if (((a * b) <= -5.9e+147) || ~(((a * b) <= 1.05e+49)))
tmp = a * b;
else
tmp = z * t;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -5.9e+147], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1.05e+49]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5.9 \cdot 10^{+147} \lor \neg \left(a \cdot b \leq 1.05 \cdot 10^{+49}\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -5.9000000000000001e147 or 1.05000000000000005e49 < (*.f64 a b) Initial program 94.6%
fma-define94.6%
Simplified94.6%
Taylor expanded in a around inf 68.8%
if -5.9000000000000001e147 < (*.f64 a b) < 1.05000000000000005e49Initial program 99.3%
fma-define100.0%
Simplified100.0%
Taylor expanded in x around 0 53.7%
Taylor expanded in t around inf 52.4%
associate-/l*48.3%
Simplified48.3%
Taylor expanded in t around inf 42.0%
Final simplification51.7%
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. (FPCore (x y z t a b) :precision binary64 (* a b))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
return a * b;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = a * b
end function
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
return a * b;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b]) def code(x, y, z, t, a, b): return a * b
x, y, z, t, a, b = sort([x, y, z, t, a, b]) function code(x, y, z, t, a, b) return Float64(a * b) end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp = code(x, y, z, t, a, b)
tmp = a * b;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_] := N[(a * b), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
a \cdot b
\end{array}
Initial program 97.6%
fma-define98.0%
Simplified98.0%
Taylor expanded in a around inf 34.1%
herbie shell --seed 2024144
(FPCore (x y z t a b)
:name "Linear.V3:$cdot from linear-1.19.1.3, B"
:precision binary64
(+ (+ (* x y) (* z t)) (* a b)))