
(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 x y (* z t)) (* a b)) (* z (+ t (* y (/ x 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(x, y, (z * t)) + (a * b);
} else {
tmp = z * (t + (y * (x / 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(fma(x, y, Float64(z * t)) + Float64(a * b)); else tmp = Float64(z * Float64(t + Float64(y * Float64(x / 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[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], N[(z * N[(t + N[(y * N[(x / z), $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(x, y, z \cdot t\right) + a \cdot b\\
\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%
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 b around inf 44.4%
associate-/l*77.8%
associate-/l*77.8%
Simplified77.8%
Taylor expanded in z around inf 55.6%
Taylor expanded in b around 0 55.6%
*-commutative55.6%
associate-*r/77.8%
Simplified77.8%
Final simplification99.2%
(FPCore (x y z t a b) :precision binary64 (fma a b (fma x y (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(a, b, fma(x, y, (z * t)));
}
function code(x, y, z, t, a, b) return fma(a, b, fma(x, y, Float64(z * t))) end
code[x_, y_, z_, t_, a_, b_] := N[(a * b + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a, b, \mathsf{fma}\left(x, y, z \cdot t\right)\right)
\end{array}
Initial program 96.5%
+-commutative96.5%
fma-define98.0%
fma-define98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* a b) -6.5e+203)
(* a b)
(if (<= (* a b) 1e-323)
(* z t)
(if (<= (* a b) 3.7e-222)
(* x y)
(if (<= (* a b) 2.4e-153)
(* z t)
(if (<= (* a b) 5.2e-13) (* x y) (* a b)))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -6.5e+203) {
tmp = a * b;
} else if ((a * b) <= 1e-323) {
tmp = z * t;
} else if ((a * b) <= 3.7e-222) {
tmp = x * y;
} else if ((a * b) <= 2.4e-153) {
tmp = z * t;
} else if ((a * b) <= 5.2e-13) {
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) <= (-6.5d+203)) then
tmp = a * b
else if ((a * b) <= 1d-323) then
tmp = z * t
else if ((a * b) <= 3.7d-222) then
tmp = x * y
else if ((a * b) <= 2.4d-153) then
tmp = z * t
else if ((a * b) <= 5.2d-13) 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) <= -6.5e+203) {
tmp = a * b;
} else if ((a * b) <= 1e-323) {
tmp = z * t;
} else if ((a * b) <= 3.7e-222) {
tmp = x * y;
} else if ((a * b) <= 2.4e-153) {
tmp = z * t;
} else if ((a * b) <= 5.2e-13) {
tmp = x * y;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -6.5e+203: tmp = a * b elif (a * b) <= 1e-323: tmp = z * t elif (a * b) <= 3.7e-222: tmp = x * y elif (a * b) <= 2.4e-153: tmp = z * t elif (a * b) <= 5.2e-13: tmp = x * y else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -6.5e+203) tmp = Float64(a * b); elseif (Float64(a * b) <= 1e-323) tmp = Float64(z * t); elseif (Float64(a * b) <= 3.7e-222) tmp = Float64(x * y); elseif (Float64(a * b) <= 2.4e-153) tmp = Float64(z * t); elseif (Float64(a * b) <= 5.2e-13) 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) <= -6.5e+203) tmp = a * b; elseif ((a * b) <= 1e-323) tmp = z * t; elseif ((a * b) <= 3.7e-222) tmp = x * y; elseif ((a * b) <= 2.4e-153) tmp = z * t; elseif ((a * b) <= 5.2e-13) 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], -6.5e+203], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1e-323], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 3.7e-222], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2.4e-153], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 5.2e-13], N[(x * y), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -6.5 \cdot 10^{+203}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 10^{-323}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 3.7 \cdot 10^{-222}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 2.4 \cdot 10^{-153}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 5.2 \cdot 10^{-13}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -6.5000000000000003e203 or 5.2000000000000001e-13 < (*.f64 a b) Initial program 94.3%
Taylor expanded in a around inf 69.7%
if -6.5000000000000003e203 < (*.f64 a b) < 9.88131e-324 or 3.6999999999999999e-222 < (*.f64 a b) < 2.4000000000000002e-153Initial program 97.4%
Taylor expanded in z around inf 54.5%
if 9.88131e-324 < (*.f64 a b) < 3.6999999999999999e-222 or 2.4000000000000002e-153 < (*.f64 a b) < 5.2000000000000001e-13Initial program 100.0%
Taylor expanded in x around inf 72.8%
Final simplification63.1%
(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 b around inf 44.4%
associate-/l*77.8%
associate-/l*77.8%
Simplified77.8%
Taylor expanded in z around inf 55.6%
Taylor expanded in b around 0 55.6%
*-commutative55.6%
associate-*r/77.8%
Simplified77.8%
Final simplification99.2%
(FPCore (x y z t a b) :precision binary64 (if (<= (* z t) -20.0) (* z (+ t (/ (* a b) z))) (if (<= (* z t) 1e+48) (+ (* x y) (* a b)) (* z (+ t (/ (* x y) z))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z * t) <= -20.0) {
tmp = z * (t + ((a * b) / z));
} else if ((z * t) <= 1e+48) {
tmp = (x * y) + (a * b);
} else {
tmp = z * (t + ((x * y) / z));
}
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 ((z * t) <= (-20.0d0)) then
tmp = z * (t + ((a * b) / z))
else if ((z * t) <= 1d+48) then
tmp = (x * y) + (a * b)
else
tmp = z * (t + ((x * y) / z))
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 ((z * t) <= -20.0) {
tmp = z * (t + ((a * b) / z));
} else if ((z * t) <= 1e+48) {
tmp = (x * y) + (a * b);
} else {
tmp = z * (t + ((x * y) / z));
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z * t) <= -20.0: tmp = z * (t + ((a * b) / z)) elif (z * t) <= 1e+48: tmp = (x * y) + (a * b) else: tmp = z * (t + ((x * y) / z)) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(z * t) <= -20.0) tmp = Float64(z * Float64(t + Float64(Float64(a * b) / z))); elseif (Float64(z * t) <= 1e+48) tmp = Float64(Float64(x * y) + Float64(a * b)); else tmp = Float64(z * Float64(t + Float64(Float64(x * y) / z))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((z * t) <= -20.0) tmp = z * (t + ((a * b) / z)); elseif ((z * t) <= 1e+48) tmp = (x * y) + (a * b); else tmp = z * (t + ((x * y) / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(z * t), $MachinePrecision], -20.0], N[(z * N[(t + N[(N[(a * b), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e+48], N[(N[(x * y), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], N[(z * N[(t + N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -20:\\
\;\;\;\;z \cdot \left(t + \frac{a \cdot b}{z}\right)\\
\mathbf{elif}\;z \cdot t \leq 10^{+48}:\\
\;\;\;\;x \cdot y + a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t + \frac{x \cdot y}{z}\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -20Initial program 94.1%
Taylor expanded in b around inf 66.2%
associate-/l*67.5%
associate-/l*63.2%
Simplified63.2%
Taylor expanded in z around inf 83.1%
Taylor expanded in x around 0 85.4%
if -20 < (*.f64 z t) < 1.00000000000000004e48Initial program 98.5%
Taylor expanded in z around 0 91.5%
if 1.00000000000000004e48 < (*.f64 z t) Initial program 94.3%
Taylor expanded in z around inf 92.4%
Taylor expanded in a around 0 79.8%
Final simplification87.4%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* x y) -7.2e+178) (not (<= (* x y) 1e+141))) (* 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) <= -7.2e+178) || !((x * y) <= 1e+141)) {
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) <= (-7.2d+178)) .or. (.not. ((x * y) <= 1d+141))) 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) <= -7.2e+178) || !((x * y) <= 1e+141)) {
tmp = x * y;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -7.2e+178) or not ((x * y) <= 1e+141): 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) <= -7.2e+178) || !(Float64(x * y) <= 1e+141)) 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) <= -7.2e+178) || ~(((x * y) <= 1e+141))) 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], -7.2e+178], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1e+141]], $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 -7.2 \cdot 10^{+178} \lor \neg \left(x \cdot y \leq 10^{+141}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -7.1999999999999995e178 or 1.00000000000000002e141 < (*.f64 x y) Initial program 91.4%
Taylor expanded in x around inf 78.7%
if -7.1999999999999995e178 < (*.f64 x y) < 1.00000000000000002e141Initial program 98.4%
Taylor expanded in x around 0 83.6%
Final simplification82.3%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* x y) -8.8e+110) (not (<= (* x y) 3.5e+44))) (+ (* x y) (* a b)) (+ (* a b) (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((x * y) <= -8.8e+110) || !((x * y) <= 3.5e+44)) {
tmp = (x * y) + (a * b);
} 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) <= (-8.8d+110)) .or. (.not. ((x * y) <= 3.5d+44))) then
tmp = (x * y) + (a * b)
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) <= -8.8e+110) || !((x * y) <= 3.5e+44)) {
tmp = (x * y) + (a * b);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -8.8e+110) or not ((x * y) <= 3.5e+44): tmp = (x * y) + (a * b) else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(x * y) <= -8.8e+110) || !(Float64(x * y) <= 3.5e+44)) tmp = Float64(Float64(x * y) + Float64(a * b)); 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) <= -8.8e+110) || ~(((x * y) <= 3.5e+44))) tmp = (x * y) + (a * b); 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], -8.8e+110], N[Not[LessEqual[N[(x * y), $MachinePrecision], 3.5e+44]], $MachinePrecision]], N[(N[(x * y), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -8.8 \cdot 10^{+110} \lor \neg \left(x \cdot y \leq 3.5 \cdot 10^{+44}\right):\\
\;\;\;\;x \cdot y + a \cdot b\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -8.79999999999999967e110 or 3.4999999999999999e44 < (*.f64 x y) Initial program 93.1%
Taylor expanded in z around 0 82.8%
if -8.79999999999999967e110 < (*.f64 x y) < 3.4999999999999999e44Initial program 98.7%
Taylor expanded in x around 0 89.1%
Final simplification86.6%
(FPCore (x y z t a b) :precision binary64 (if (<= (* x y) -4e+111) (+ (* x y) (* a b)) (if (<= (* x y) 2000.0) (+ (* a b) (* z t)) (+ (* x y) (* z t)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -4e+111) {
tmp = (x * y) + (a * b);
} else if ((x * y) <= 2000.0) {
tmp = (a * b) + (z * t);
} else {
tmp = (x * y) + (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) <= (-4d+111)) then
tmp = (x * y) + (a * b)
else if ((x * y) <= 2000.0d0) then
tmp = (a * b) + (z * t)
else
tmp = (x * y) + (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) <= -4e+111) {
tmp = (x * y) + (a * b);
} else if ((x * y) <= 2000.0) {
tmp = (a * b) + (z * t);
} else {
tmp = (x * y) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -4e+111: tmp = (x * y) + (a * b) elif (x * y) <= 2000.0: tmp = (a * b) + (z * t) else: tmp = (x * y) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -4e+111) tmp = Float64(Float64(x * y) + Float64(a * b)); elseif (Float64(x * y) <= 2000.0) tmp = Float64(Float64(a * b) + Float64(z * t)); else tmp = Float64(Float64(x * y) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((x * y) <= -4e+111) tmp = (x * y) + (a * b); elseif ((x * y) <= 2000.0) tmp = (a * b) + (z * t); else tmp = (x * y) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -4e+111], N[(N[(x * y), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2000.0], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -4 \cdot 10^{+111}:\\
\;\;\;\;x \cdot y + a \cdot b\\
\mathbf{elif}\;x \cdot y \leq 2000:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\end{array}
\end{array}
if (*.f64 x y) < -3.99999999999999983e111Initial program 93.0%
Taylor expanded in z around 0 88.1%
if -3.99999999999999983e111 < (*.f64 x y) < 2e3Initial program 99.3%
Taylor expanded in x around 0 90.6%
if 2e3 < (*.f64 x y) Initial program 92.4%
Taylor expanded in a around 0 78.5%
Final simplification87.0%
(FPCore (x y z t a b) :precision binary64 (if (<= (* z t) -20.0) (* z (+ t (/ (* a b) z))) (if (<= (* z t) 2e+46) (+ (* x y) (* a b)) (+ (* x y) (* z t)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z * t) <= -20.0) {
tmp = z * (t + ((a * b) / z));
} else if ((z * t) <= 2e+46) {
tmp = (x * y) + (a * b);
} else {
tmp = (x * y) + (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 ((z * t) <= (-20.0d0)) then
tmp = z * (t + ((a * b) / z))
else if ((z * t) <= 2d+46) then
tmp = (x * y) + (a * b)
else
tmp = (x * y) + (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 ((z * t) <= -20.0) {
tmp = z * (t + ((a * b) / z));
} else if ((z * t) <= 2e+46) {
tmp = (x * y) + (a * b);
} else {
tmp = (x * y) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z * t) <= -20.0: tmp = z * (t + ((a * b) / z)) elif (z * t) <= 2e+46: tmp = (x * y) + (a * b) else: tmp = (x * y) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(z * t) <= -20.0) tmp = Float64(z * Float64(t + Float64(Float64(a * b) / z))); elseif (Float64(z * t) <= 2e+46) tmp = Float64(Float64(x * y) + Float64(a * b)); else tmp = Float64(Float64(x * y) + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((z * t) <= -20.0) tmp = z * (t + ((a * b) / z)); elseif ((z * t) <= 2e+46) tmp = (x * y) + (a * b); else tmp = (x * y) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(z * t), $MachinePrecision], -20.0], N[(z * N[(t + N[(N[(a * b), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+46], N[(N[(x * y), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -20:\\
\;\;\;\;z \cdot \left(t + \frac{a \cdot b}{z}\right)\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+46}:\\
\;\;\;\;x \cdot y + a \cdot b\\
\mathbf{else}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\end{array}
\end{array}
if (*.f64 z t) < -20Initial program 94.1%
Taylor expanded in b around inf 66.2%
associate-/l*67.5%
associate-/l*63.2%
Simplified63.2%
Taylor expanded in z around inf 83.1%
Taylor expanded in x around 0 85.4%
if -20 < (*.f64 z t) < 2e46Initial program 98.5%
Taylor expanded in z around 0 91.4%
if 2e46 < (*.f64 z t) Initial program 94.4%
Taylor expanded in a around 0 78.4%
Final simplification87.0%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -1.7e+206) (not (<= (* a b) 4.3e-129))) (* a b) (* z t)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -1.7e+206) || !((a * b) <= 4.3e-129)) {
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) <= (-1.7d+206)) .or. (.not. ((a * b) <= 4.3d-129))) 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) <= -1.7e+206) || !((a * b) <= 4.3e-129)) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -1.7e+206) or not ((a * b) <= 4.3e-129): tmp = a * b else: tmp = z * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -1.7e+206) || !(Float64(a * b) <= 4.3e-129)) 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) <= -1.7e+206) || ~(((a * b) <= 4.3e-129))) 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], -1.7e+206], N[Not[LessEqual[N[(a * b), $MachinePrecision], 4.3e-129]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.7 \cdot 10^{+206} \lor \neg \left(a \cdot b \leq 4.3 \cdot 10^{-129}\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -1.69999999999999999e206 or 4.29999999999999981e-129 < (*.f64 a b) Initial program 95.0%
Taylor expanded in a around inf 62.5%
if -1.69999999999999999e206 < (*.f64 a b) < 4.29999999999999981e-129Initial program 97.8%
Taylor expanded in z around inf 50.9%
Final simplification56.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 96.5%
Taylor expanded in a around inf 36.5%
Final simplification36.5%
herbie shell --seed 2024096
(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)))