
(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}
(FPCore (x y z t a b) :precision binary64 (fma x y (fma a b (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(x, y, fma(a, b, (z * t)));
}
function code(x, y, z, t, a, b) return fma(x, y, fma(a, b, Float64(z * t))) end
code[x_, y_, z_, t_, a_, b_] := N[(x * y + N[(a * b + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, z \cdot t\right)\right)
\end{array}
Initial program 98.8%
associate-+l+98.8%
fma-def99.6%
+-commutative99.6%
fma-def100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z t a b) :precision binary64 (+ (fma x y (* z t)) (* a b)))
double code(double x, double y, double z, double t, double a, double b) {
return fma(x, y, (z * t)) + (a * b);
}
function code(x, y, z, t, a, b) return Float64(fma(x, y, Float64(z * t)) + Float64(a * b)) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y, z \cdot t\right) + a \cdot b
\end{array}
Initial program 98.8%
fma-def99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* x y) -6e+39)
(* x y)
(if (<= (* x y) -8.5e-50)
(* z t)
(if (<= (* x y) -6e-299)
(* a b)
(if (<= (* x y) 4e-140)
(* z t)
(if (<= (* x y) 680.0)
(* a b)
(if (<= (* x y) 7.4e+22)
(* z t)
(if (or (<= (* x y) 1.85e+77) (not (<= (* x y) 2.2e+142)))
(* x y)
(* a b)))))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -6e+39) {
tmp = x * y;
} else if ((x * y) <= -8.5e-50) {
tmp = z * t;
} else if ((x * y) <= -6e-299) {
tmp = a * b;
} else if ((x * y) <= 4e-140) {
tmp = z * t;
} else if ((x * y) <= 680.0) {
tmp = a * b;
} else if ((x * y) <= 7.4e+22) {
tmp = z * t;
} else if (((x * y) <= 1.85e+77) || !((x * y) <= 2.2e+142)) {
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 ((x * y) <= (-6d+39)) then
tmp = x * y
else if ((x * y) <= (-8.5d-50)) then
tmp = z * t
else if ((x * y) <= (-6d-299)) then
tmp = a * b
else if ((x * y) <= 4d-140) then
tmp = z * t
else if ((x * y) <= 680.0d0) then
tmp = a * b
else if ((x * y) <= 7.4d+22) then
tmp = z * t
else if (((x * y) <= 1.85d+77) .or. (.not. ((x * y) <= 2.2d+142))) 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 ((x * y) <= -6e+39) {
tmp = x * y;
} else if ((x * y) <= -8.5e-50) {
tmp = z * t;
} else if ((x * y) <= -6e-299) {
tmp = a * b;
} else if ((x * y) <= 4e-140) {
tmp = z * t;
} else if ((x * y) <= 680.0) {
tmp = a * b;
} else if ((x * y) <= 7.4e+22) {
tmp = z * t;
} else if (((x * y) <= 1.85e+77) || !((x * y) <= 2.2e+142)) {
tmp = x * y;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -6e+39: tmp = x * y elif (x * y) <= -8.5e-50: tmp = z * t elif (x * y) <= -6e-299: tmp = a * b elif (x * y) <= 4e-140: tmp = z * t elif (x * y) <= 680.0: tmp = a * b elif (x * y) <= 7.4e+22: tmp = z * t elif ((x * y) <= 1.85e+77) or not ((x * y) <= 2.2e+142): tmp = x * y else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -6e+39) tmp = Float64(x * y); elseif (Float64(x * y) <= -8.5e-50) tmp = Float64(z * t); elseif (Float64(x * y) <= -6e-299) tmp = Float64(a * b); elseif (Float64(x * y) <= 4e-140) tmp = Float64(z * t); elseif (Float64(x * y) <= 680.0) tmp = Float64(a * b); elseif (Float64(x * y) <= 7.4e+22) tmp = Float64(z * t); elseif ((Float64(x * y) <= 1.85e+77) || !(Float64(x * y) <= 2.2e+142)) 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 ((x * y) <= -6e+39) tmp = x * y; elseif ((x * y) <= -8.5e-50) tmp = z * t; elseif ((x * y) <= -6e-299) tmp = a * b; elseif ((x * y) <= 4e-140) tmp = z * t; elseif ((x * y) <= 680.0) tmp = a * b; elseif ((x * y) <= 7.4e+22) tmp = z * t; elseif (((x * y) <= 1.85e+77) || ~(((x * y) <= 2.2e+142))) tmp = x * y; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -6e+39], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -8.5e-50], N[(z * t), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -6e-299], N[(a * b), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 4e-140], N[(z * t), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 680.0], N[(a * b), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 7.4e+22], N[(z * t), $MachinePrecision], If[Or[LessEqual[N[(x * y), $MachinePrecision], 1.85e+77], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2.2e+142]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -6 \cdot 10^{+39}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq -8.5 \cdot 10^{-50}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;x \cdot y \leq -6 \cdot 10^{-299}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{-140}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;x \cdot y \leq 680:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;x \cdot y \leq 7.4 \cdot 10^{+22}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;x \cdot y \leq 1.85 \cdot 10^{+77} \lor \neg \left(x \cdot y \leq 2.2 \cdot 10^{+142}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 x y) < -5.9999999999999999e39 or 7.3999999999999996e22 < (*.f64 x y) < 1.84999999999999997e77 or 2.19999999999999987e142 < (*.f64 x y) Initial program 98.2%
Taylor expanded in x around inf 67.3%
if -5.9999999999999999e39 < (*.f64 x y) < -8.50000000000000012e-50 or -5.99999999999999969e-299 < (*.f64 x y) < 3.9999999999999999e-140 or 680 < (*.f64 x y) < 7.3999999999999996e22Initial program 100.0%
Taylor expanded in z around inf 66.5%
if -8.50000000000000012e-50 < (*.f64 x y) < -5.99999999999999969e-299 or 3.9999999999999999e-140 < (*.f64 x y) < 680 or 1.84999999999999997e77 < (*.f64 x y) < 2.19999999999999987e142Initial program 98.3%
Taylor expanded in a around inf 62.8%
Final simplification66.0%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* x y) (* z t))) (t_2 (+ (* a b) (* x y))))
(if (<= (* a b) -3e+74)
t_2
(if (<= (* a b) 2.9e-19)
t_1
(if (<= (* a b) 1.8e+57)
t_2
(if (<= (* a b) 2e+159) t_1 (+ (* a b) (* z t))))))))
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) + (x * y);
double tmp;
if ((a * b) <= -3e+74) {
tmp = t_2;
} else if ((a * b) <= 2.9e-19) {
tmp = t_1;
} else if ((a * b) <= 1.8e+57) {
tmp = t_2;
} else if ((a * b) <= 2e+159) {
tmp = t_1;
} 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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (x * y) + (z * t)
t_2 = (a * b) + (x * y)
if ((a * b) <= (-3d+74)) then
tmp = t_2
else if ((a * b) <= 2.9d-19) then
tmp = t_1
else if ((a * b) <= 1.8d+57) then
tmp = t_2
else if ((a * b) <= 2d+159) then
tmp = t_1
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 t_1 = (x * y) + (z * t);
double t_2 = (a * b) + (x * y);
double tmp;
if ((a * b) <= -3e+74) {
tmp = t_2;
} else if ((a * b) <= 2.9e-19) {
tmp = t_1;
} else if ((a * b) <= 1.8e+57) {
tmp = t_2;
} else if ((a * b) <= 2e+159) {
tmp = t_1;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (x * y) + (z * t) t_2 = (a * b) + (x * y) tmp = 0 if (a * b) <= -3e+74: tmp = t_2 elif (a * b) <= 2.9e-19: tmp = t_1 elif (a * b) <= 1.8e+57: tmp = t_2 elif (a * b) <= 2e+159: tmp = t_1 else: tmp = (a * b) + (z * t) 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(x * y)) tmp = 0.0 if (Float64(a * b) <= -3e+74) tmp = t_2; elseif (Float64(a * b) <= 2.9e-19) tmp = t_1; elseif (Float64(a * b) <= 1.8e+57) tmp = t_2; elseif (Float64(a * b) <= 2e+159) tmp = t_1; else tmp = Float64(Float64(a * b) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (x * y) + (z * t); t_2 = (a * b) + (x * y); tmp = 0.0; if ((a * b) <= -3e+74) tmp = t_2; elseif ((a * b) <= 2.9e-19) tmp = t_1; elseif ((a * b) <= 1.8e+57) tmp = t_2; elseif ((a * b) <= 2e+159) tmp = t_1; else tmp = (a * b) + (z * t); 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[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -3e+74], t$95$2, If[LessEqual[N[(a * b), $MachinePrecision], 2.9e-19], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 1.8e+57], t$95$2, If[LessEqual[N[(a * b), $MachinePrecision], 2e+159], t$95$1, N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
t_2 := a \cdot b + x \cdot y\\
\mathbf{if}\;a \cdot b \leq -3 \cdot 10^{+74}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;a \cdot b \leq 2.9 \cdot 10^{-19}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq 1.8 \cdot 10^{+57}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+159}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -3e74 or 2.9e-19 < (*.f64 a b) < 1.8000000000000001e57Initial program 100.0%
Taylor expanded in z around 0 87.2%
if -3e74 < (*.f64 a b) < 2.9e-19 or 1.8000000000000001e57 < (*.f64 a b) < 1.9999999999999999e159Initial program 99.3%
Taylor expanded in a around 0 90.6%
if 1.9999999999999999e159 < (*.f64 a b) Initial program 94.6%
Taylor expanded in x around 0 92.2%
Final simplification89.9%
(FPCore (x y z t a b)
:precision binary64
(if (or (<= (* a b) -4.4e+67)
(not
(or (<= (* a b) 2.9e-19)
(and (not (<= (* a b) 2.95e+57)) (<= (* a b) 4.5e+219)))))
(* a b)
(* z t)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -4.4e+67) || !(((a * b) <= 2.9e-19) || (!((a * b) <= 2.95e+57) && ((a * b) <= 4.5e+219)))) {
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) <= (-4.4d+67)) .or. (.not. ((a * b) <= 2.9d-19) .or. (.not. ((a * b) <= 2.95d+57)) .and. ((a * b) <= 4.5d+219))) 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) <= -4.4e+67) || !(((a * b) <= 2.9e-19) || (!((a * b) <= 2.95e+57) && ((a * b) <= 4.5e+219)))) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -4.4e+67) or not (((a * b) <= 2.9e-19) or (not ((a * b) <= 2.95e+57) and ((a * b) <= 4.5e+219))): tmp = a * b else: tmp = z * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -4.4e+67) || !((Float64(a * b) <= 2.9e-19) || (!(Float64(a * b) <= 2.95e+57) && (Float64(a * b) <= 4.5e+219)))) 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) <= -4.4e+67) || ~((((a * b) <= 2.9e-19) || (~(((a * b) <= 2.95e+57)) && ((a * b) <= 4.5e+219))))) 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], -4.4e+67], N[Not[Or[LessEqual[N[(a * b), $MachinePrecision], 2.9e-19], And[N[Not[LessEqual[N[(a * b), $MachinePrecision], 2.95e+57]], $MachinePrecision], LessEqual[N[(a * b), $MachinePrecision], 4.5e+219]]]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -4.4 \cdot 10^{+67} \lor \neg \left(a \cdot b \leq 2.9 \cdot 10^{-19} \lor \neg \left(a \cdot b \leq 2.95 \cdot 10^{+57}\right) \land a \cdot b \leq 4.5 \cdot 10^{+219}\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -4.4e67 or 2.9e-19 < (*.f64 a b) < 2.95000000000000006e57 or 4.50000000000000023e219 < (*.f64 a b) Initial program 97.8%
Taylor expanded in a around inf 73.6%
if -4.4e67 < (*.f64 a b) < 2.9e-19 or 2.95000000000000006e57 < (*.f64 a b) < 4.50000000000000023e219Initial program 99.3%
Taylor expanded in z around inf 47.9%
Final simplification57.1%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* x y) -3.4e+221) (not (<= (* x y) 3.35e+146))) (* 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) <= -3.4e+221) || !((x * y) <= 3.35e+146)) {
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) <= (-3.4d+221)) .or. (.not. ((x * y) <= 3.35d+146))) 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) <= -3.4e+221) || !((x * y) <= 3.35e+146)) {
tmp = x * y;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -3.4e+221) or not ((x * y) <= 3.35e+146): 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) <= -3.4e+221) || !(Float64(x * y) <= 3.35e+146)) 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) <= -3.4e+221) || ~(((x * y) <= 3.35e+146))) 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], -3.4e+221], N[Not[LessEqual[N[(x * y), $MachinePrecision], 3.35e+146]], $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 -3.4 \cdot 10^{+221} \lor \neg \left(x \cdot y \leq 3.35 \cdot 10^{+146}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -3.3999999999999998e221 or 3.35000000000000003e146 < (*.f64 x y) Initial program 96.9%
Taylor expanded in x around inf 86.1%
if -3.3999999999999998e221 < (*.f64 x y) < 3.35000000000000003e146Initial program 99.4%
Taylor expanded in x around 0 83.9%
Final simplification84.5%
(FPCore (x y z t a b) :precision binary64 (if (or (<= x -1.35e+91) (not (<= x 2.4e-71))) (+ (* 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.35e+91) || !(x <= 2.4e-71)) {
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.35d+91)) .or. (.not. (x <= 2.4d-71))) 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.35e+91) || !(x <= 2.4e-71)) {
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.35e+91) or not (x <= 2.4e-71): 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.35e+91) || !(x <= 2.4e-71)) 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.35e+91) || ~((x <= 2.4e-71))) 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.35e+91], N[Not[LessEqual[x, 2.4e-71]], $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.35 \cdot 10^{+91} \lor \neg \left(x \leq 2.4 \cdot 10^{-71}\right):\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if x < -1.35e91 or 2.4e-71 < x Initial program 98.5%
Taylor expanded in z around 0 76.4%
if -1.35e91 < x < 2.4e-71Initial program 99.2%
Taylor expanded in x around 0 82.4%
Final simplification79.3%
(FPCore (x y z t a b) :precision binary64 (+ (* a b) (+ (* x y) (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return (a * b) + ((x * y) + (z * t));
}
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) + ((x * y) + (z * t))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (a * b) + ((x * y) + (z * t));
}
def code(x, y, z, t, a, b): return (a * b) + ((x * y) + (z * t))
function code(x, y, z, t, a, b) return Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))) end
function tmp = code(x, y, z, t, a, b) tmp = (a * b) + ((x * y) + (z * t)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b + \left(x \cdot y + z \cdot t\right)
\end{array}
Initial program 98.8%
Final simplification98.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 98.8%
Taylor expanded in a around inf 34.5%
Final simplification34.5%
herbie shell --seed 2023320
(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)))