
(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 10 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 96.9%
associate-+l+96.9%
fma-def98.0%
fma-def98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z t a b) :precision binary64 (+ (* a b) (fma x y (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return (a * b) + fma(x, y, (z * t));
}
function code(x, y, z, t, a, b) return Float64(Float64(a * b) + fma(x, y, Float64(z * t))) end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a * b), $MachinePrecision] + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b + \mathsf{fma}\left(x, y, z \cdot t\right)
\end{array}
Initial program 96.9%
fma-def97.3%
Simplified97.3%
Final simplification97.3%
(FPCore (x y z t a b) :precision binary64 (fma x y (+ (* a b) (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
return fma(x, y, ((a * b) + (z * t)));
}
function code(x, y, z, t, a, b) return fma(x, y, Float64(Float64(a * b) + Float64(z * t))) end
code[x_, y_, z_, t_, a_, b_] := N[(x * y + N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y, a \cdot b + z \cdot t\right)
\end{array}
Initial program 96.9%
associate-+l+96.9%
fma-def98.0%
fma-def98.4%
Simplified98.4%
fma-udef98.0%
Applied egg-rr98.0%
Final simplification98.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 (* x y))))
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 = x * y;
}
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 = x * y;
}
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 = x * y 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(x * y); 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 = x * y; 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[(x * y), $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}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) < +inf.0Initial program 100.0%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
Taylor expanded in x around inf 50.0%
Final simplification98.4%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* a b) -5.4e+54)
(* a b)
(if (<= (* a b) 4.6e-305)
(* z t)
(if (<= (* a b) 2.3e-248)
(* x y)
(if (<= (* a b) 48000000000000.0) (* z t) (* a b))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -5.4e+54) {
tmp = a * b;
} else if ((a * b) <= 4.6e-305) {
tmp = z * t;
} else if ((a * b) <= 2.3e-248) {
tmp = x * y;
} else if ((a * b) <= 48000000000000.0) {
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) <= (-5.4d+54)) then
tmp = a * b
else if ((a * b) <= 4.6d-305) then
tmp = z * t
else if ((a * b) <= 2.3d-248) then
tmp = x * y
else if ((a * b) <= 48000000000000.0d0) 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) <= -5.4e+54) {
tmp = a * b;
} else if ((a * b) <= 4.6e-305) {
tmp = z * t;
} else if ((a * b) <= 2.3e-248) {
tmp = x * y;
} else if ((a * b) <= 48000000000000.0) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -5.4e+54: tmp = a * b elif (a * b) <= 4.6e-305: tmp = z * t elif (a * b) <= 2.3e-248: tmp = x * y elif (a * b) <= 48000000000000.0: tmp = z * t else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -5.4e+54) tmp = Float64(a * b); elseif (Float64(a * b) <= 4.6e-305) tmp = Float64(z * t); elseif (Float64(a * b) <= 2.3e-248) tmp = Float64(x * y); elseif (Float64(a * b) <= 48000000000000.0) 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) <= -5.4e+54) tmp = a * b; elseif ((a * b) <= 4.6e-305) tmp = z * t; elseif ((a * b) <= 2.3e-248) tmp = x * y; elseif ((a * b) <= 48000000000000.0) 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], -5.4e+54], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4.6e-305], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2.3e-248], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 48000000000000.0], N[(z * t), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5.4 \cdot 10^{+54}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 4.6 \cdot 10^{-305}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 2.3 \cdot 10^{-248}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 48000000000000:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -5.40000000000000022e54 or 4.8e13 < (*.f64 a b) Initial program 94.5%
Taylor expanded in a around inf 70.8%
if -5.40000000000000022e54 < (*.f64 a b) < 4.5999999999999999e-305 or 2.3e-248 < (*.f64 a b) < 4.8e13Initial program 98.6%
Taylor expanded in z around inf 56.7%
if 4.5999999999999999e-305 < (*.f64 a b) < 2.3e-248Initial program 100.0%
Taylor expanded in x around inf 78.2%
Final simplification63.4%
(FPCore (x y z t a b)
:precision binary64
(if (or (<= x -7.5e+244)
(and (not (<= x -1.8e+225))
(or (<= x -9.8e+129) (not (<= x 1.65e-94)))))
(+ (* 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 <= -7.5e+244) || (!(x <= -1.8e+225) && ((x <= -9.8e+129) || !(x <= 1.65e-94)))) {
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 <= (-7.5d+244)) .or. (.not. (x <= (-1.8d+225))) .and. (x <= (-9.8d+129)) .or. (.not. (x <= 1.65d-94))) 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 <= -7.5e+244) || (!(x <= -1.8e+225) && ((x <= -9.8e+129) || !(x <= 1.65e-94)))) {
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 <= -7.5e+244) or (not (x <= -1.8e+225) and ((x <= -9.8e+129) or not (x <= 1.65e-94))): 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 <= -7.5e+244) || (!(x <= -1.8e+225) && ((x <= -9.8e+129) || !(x <= 1.65e-94)))) 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 <= -7.5e+244) || (~((x <= -1.8e+225)) && ((x <= -9.8e+129) || ~((x <= 1.65e-94))))) 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, -7.5e+244], And[N[Not[LessEqual[x, -1.8e+225]], $MachinePrecision], Or[LessEqual[x, -9.8e+129], N[Not[LessEqual[x, 1.65e-94]], $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 -7.5 \cdot 10^{+244} \lor \neg \left(x \leq -1.8 \cdot 10^{+225}\right) \land \left(x \leq -9.8 \cdot 10^{+129} \lor \neg \left(x \leq 1.65 \cdot 10^{-94}\right)\right):\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if x < -7.5e244 or -1.7999999999999999e225 < x < -9.8e129 or 1.6500000000000001e-94 < x Initial program 94.2%
Taylor expanded in z around 0 70.3%
if -7.5e244 < x < -1.7999999999999999e225 or -9.8e129 < x < 1.6500000000000001e-94Initial program 99.3%
Taylor expanded in x around 0 82.8%
Final simplification76.9%
(FPCore (x y z t a b)
:precision binary64
(if (<= x -9.5e+276)
(* x y)
(if (or (<= x -7.2e+224) (and (not (<= x -5.6e+182)) (<= x 1.25e-93)))
(+ (* a b) (* z t))
(* x y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (x <= -9.5e+276) {
tmp = x * y;
} else if ((x <= -7.2e+224) || (!(x <= -5.6e+182) && (x <= 1.25e-93))) {
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 (x <= (-9.5d+276)) then
tmp = x * y
else if ((x <= (-7.2d+224)) .or. (.not. (x <= (-5.6d+182))) .and. (x <= 1.25d-93)) 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 (x <= -9.5e+276) {
tmp = x * y;
} else if ((x <= -7.2e+224) || (!(x <= -5.6e+182) && (x <= 1.25e-93))) {
tmp = (a * b) + (z * t);
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if x <= -9.5e+276: tmp = x * y elif (x <= -7.2e+224) or (not (x <= -5.6e+182) and (x <= 1.25e-93)): tmp = (a * b) + (z * t) else: tmp = x * y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (x <= -9.5e+276) tmp = Float64(x * y); elseif ((x <= -7.2e+224) || (!(x <= -5.6e+182) && (x <= 1.25e-93))) 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 (x <= -9.5e+276) tmp = x * y; elseif ((x <= -7.2e+224) || (~((x <= -5.6e+182)) && (x <= 1.25e-93))) tmp = (a * b) + (z * t); else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[x, -9.5e+276], N[(x * y), $MachinePrecision], If[Or[LessEqual[x, -7.2e+224], And[N[Not[LessEqual[x, -5.6e+182]], $MachinePrecision], LessEqual[x, 1.25e-93]]], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{+276}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq -7.2 \cdot 10^{+224} \lor \neg \left(x \leq -5.6 \cdot 10^{+182}\right) \land x \leq 1.25 \cdot 10^{-93}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if x < -9.50000000000000013e276 or -7.2e224 < x < -5.60000000000000013e182 or 1.24999999999999999e-93 < x Initial program 95.0%
Taylor expanded in x around inf 46.8%
if -9.50000000000000013e276 < x < -7.2e224 or -5.60000000000000013e182 < x < 1.24999999999999999e-93Initial program 98.1%
Taylor expanded in x around 0 79.8%
Final simplification66.8%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -1.8e+51) (not (<= (* a b) 4.9e+14))) (+ (* 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 (((a * b) <= -1.8e+51) || !((a * b) <= 4.9e+14)) {
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 (((a * b) <= (-1.8d+51)) .or. (.not. ((a * b) <= 4.9d+14))) 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 (((a * b) <= -1.8e+51) || !((a * b) <= 4.9e+14)) {
tmp = (a * b) + (z * t);
} else {
tmp = (x * y) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -1.8e+51) or not ((a * b) <= 4.9e+14): 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(a * b) <= -1.8e+51) || !(Float64(a * b) <= 4.9e+14)) 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 (((a * b) <= -1.8e+51) || ~(((a * b) <= 4.9e+14))) tmp = (a * b) + (z * t); else tmp = (x * y) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -1.8e+51], N[Not[LessEqual[N[(a * b), $MachinePrecision], 4.9e+14]], $MachinePrecision]], 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}\;a \cdot b \leq -1.8 \cdot 10^{+51} \lor \neg \left(a \cdot b \leq 4.9 \cdot 10^{+14}\right):\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -1.80000000000000005e51 or 4.9e14 < (*.f64 a b) Initial program 94.5%
Taylor expanded in x around 0 86.5%
if -1.80000000000000005e51 < (*.f64 a b) < 4.9e14Initial program 98.6%
Taylor expanded in a around 0 91.7%
Final simplification89.5%
(FPCore (x y z t a b) :precision binary64 (if (<= (* a b) -5.8e+54) (* a b) (if (<= (* a b) 68000000000000.0) (* z t) (* a b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -5.8e+54) {
tmp = a * b;
} else if ((a * b) <= 68000000000000.0) {
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) <= (-5.8d+54)) then
tmp = a * b
else if ((a * b) <= 68000000000000.0d0) 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) <= -5.8e+54) {
tmp = a * b;
} else if ((a * b) <= 68000000000000.0) {
tmp = z * t;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -5.8e+54: tmp = a * b elif (a * b) <= 68000000000000.0: tmp = z * t else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -5.8e+54) tmp = Float64(a * b); elseif (Float64(a * b) <= 68000000000000.0) 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) <= -5.8e+54) tmp = a * b; elseif ((a * b) <= 68000000000000.0) 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], -5.8e+54], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 68000000000000.0], N[(z * t), $MachinePrecision], N[(a * b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5.8 \cdot 10^{+54}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 68000000000000:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -5.7999999999999997e54 or 6.8e13 < (*.f64 a b) Initial program 94.5%
Taylor expanded in a around inf 70.8%
if -5.7999999999999997e54 < (*.f64 a b) < 6.8e13Initial program 98.6%
Taylor expanded in z around inf 54.2%
Final simplification61.2%
(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.9%
Taylor expanded in a around inf 35.8%
Final simplification35.8%
herbie shell --seed 2023199
(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)))