
(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 11 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}
(FPCore (x y z t a b) :precision binary64 (if (<= (+ (* a b) (+ (* x y) (* z t))) INFINITY) (fma a b (fma x y (* z t))) (* z (+ t (+ (* x (/ y z)) (* a (/ b z)))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) + ((x * y) + (z * t))) <= ((double) INFINITY)) {
tmp = fma(a, b, fma(x, y, (z * t)));
} else {
tmp = z * (t + ((x * (y / z)) + (a * (b / z))));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))) <= Inf) tmp = fma(a, b, fma(x, y, Float64(z * t))); else tmp = Float64(z * Float64(t + Float64(Float64(x * Float64(y / z)) + Float64(a * Float64(b / z))))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(a * b + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t + N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] + N[(a * N[(b / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b + \left(x \cdot y + z \cdot t\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t + \left(x \cdot \frac{y}{z} + a \cdot \frac{b}{z}\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) < +inf.0Initial program 100.0%
+-commutative100.0%
fma-define100.0%
fma-define100.0%
Simplified100.0%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
Taylor expanded in z around inf 71.4%
+-commutative71.4%
associate-/l*85.7%
associate-/l*100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z t a b) :precision binary64 (fma x y (fma z t (* a b))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(x, y, fma(z, t, (a * b)));
}
function code(x, y, z, t, a, b) return fma(x, y, fma(z, t, Float64(a * b))) end
code[x_, y_, z_, t_, a_, b_] := N[(x * y + N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)
\end{array}
Initial program 97.2%
associate-+l+97.2%
fma-define97.6%
fma-define98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ (* a b) (+ (* x y) (* z t))) INFINITY) (+ (* a b) (fma x y (* z t))) (* z (+ t (+ (* x (/ y z)) (* a (/ b z)))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) + ((x * y) + (z * t))) <= ((double) INFINITY)) {
tmp = (a * b) + fma(x, y, (z * t));
} else {
tmp = z * (t + ((x * (y / z)) + (a * (b / z))));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))) <= Inf) tmp = Float64(Float64(a * b) + fma(x, y, Float64(z * t))); else tmp = Float64(z * Float64(t + Float64(Float64(x * Float64(y / z)) + Float64(a * Float64(b / z))))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(a * b), $MachinePrecision] + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t + N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] + N[(a * N[(b / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b + \left(x \cdot y + z \cdot t\right) \leq \infty:\\
\;\;\;\;a \cdot b + \mathsf{fma}\left(x, y, z \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t + \left(x \cdot \frac{y}{z} + a \cdot \frac{b}{z}\right)\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%
Taylor expanded in z around inf 71.4%
+-commutative71.4%
associate-/l*85.7%
associate-/l*100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* x y) (* z t))) (t_2 (+ (* a b) (* z t))))
(if (<= (* a b) -5.2e+137)
t_2
(if (<= (* a b) -1.85e+88)
t_1
(if (<= (* a b) -3.05e+75)
(* a b)
(if (<= (* a b) -1.05e+32)
(* x y)
(if (<= (* a b) 8e+48) t_1 t_2)))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x * y) + (z * t);
double t_2 = (a * b) + (z * t);
double tmp;
if ((a * b) <= -5.2e+137) {
tmp = t_2;
} else if ((a * b) <= -1.85e+88) {
tmp = t_1;
} else if ((a * b) <= -3.05e+75) {
tmp = a * b;
} else if ((a * b) <= -1.05e+32) {
tmp = x * y;
} else if ((a * b) <= 8e+48) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (x * y) + (z * t)
t_2 = (a * b) + (z * t)
if ((a * b) <= (-5.2d+137)) then
tmp = t_2
else if ((a * b) <= (-1.85d+88)) then
tmp = t_1
else if ((a * b) <= (-3.05d+75)) then
tmp = a * b
else if ((a * b) <= (-1.05d+32)) then
tmp = x * y
else if ((a * b) <= 8d+48) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x * y) + (z * t);
double t_2 = (a * b) + (z * t);
double tmp;
if ((a * b) <= -5.2e+137) {
tmp = t_2;
} else if ((a * b) <= -1.85e+88) {
tmp = t_1;
} else if ((a * b) <= -3.05e+75) {
tmp = a * b;
} else if ((a * b) <= -1.05e+32) {
tmp = x * y;
} else if ((a * b) <= 8e+48) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (x * y) + (z * t) t_2 = (a * b) + (z * t) tmp = 0 if (a * b) <= -5.2e+137: tmp = t_2 elif (a * b) <= -1.85e+88: tmp = t_1 elif (a * b) <= -3.05e+75: tmp = a * b elif (a * b) <= -1.05e+32: tmp = x * y elif (a * b) <= 8e+48: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(x * y) + Float64(z * t)) t_2 = Float64(Float64(a * b) + Float64(z * t)) tmp = 0.0 if (Float64(a * b) <= -5.2e+137) tmp = t_2; elseif (Float64(a * b) <= -1.85e+88) tmp = t_1; elseif (Float64(a * b) <= -3.05e+75) tmp = Float64(a * b); elseif (Float64(a * b) <= -1.05e+32) tmp = Float64(x * y); elseif (Float64(a * b) <= 8e+48) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (x * y) + (z * t); t_2 = (a * b) + (z * t); tmp = 0.0; if ((a * b) <= -5.2e+137) tmp = t_2; elseif ((a * b) <= -1.85e+88) tmp = t_1; elseif ((a * b) <= -3.05e+75) tmp = a * b; elseif ((a * b) <= -1.05e+32) tmp = x * y; elseif ((a * b) <= 8e+48) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -5.2e+137], t$95$2, If[LessEqual[N[(a * b), $MachinePrecision], -1.85e+88], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], -3.05e+75], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -1.05e+32], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 8e+48], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
t_2 := a \cdot b + z \cdot t\\
\mathbf{if}\;a \cdot b \leq -5.2 \cdot 10^{+137}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;a \cdot b \leq -1.85 \cdot 10^{+88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq -3.05 \cdot 10^{+75}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -1.05 \cdot 10^{+32}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 8 \cdot 10^{+48}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 a b) < -5.1999999999999998e137 or 8.00000000000000035e48 < (*.f64 a b) Initial program 94.5%
Taylor expanded in x around 0 89.0%
if -5.1999999999999998e137 < (*.f64 a b) < -1.84999999999999997e88 or -1.05e32 < (*.f64 a b) < 8.00000000000000035e48Initial program 100.0%
Taylor expanded in b around inf 79.5%
Taylor expanded in a around 0 74.6%
Taylor expanded in b around 0 95.1%
if -1.84999999999999997e88 < (*.f64 a b) < -3.05000000000000005e75Initial program 100.0%
Taylor expanded in a around inf 100.0%
if -3.05000000000000005e75 < (*.f64 a b) < -1.05e32Initial program 71.4%
Taylor expanded in b around inf 71.2%
Taylor expanded in a around 0 71.2%
Taylor expanded in t around 0 85.8%
Final simplification92.7%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* a b) -3e+145)
(* a b)
(if (<= (* a b) -5e-316)
(* x y)
(if (<= (* a b) 3.2e-307)
(* z t)
(if (<= (* a b) 7.5e-205)
(* x y)
(if (<= (* a b) 4.2e+63) (* z t) (* a b)))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -3e+145) {
tmp = a * b;
} else if ((a * b) <= -5e-316) {
tmp = x * y;
} else if ((a * b) <= 3.2e-307) {
tmp = z * t;
} else if ((a * b) <= 7.5e-205) {
tmp = x * y;
} else if ((a * b) <= 4.2e+63) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
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) <= (-3d+145)) then
tmp = a * b
else if ((a * b) <= (-5d-316)) then
tmp = x * y
else if ((a * b) <= 3.2d-307) then
tmp = z * t
else if ((a * b) <= 7.5d-205) then
tmp = x * y
else if ((a * b) <= 4.2d+63) then
tmp = z * t
else
tmp = a * b
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -3e+145) {
tmp = a * b;
} else if ((a * b) <= -5e-316) {
tmp = x * y;
} else if ((a * b) <= 3.2e-307) {
tmp = z * t;
} else if ((a * b) <= 7.5e-205) {
tmp = x * y;
} else if ((a * b) <= 4.2e+63) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -3e+145: tmp = a * b elif (a * b) <= -5e-316: tmp = x * y elif (a * b) <= 3.2e-307: tmp = z * t elif (a * b) <= 7.5e-205: tmp = x * y elif (a * b) <= 4.2e+63: tmp = z * t else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -3e+145) tmp = Float64(a * b); elseif (Float64(a * b) <= -5e-316) tmp = Float64(x * y); elseif (Float64(a * b) <= 3.2e-307) tmp = Float64(z * t); elseif (Float64(a * b) <= 7.5e-205) tmp = Float64(x * y); elseif (Float64(a * b) <= 4.2e+63) tmp = Float64(z * t); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((a * b) <= -3e+145) tmp = a * b; elseif ((a * b) <= -5e-316) tmp = x * y; elseif ((a * b) <= 3.2e-307) tmp = z * t; elseif ((a * b) <= 7.5e-205) tmp = x * y; elseif ((a * b) <= 4.2e+63) tmp = z * t; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -3e+145], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -5e-316], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 3.2e-307], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 7.5e-205], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4.2e+63], N[(z * t), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -3 \cdot 10^{+145}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-316}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 3.2 \cdot 10^{-307}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 7.5 \cdot 10^{-205}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 4.2 \cdot 10^{+63}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -3.0000000000000002e145 or 4.2000000000000004e63 < (*.f64 a b) Initial program 94.2%
Taylor expanded in a around inf 78.3%
if -3.0000000000000002e145 < (*.f64 a b) < -5.000000017e-316 or 3.20000000000000011e-307 < (*.f64 a b) < 7.4999999999999996e-205Initial program 97.7%
Taylor expanded in b around inf 85.9%
Taylor expanded in a around 0 75.3%
Taylor expanded in t around 0 58.1%
if -5.000000017e-316 < (*.f64 a b) < 3.20000000000000011e-307 or 7.4999999999999996e-205 < (*.f64 a b) < 4.2000000000000004e63Initial program 100.0%
Taylor expanded in b around inf 73.0%
Taylor expanded in a around 0 69.3%
Taylor expanded in t around inf 66.4%
Final simplification67.6%
(FPCore (x y z t a b)
:precision binary64
(if (or (<= (* x y) -5e+152)
(and (not (<= (* x y) 1.05e+119))
(or (<= (* x y) 5.6e+184) (not (<= (* x y) 7.7e+245)))))
(* x y)
(+ (* a b) (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((x * y) <= -5e+152) || (!((x * y) <= 1.05e+119) && (((x * y) <= 5.6e+184) || !((x * y) <= 7.7e+245)))) {
tmp = x * y;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
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+152)) .or. (.not. ((x * y) <= 1.05d+119)) .and. ((x * y) <= 5.6d+184) .or. (.not. ((x * y) <= 7.7d+245))) then
tmp = x * y
else
tmp = (a * b) + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((x * y) <= -5e+152) || (!((x * y) <= 1.05e+119) && (((x * y) <= 5.6e+184) || !((x * y) <= 7.7e+245)))) {
tmp = x * y;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -5e+152) or (not ((x * y) <= 1.05e+119) and (((x * y) <= 5.6e+184) or not ((x * y) <= 7.7e+245))): tmp = x * y else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(x * y) <= -5e+152) || (!(Float64(x * y) <= 1.05e+119) && ((Float64(x * y) <= 5.6e+184) || !(Float64(x * y) <= 7.7e+245)))) tmp = Float64(x * y); else tmp = Float64(Float64(a * b) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (((x * y) <= -5e+152) || (~(((x * y) <= 1.05e+119)) && (((x * y) <= 5.6e+184) || ~(((x * y) <= 7.7e+245))))) tmp = x * y; else tmp = (a * b) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -5e+152], And[N[Not[LessEqual[N[(x * y), $MachinePrecision], 1.05e+119]], $MachinePrecision], Or[LessEqual[N[(x * y), $MachinePrecision], 5.6e+184], N[Not[LessEqual[N[(x * y), $MachinePrecision], 7.7e+245]], $MachinePrecision]]]], N[(x * y), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+152} \lor \neg \left(x \cdot y \leq 1.05 \cdot 10^{+119}\right) \land \left(x \cdot y \leq 5.6 \cdot 10^{+184} \lor \neg \left(x \cdot y \leq 7.7 \cdot 10^{+245}\right)\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -5e152 or 1.04999999999999991e119 < (*.f64 x y) < 5.5999999999999998e184 or 7.6999999999999998e245 < (*.f64 x y) Initial program 93.7%
Taylor expanded in b around inf 74.4%
Taylor expanded in a around 0 70.5%
Taylor expanded in t around 0 86.1%
if -5e152 < (*.f64 x y) < 1.04999999999999991e119 or 5.5999999999999998e184 < (*.f64 x y) < 7.6999999999999998e245Initial program 98.8%
Taylor expanded in x around 0 88.0%
Final simplification87.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* x y) (* z t))) (t_2 (+ (* a b) (* z t))))
(if (<= (* a b) -4.5e+137)
t_2
(if (<= (* a b) -2.7e+92)
t_1
(if (<= (* a b) -1.4e+20)
(+ (* a b) (* x y))
(if (<= (* a b) 9e+48) t_1 t_2))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x * y) + (z * t);
double t_2 = (a * b) + (z * t);
double tmp;
if ((a * b) <= -4.5e+137) {
tmp = t_2;
} else if ((a * b) <= -2.7e+92) {
tmp = t_1;
} else if ((a * b) <= -1.4e+20) {
tmp = (a * b) + (x * y);
} else if ((a * b) <= 9e+48) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (x * y) + (z * t)
t_2 = (a * b) + (z * t)
if ((a * b) <= (-4.5d+137)) then
tmp = t_2
else if ((a * b) <= (-2.7d+92)) then
tmp = t_1
else if ((a * b) <= (-1.4d+20)) then
tmp = (a * b) + (x * y)
else if ((a * b) <= 9d+48) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x * y) + (z * t);
double t_2 = (a * b) + (z * t);
double tmp;
if ((a * b) <= -4.5e+137) {
tmp = t_2;
} else if ((a * b) <= -2.7e+92) {
tmp = t_1;
} else if ((a * b) <= -1.4e+20) {
tmp = (a * b) + (x * y);
} else if ((a * b) <= 9e+48) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (x * y) + (z * t) t_2 = (a * b) + (z * t) tmp = 0 if (a * b) <= -4.5e+137: tmp = t_2 elif (a * b) <= -2.7e+92: tmp = t_1 elif (a * b) <= -1.4e+20: tmp = (a * b) + (x * y) elif (a * b) <= 9e+48: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(x * y) + Float64(z * t)) t_2 = Float64(Float64(a * b) + Float64(z * t)) tmp = 0.0 if (Float64(a * b) <= -4.5e+137) tmp = t_2; elseif (Float64(a * b) <= -2.7e+92) tmp = t_1; elseif (Float64(a * b) <= -1.4e+20) tmp = Float64(Float64(a * b) + Float64(x * y)); elseif (Float64(a * b) <= 9e+48) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (x * y) + (z * t); t_2 = (a * b) + (z * t); tmp = 0.0; if ((a * b) <= -4.5e+137) tmp = t_2; elseif ((a * b) <= -2.7e+92) tmp = t_1; elseif ((a * b) <= -1.4e+20) tmp = (a * b) + (x * y); elseif ((a * b) <= 9e+48) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -4.5e+137], t$95$2, If[LessEqual[N[(a * b), $MachinePrecision], -2.7e+92], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], -1.4e+20], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 9e+48], t$95$1, t$95$2]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
t_2 := a \cdot b + z \cdot t\\
\mathbf{if}\;a \cdot b \leq -4.5 \cdot 10^{+137}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;a \cdot b \leq -2.7 \cdot 10^{+92}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \cdot b \leq -1.4 \cdot 10^{+20}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 9 \cdot 10^{+48}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (*.f64 a b) < -4.5000000000000001e137 or 8.99999999999999991e48 < (*.f64 a b) Initial program 94.5%
Taylor expanded in x around 0 89.0%
if -4.5000000000000001e137 < (*.f64 a b) < -2.6999999999999999e92 or -1.4e20 < (*.f64 a b) < 8.99999999999999991e48Initial program 100.0%
Taylor expanded in b around inf 79.9%
Taylor expanded in a around 0 75.6%
Taylor expanded in b around 0 95.7%
if -2.6999999999999999e92 < (*.f64 a b) < -1.4e20Initial program 84.6%
Taylor expanded in x around inf 85.0%
Final simplification92.8%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (* a b) (+ (* x y) (* z t))))) (if (<= t_1 INFINITY) t_1 (* z (+ t (+ (* x (/ y z)) (* a (/ b z))))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((x * y) + (z * t));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = z * (t + ((x * (y / z)) + (a * (b / z))));
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((x * y) + (z * t));
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = z * (t + ((x * (y / z)) + (a * (b / z))));
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a * b) + ((x * y) + (z * t)) tmp = 0 if t_1 <= math.inf: tmp = t_1 else: tmp = z * (t + ((x * (y / z)) + (a * (b / z)))) return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = Float64(z * Float64(t + Float64(Float64(x * Float64(y / z)) + Float64(a * Float64(b / z))))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a * b) + ((x * y) + (z * t)); tmp = 0.0; if (t_1 <= Inf) tmp = t_1; else tmp = z * (t + ((x * (y / z)) + (a * (b / z)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(z * N[(t + N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] + N[(a * N[(b / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + \left(x \cdot y + z \cdot t\right)\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t + \left(x \cdot \frac{y}{z} + a \cdot \frac{b}{z}\right)\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%
Taylor expanded in z around inf 71.4%
+-commutative71.4%
associate-/l*85.7%
associate-/l*100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (* a b) (+ (* x y) (* z t))))) (if (<= t_1 INFINITY) t_1 (* z (+ t (* y (/ x z)))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((x * y) + (z * t));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = z * (t + (y * (x / z)));
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((x * y) + (z * t));
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = z * (t + (y * (x / z)));
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a * b) + ((x * y) + (z * t)) tmp = 0 if t_1 <= math.inf: tmp = t_1 else: tmp = z * (t + (y * (x / z))) return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = Float64(z * Float64(t + Float64(y * Float64(x / z)))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a * b) + ((x * y) + (z * t)); tmp = 0.0; if (t_1 <= Inf) tmp = t_1; else tmp = z * (t + (y * (x / z))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(z * N[(t + N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + \left(x \cdot y + z \cdot t\right)\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t + y \cdot \frac{x}{z}\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%
Taylor expanded in z around inf 42.9%
Taylor expanded in a around 0 57.1%
clear-num57.1%
inv-pow57.1%
Applied egg-rr57.1%
unpow-157.1%
associate-/r*71.4%
Simplified71.4%
associate-/r/71.4%
clear-num71.4%
Applied egg-rr71.4%
Final simplification99.2%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -3.5e+123) (not (<= (* a b) 1.9e+63))) (* a b) (* z t)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -3.5e+123) || !((a * b) <= 1.9e+63)) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
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) <= (-3.5d+123)) .or. (.not. ((a * b) <= 1.9d+63))) then
tmp = a * b
else
tmp = z * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -3.5e+123) || !((a * b) <= 1.9e+63)) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -3.5e+123) or not ((a * b) <= 1.9e+63): tmp = a * b else: tmp = z * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -3.5e+123) || !(Float64(a * b) <= 1.9e+63)) tmp = Float64(a * b); else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (((a * b) <= -3.5e+123) || ~(((a * b) <= 1.9e+63))) tmp = a * b; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -3.5e+123], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1.9e+63]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -3.5 \cdot 10^{+123} \lor \neg \left(a \cdot b \leq 1.9 \cdot 10^{+63}\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -3.5e123 or 1.9000000000000001e63 < (*.f64 a b) Initial program 94.4%
Taylor expanded in a around inf 76.8%
if -3.5e123 < (*.f64 a b) < 1.9000000000000001e63Initial program 98.8%
Taylor expanded in b around inf 79.3%
Taylor expanded in a around 0 72.5%
Taylor expanded in t around inf 49.2%
Final simplification58.8%
(FPCore (x y z t a b) :precision binary64 (* a b))
double code(double x, double y, double z, double t, double a, double b) {
return 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 = a * b
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return a * b;
}
def code(x, y, z, t, a, b): return a * b
function code(x, y, z, t, a, b) return Float64(a * b) end
function tmp = code(x, y, z, t, a, b) tmp = a * b; end
code[x_, y_, z_, t_, a_, b_] := N[(a * b), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b
\end{array}
Initial program 97.2%
Taylor expanded in a around inf 31.8%
Final simplification31.8%
herbie shell --seed 2024077
(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)))