
(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 (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 95.3%
associate-+l+95.3%
fma-def97.6%
fma-def98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ (* a b) (+ (* z t) (* x y))) INFINITY) (+ (* a b) (fma x y (* z t))) (fma z t (* a b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) + ((z * t) + (x * y))) <= ((double) INFINITY)) {
tmp = (a * b) + fma(x, y, (z * t));
} else {
tmp = fma(z, t, (a * b));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(a * b) + Float64(Float64(z * t) + Float64(x * y))) <= Inf) tmp = Float64(Float64(a * b) + fma(x, y, Float64(z * t))); else tmp = fma(z, t, Float64(a * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(a * b), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(a * b), $MachinePrecision] + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b + \left(z \cdot t + x \cdot y\right) \leq \infty:\\
\;\;\;\;a \cdot b + \mathsf{fma}\left(x, y, z \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t, a \cdot b\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) < +inf.0Initial program 100.0%
fma-def100.0%
Simplified100.0%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
Taylor expanded in x around 0 50.0%
+-commutative50.0%
*-commutative50.0%
fma-def66.7%
Applied egg-rr66.7%
Final simplification98.4%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (* a b) (+ (* z t) (* x y))))) (if (<= t_1 INFINITY) t_1 (fma z t (* a b)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((z * t) + (x * y));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma(z, t, (a * b));
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(Float64(z * t) + Float64(x * y))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = fma(z, t, Float64(a * b)); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + \left(z \cdot t + x \cdot y\right)\\
\mathbf{if}\;t_1 \leq \infty:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t, a \cdot b\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 x around 0 50.0%
+-commutative50.0%
*-commutative50.0%
fma-def66.7%
Applied egg-rr66.7%
Final simplification98.4%
(FPCore (x y z t a b) :precision binary64 (fma z t (+ (* a b) (* x y))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(z, t, ((a * b) + (x * y)));
}
function code(x, y, z, t, a, b) return fma(z, t, Float64(Float64(a * b) + Float64(x * y))) end
code[x_, y_, z_, t_, a_, b_] := N[(z * t + N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, t, a \cdot b + x \cdot y\right)
\end{array}
Initial program 95.3%
+-commutative95.3%
associate-+l+95.3%
fma-def96.9%
fma-def97.7%
Applied egg-rr97.7%
fma-udef96.9%
Applied egg-rr96.9%
Final simplification96.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* a b) (* z t))) (t_2 (+ (* z t) (* x y))))
(if (<= (* z t) -1e+206)
t_2
(if (<= (* z t) -20000.0)
t_1
(if (<= (* z t) -2e-110)
t_2
(if (<= (* z t) 2e-13)
(+ (* a b) (* x y))
(if (<= (* z t) 2.6e+129) t_2 t_1)))))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + (z * t);
double t_2 = (z * t) + (x * y);
double tmp;
if ((z * t) <= -1e+206) {
tmp = t_2;
} else if ((z * t) <= -20000.0) {
tmp = t_1;
} else if ((z * t) <= -2e-110) {
tmp = t_2;
} else if ((z * t) <= 2e-13) {
tmp = (a * b) + (x * y);
} else if ((z * t) <= 2.6e+129) {
tmp = t_2;
} else {
tmp = t_1;
}
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 = (a * b) + (z * t)
t_2 = (z * t) + (x * y)
if ((z * t) <= (-1d+206)) then
tmp = t_2
else if ((z * t) <= (-20000.0d0)) then
tmp = t_1
else if ((z * t) <= (-2d-110)) then
tmp = t_2
else if ((z * t) <= 2d-13) then
tmp = (a * b) + (x * y)
else if ((z * t) <= 2.6d+129) then
tmp = t_2
else
tmp = t_1
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 = (a * b) + (z * t);
double t_2 = (z * t) + (x * y);
double tmp;
if ((z * t) <= -1e+206) {
tmp = t_2;
} else if ((z * t) <= -20000.0) {
tmp = t_1;
} else if ((z * t) <= -2e-110) {
tmp = t_2;
} else if ((z * t) <= 2e-13) {
tmp = (a * b) + (x * y);
} else if ((z * t) <= 2.6e+129) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a * b) + (z * t) t_2 = (z * t) + (x * y) tmp = 0 if (z * t) <= -1e+206: tmp = t_2 elif (z * t) <= -20000.0: tmp = t_1 elif (z * t) <= -2e-110: tmp = t_2 elif (z * t) <= 2e-13: tmp = (a * b) + (x * y) elif (z * t) <= 2.6e+129: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(z * t)) t_2 = Float64(Float64(z * t) + Float64(x * y)) tmp = 0.0 if (Float64(z * t) <= -1e+206) tmp = t_2; elseif (Float64(z * t) <= -20000.0) tmp = t_1; elseif (Float64(z * t) <= -2e-110) tmp = t_2; elseif (Float64(z * t) <= 2e-13) tmp = Float64(Float64(a * b) + Float64(x * y)); elseif (Float64(z * t) <= 2.6e+129) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a * b) + (z * t); t_2 = (z * t) + (x * y); tmp = 0.0; if ((z * t) <= -1e+206) tmp = t_2; elseif ((z * t) <= -20000.0) tmp = t_1; elseif ((z * t) <= -2e-110) tmp = t_2; elseif ((z * t) <= 2e-13) tmp = (a * b) + (x * y); elseif ((z * t) <= 2.6e+129) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -1e+206], t$95$2, If[LessEqual[N[(z * t), $MachinePrecision], -20000.0], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], -2e-110], t$95$2, If[LessEqual[N[(z * t), $MachinePrecision], 2e-13], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2.6e+129], t$95$2, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + z \cdot t\\
t_2 := z \cdot t + x \cdot y\\
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+206}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \cdot t \leq -20000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \cdot t \leq -2 \cdot 10^{-110}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{-13}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{elif}\;z \cdot t \leq 2.6 \cdot 10^{+129}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (*.f64 z t) < -1e206 or -2e4 < (*.f64 z t) < -2.0000000000000001e-110 or 2.0000000000000001e-13 < (*.f64 z t) < 2.60000000000000012e129Initial program 94.3%
Taylor expanded in a around 0 88.4%
if -1e206 < (*.f64 z t) < -2e4 or 2.60000000000000012e129 < (*.f64 z t) Initial program 91.3%
Taylor expanded in x around 0 89.1%
if -2.0000000000000001e-110 < (*.f64 z t) < 2.0000000000000001e-13Initial program 99.0%
Taylor expanded in z around 0 96.6%
Final simplification91.9%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* a b) -1.1e+141)
(* a b)
(if (<= (* a b) -3.35e+117)
(* x y)
(if (<= (* a b) -2.2e+77)
(* a b)
(if (<= (* a b) 3.1e-148)
(* z t)
(if (<= (* a b) 8.8e+129) (* x y) (* a b)))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -1.1e+141) {
tmp = a * b;
} else if ((a * b) <= -3.35e+117) {
tmp = x * y;
} else if ((a * b) <= -2.2e+77) {
tmp = a * b;
} else if ((a * b) <= 3.1e-148) {
tmp = z * t;
} else if ((a * b) <= 8.8e+129) {
tmp = x * y;
} 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) <= (-1.1d+141)) then
tmp = a * b
else if ((a * b) <= (-3.35d+117)) then
tmp = x * y
else if ((a * b) <= (-2.2d+77)) then
tmp = a * b
else if ((a * b) <= 3.1d-148) then
tmp = z * t
else if ((a * b) <= 8.8d+129) then
tmp = x * y
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) <= -1.1e+141) {
tmp = a * b;
} else if ((a * b) <= -3.35e+117) {
tmp = x * y;
} else if ((a * b) <= -2.2e+77) {
tmp = a * b;
} else if ((a * b) <= 3.1e-148) {
tmp = z * t;
} else if ((a * b) <= 8.8e+129) {
tmp = x * y;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -1.1e+141: tmp = a * b elif (a * b) <= -3.35e+117: tmp = x * y elif (a * b) <= -2.2e+77: tmp = a * b elif (a * b) <= 3.1e-148: tmp = z * t elif (a * b) <= 8.8e+129: tmp = x * y else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -1.1e+141) tmp = Float64(a * b); elseif (Float64(a * b) <= -3.35e+117) tmp = Float64(x * y); elseif (Float64(a * b) <= -2.2e+77) tmp = Float64(a * b); elseif (Float64(a * b) <= 3.1e-148) tmp = Float64(z * t); elseif (Float64(a * b) <= 8.8e+129) tmp = Float64(x * y); 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) <= -1.1e+141) tmp = a * b; elseif ((a * b) <= -3.35e+117) tmp = x * y; elseif ((a * b) <= -2.2e+77) tmp = a * b; elseif ((a * b) <= 3.1e-148) tmp = z * t; elseif ((a * b) <= 8.8e+129) tmp = x * y; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -1.1e+141], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -3.35e+117], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -2.2e+77], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 3.1e-148], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 8.8e+129], N[(x * y), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.1 \cdot 10^{+141}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -3.35 \cdot 10^{+117}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq -2.2 \cdot 10^{+77}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 3.1 \cdot 10^{-148}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 8.8 \cdot 10^{+129}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -1.1e141 or -3.3499999999999999e117 < (*.f64 a b) < -2.2e77 or 8.7999999999999997e129 < (*.f64 a b) Initial program 91.0%
Taylor expanded in a around inf 71.6%
if -1.1e141 < (*.f64 a b) < -3.3499999999999999e117 or 3.1000000000000001e-148 < (*.f64 a b) < 8.7999999999999997e129Initial program 96.3%
Taylor expanded in x around inf 60.6%
if -2.2e77 < (*.f64 a b) < 3.1000000000000001e-148Initial program 98.2%
Taylor expanded in z around inf 52.5%
Final simplification60.8%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (+ (* a b) (+ (* z t) (* x y))))) (if (<= t_1 INFINITY) t_1 (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((z * t) + (x * y));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = z * t;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (a * b) + ((z * t) + (x * y));
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (a * b) + ((z * t) + (x * y)) tmp = 0 if t_1 <= math.inf: tmp = t_1 else: tmp = z * t return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(a * b) + Float64(Float64(z * t) + Float64(x * y))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (a * b) + ((z * t) + (x * y)); tmp = 0.0; if (t_1 <= Inf) tmp = t_1; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(z * t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := a \cdot b + \left(z \cdot t + x \cdot y\right)\\
\mathbf{if}\;t_1 \leq \infty:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\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 50.2%
Final simplification97.6%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -1.5e+132) (not (<= x 7.5e-54))) (+ (* a b) (* x y)) (+ (* a b) (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x <= -1.5e+132) || !(x <= 7.5e-54)) {
tmp = (a * b) + (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 <= (-1.5d+132)) .or. (.not. (x <= 7.5d-54))) then
tmp = (a * b) + (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 <= -1.5e+132) || !(x <= 7.5e-54)) {
tmp = (a * b) + (x * y);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x <= -1.5e+132) or not (x <= 7.5e-54): tmp = (a * b) + (x * y) else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((x <= -1.5e+132) || !(x <= 7.5e-54)) tmp = Float64(Float64(a * b) + 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 <= -1.5e+132) || ~((x <= 7.5e-54))) tmp = (a * b) + (x * y); else tmp = (a * b) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[x, -1.5e+132], N[Not[LessEqual[x, 7.5e-54]], $MachinePrecision]], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{+132} \lor \neg \left(x \leq 7.5 \cdot 10^{-54}\right):\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if x < -1.4999999999999999e132 or 7.5000000000000005e-54 < x Initial program 91.1%
Taylor expanded in z around 0 77.8%
if -1.4999999999999999e132 < x < 7.5000000000000005e-54Initial program 98.0%
Taylor expanded in x around 0 81.2%
Final simplification79.9%
(FPCore (x y z t a b) :precision binary64 (if (<= (* a b) -7.2e+77) (* a b) (if (<= (* a b) 4.17e+30) (* z t) (* a b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -7.2e+77) {
tmp = a * b;
} else if ((a * b) <= 4.17e+30) {
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) <= (-7.2d+77)) then
tmp = a * b
else if ((a * b) <= 4.17d+30) 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) <= -7.2e+77) {
tmp = a * b;
} else if ((a * b) <= 4.17e+30) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -7.2e+77: tmp = a * b elif (a * b) <= 4.17e+30: tmp = z * t else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -7.2e+77) tmp = Float64(a * b); elseif (Float64(a * b) <= 4.17e+30) 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) <= -7.2e+77) tmp = a * b; elseif ((a * b) <= 4.17e+30) 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], -7.2e+77], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4.17e+30], N[(z * t), $MachinePrecision], N[(a * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -7.2 \cdot 10^{+77}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 4.17 \cdot 10^{+30}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -7.1999999999999996e77 or 4.1699999999999998e30 < (*.f64 a b) Initial program 91.7%
Taylor expanded in a around inf 62.0%
if -7.1999999999999996e77 < (*.f64 a b) < 4.1699999999999998e30Initial program 97.9%
Taylor expanded in z around inf 48.3%
Final simplification54.1%
(FPCore (x y z t a b) :precision binary64 (if (<= y -2.3e+17) (* x y) (if (<= y 7e+114) (+ (* a b) (* z t)) (* x y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -2.3e+17) {
tmp = x * y;
} else if (y <= 7e+114) {
tmp = (a * b) + (z * t);
} else {
tmp = x * y;
}
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 (y <= (-2.3d+17)) then
tmp = x * y
else if (y <= 7d+114) then
tmp = (a * b) + (z * t)
else
tmp = x * y
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 (y <= -2.3e+17) {
tmp = x * y;
} else if (y <= 7e+114) {
tmp = (a * b) + (z * t);
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y <= -2.3e+17: tmp = x * y elif y <= 7e+114: tmp = (a * b) + (z * t) else: tmp = x * y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -2.3e+17) tmp = Float64(x * y); elseif (y <= 7e+114) tmp = Float64(Float64(a * b) + Float64(z * t)); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (y <= -2.3e+17) tmp = x * y; elseif (y <= 7e+114) tmp = (a * b) + (z * t); else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -2.3e+17], N[(x * y), $MachinePrecision], If[LessEqual[y, 7e+114], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{+17}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq 7 \cdot 10^{+114}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if y < -2.3e17 or 7.0000000000000001e114 < y Initial program 92.1%
Taylor expanded in x around inf 54.5%
if -2.3e17 < y < 7.0000000000000001e114Initial program 97.9%
Taylor expanded in x around 0 81.5%
Final simplification69.4%
(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 95.3%
Taylor expanded in a around inf 32.6%
Final simplification32.6%
herbie shell --seed 2023224
(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)))