
(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 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 98.8%
+-commutative98.8%
fma-define99.2%
fma-define99.6%
Simplified99.6%
Final simplification99.6%
(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-define99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* z t) -1.05e+62)
(* z t)
(if (<= (* z t) -1.25e-86)
(* a b)
(if (<= (* z t) -5.2e-247)
(* x y)
(if (<= (* z t) 4.7e-290)
(* a b)
(if (<= (* z t) 7.4e-140)
(* x y)
(if (<= (* z t) 1.85e+49) (* a b) (* z t))))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z * t) <= -1.05e+62) {
tmp = z * t;
} else if ((z * t) <= -1.25e-86) {
tmp = a * b;
} else if ((z * t) <= -5.2e-247) {
tmp = x * y;
} else if ((z * t) <= 4.7e-290) {
tmp = a * b;
} else if ((z * t) <= 7.4e-140) {
tmp = x * y;
} else if ((z * t) <= 1.85e+49) {
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 ((z * t) <= (-1.05d+62)) then
tmp = z * t
else if ((z * t) <= (-1.25d-86)) then
tmp = a * b
else if ((z * t) <= (-5.2d-247)) then
tmp = x * y
else if ((z * t) <= 4.7d-290) then
tmp = a * b
else if ((z * t) <= 7.4d-140) then
tmp = x * y
else if ((z * t) <= 1.85d+49) 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 ((z * t) <= -1.05e+62) {
tmp = z * t;
} else if ((z * t) <= -1.25e-86) {
tmp = a * b;
} else if ((z * t) <= -5.2e-247) {
tmp = x * y;
} else if ((z * t) <= 4.7e-290) {
tmp = a * b;
} else if ((z * t) <= 7.4e-140) {
tmp = x * y;
} else if ((z * t) <= 1.85e+49) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z * t) <= -1.05e+62: tmp = z * t elif (z * t) <= -1.25e-86: tmp = a * b elif (z * t) <= -5.2e-247: tmp = x * y elif (z * t) <= 4.7e-290: tmp = a * b elif (z * t) <= 7.4e-140: tmp = x * y elif (z * t) <= 1.85e+49: tmp = a * b else: tmp = z * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(z * t) <= -1.05e+62) tmp = Float64(z * t); elseif (Float64(z * t) <= -1.25e-86) tmp = Float64(a * b); elseif (Float64(z * t) <= -5.2e-247) tmp = Float64(x * y); elseif (Float64(z * t) <= 4.7e-290) tmp = Float64(a * b); elseif (Float64(z * t) <= 7.4e-140) tmp = Float64(x * y); elseif (Float64(z * t) <= 1.85e+49) 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 ((z * t) <= -1.05e+62) tmp = z * t; elseif ((z * t) <= -1.25e-86) tmp = a * b; elseif ((z * t) <= -5.2e-247) tmp = x * y; elseif ((z * t) <= 4.7e-290) tmp = a * b; elseif ((z * t) <= 7.4e-140) tmp = x * y; elseif ((z * t) <= 1.85e+49) tmp = a * b; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(z * t), $MachinePrecision], -1.05e+62], N[(z * t), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -1.25e-86], N[(a * b), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -5.2e-247], N[(x * y), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 4.7e-290], N[(a * b), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 7.4e-140], N[(x * y), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1.85e+49], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1.05 \cdot 10^{+62}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;z \cdot t \leq -1.25 \cdot 10^{-86}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;z \cdot t \leq -5.2 \cdot 10^{-247}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;z \cdot t \leq 4.7 \cdot 10^{-290}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;z \cdot t \leq 7.4 \cdot 10^{-140}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;z \cdot t \leq 1.85 \cdot 10^{+49}:\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 z t) < -1.05e62 or 1.85000000000000009e49 < (*.f64 z t) Initial program 97.9%
Taylor expanded in z around inf 97.1%
Taylor expanded in a around 0 85.6%
Taylor expanded in t around inf 74.0%
if -1.05e62 < (*.f64 z t) < -1.25e-86 or -5.2e-247 < (*.f64 z t) < 4.7000000000000001e-290 or 7.39999999999999955e-140 < (*.f64 z t) < 1.85000000000000009e49Initial program 100.0%
Taylor expanded in a around inf 58.8%
if -1.25e-86 < (*.f64 z t) < -5.2e-247 or 4.7000000000000001e-290 < (*.f64 z t) < 7.39999999999999955e-140Initial program 97.7%
Taylor expanded in x around inf 94.0%
Taylor expanded in b around inf 85.6%
associate-/l*83.4%
Simplified83.4%
Taylor expanded in b around 0 62.0%
Final simplification65.3%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* x y) -3.4e+220)
(* x y)
(if (or (<= (* x y) -2.9e+185)
(and (not (<= (* x y) -1.35e+24)) (<= (* x y) 4e+53)))
(+ (* z t) (* a b))
(+ (* z t) (* x y)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * y) <= -3.4e+220) {
tmp = x * y;
} else if (((x * y) <= -2.9e+185) || (!((x * y) <= -1.35e+24) && ((x * y) <= 4e+53))) {
tmp = (z * t) + (a * b);
} else {
tmp = (z * t) + (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 * y) <= (-3.4d+220)) then
tmp = x * y
else if (((x * y) <= (-2.9d+185)) .or. (.not. ((x * y) <= (-1.35d+24))) .and. ((x * y) <= 4d+53)) then
tmp = (z * t) + (a * b)
else
tmp = (z * t) + (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 * y) <= -3.4e+220) {
tmp = x * y;
} else if (((x * y) <= -2.9e+185) || (!((x * y) <= -1.35e+24) && ((x * y) <= 4e+53))) {
tmp = (z * t) + (a * b);
} else {
tmp = (z * t) + (x * y);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (x * y) <= -3.4e+220: tmp = x * y elif ((x * y) <= -2.9e+185) or (not ((x * y) <= -1.35e+24) and ((x * y) <= 4e+53)): tmp = (z * t) + (a * b) else: tmp = (z * t) + (x * y) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * y) <= -3.4e+220) tmp = Float64(x * y); elseif ((Float64(x * y) <= -2.9e+185) || (!(Float64(x * y) <= -1.35e+24) && (Float64(x * y) <= 4e+53))) tmp = Float64(Float64(z * t) + Float64(a * b)); else tmp = Float64(Float64(z * t) + Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((x * y) <= -3.4e+220) tmp = x * y; elseif (((x * y) <= -2.9e+185) || (~(((x * y) <= -1.35e+24)) && ((x * y) <= 4e+53))) tmp = (z * t) + (a * b); else tmp = (z * t) + (x * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -3.4e+220], N[(x * y), $MachinePrecision], If[Or[LessEqual[N[(x * y), $MachinePrecision], -2.9e+185], And[N[Not[LessEqual[N[(x * y), $MachinePrecision], -1.35e+24]], $MachinePrecision], LessEqual[N[(x * y), $MachinePrecision], 4e+53]]], N[(N[(z * t), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -3.4 \cdot 10^{+220}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \cdot y \leq -2.9 \cdot 10^{+185} \lor \neg \left(x \cdot y \leq -1.35 \cdot 10^{+24}\right) \land x \cdot y \leq 4 \cdot 10^{+53}:\\
\;\;\;\;z \cdot t + a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t + x \cdot y\\
\end{array}
\end{array}
if (*.f64 x y) < -3.4e220Initial program 94.9%
Taylor expanded in x around inf 99.1%
Taylor expanded in b around inf 86.3%
associate-/l*86.3%
Simplified86.3%
Taylor expanded in b around 0 94.1%
if -3.4e220 < (*.f64 x y) < -2.89999999999999988e185 or -1.35e24 < (*.f64 x y) < 4e53Initial program 100.0%
Taylor expanded in x around 0 91.6%
if -2.89999999999999988e185 < (*.f64 x y) < -1.35e24 or 4e53 < (*.f64 x y) Initial program 97.6%
Taylor expanded in b around inf 74.5%
associate-+r+74.5%
associate-/l*73.3%
associate-/l*69.9%
Simplified69.9%
Taylor expanded in b around 0 82.2%
Final simplification88.7%
(FPCore (x y z t a b) :precision binary64 (if (<= (* z t) -1e+38) (+ (* z t) (* a b)) (if (<= (* z t) 2e+96) (+ (* a b) (* x y)) (* z (+ t (/ (* x y) z))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z * t) <= -1e+38) {
tmp = (z * t) + (a * b);
} else if ((z * t) <= 2e+96) {
tmp = (a * b) + (x * y);
} 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) <= (-1d+38)) then
tmp = (z * t) + (a * b)
else if ((z * t) <= 2d+96) then
tmp = (a * b) + (x * y)
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) <= -1e+38) {
tmp = (z * t) + (a * b);
} else if ((z * t) <= 2e+96) {
tmp = (a * b) + (x * y);
} else {
tmp = z * (t + ((x * y) / z));
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z * t) <= -1e+38: tmp = (z * t) + (a * b) elif (z * t) <= 2e+96: tmp = (a * b) + (x * y) else: tmp = z * (t + ((x * y) / z)) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(z * t) <= -1e+38) tmp = Float64(Float64(z * t) + Float64(a * b)); elseif (Float64(z * t) <= 2e+96) tmp = Float64(Float64(a * b) + Float64(x * y)); 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) <= -1e+38) tmp = (z * t) + (a * b); elseif ((z * t) <= 2e+96) tmp = (a * b) + (x * y); 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], -1e+38], N[(N[(z * t), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+96], N[(N[(a * b), $MachinePrecision] + N[(x * y), $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 -1 \cdot 10^{+38}:\\
\;\;\;\;z \cdot t + a \cdot b\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+96}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t + \frac{x \cdot y}{z}\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -9.99999999999999977e37Initial program 98.0%
Taylor expanded in x around 0 86.5%
if -9.99999999999999977e37 < (*.f64 z t) < 2.0000000000000001e96Initial program 99.3%
Taylor expanded in x around inf 90.9%
if 2.0000000000000001e96 < (*.f64 z t) Initial program 97.5%
Taylor expanded in z around inf 99.9%
Taylor expanded in a around 0 95.2%
Final simplification90.7%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* x y) -4e+220) (not (<= (* x y) 7.6e+78))) (* x y) (+ (* z t) (* a b))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((x * y) <= -4e+220) || !((x * y) <= 7.6e+78)) {
tmp = x * y;
} else {
tmp = (z * t) + (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) <= (-4d+220)) .or. (.not. ((x * y) <= 7.6d+78))) then
tmp = x * y
else
tmp = (z * t) + (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) <= -4e+220) || !((x * y) <= 7.6e+78)) {
tmp = x * y;
} else {
tmp = (z * t) + (a * b);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((x * y) <= -4e+220) or not ((x * y) <= 7.6e+78): tmp = x * y else: tmp = (z * t) + (a * b) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(x * y) <= -4e+220) || !(Float64(x * y) <= 7.6e+78)) tmp = Float64(x * y); else tmp = Float64(Float64(z * t) + Float64(a * b)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (((x * y) <= -4e+220) || ~(((x * y) <= 7.6e+78))) tmp = x * y; else tmp = (z * t) + (a * b); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -4e+220], N[Not[LessEqual[N[(x * y), $MachinePrecision], 7.6e+78]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(N[(z * t), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -4 \cdot 10^{+220} \lor \neg \left(x \cdot y \leq 7.6 \cdot 10^{+78}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot t + a \cdot b\\
\end{array}
\end{array}
if (*.f64 x y) < -4e220 or 7.5999999999999998e78 < (*.f64 x y) Initial program 95.0%
Taylor expanded in x around inf 90.0%
Taylor expanded in b around inf 78.3%
associate-/l*76.7%
Simplified76.7%
Taylor expanded in b around 0 79.6%
if -4e220 < (*.f64 x y) < 7.5999999999999998e78Initial program 100.0%
Taylor expanded in x around 0 84.2%
Final simplification83.1%
(FPCore (x y z t a b) :precision binary64 (if (<= (* z t) -1e+38) (+ (* z t) (* a b)) (if (<= (* z t) 5e+45) (+ (* a b) (* x y)) (+ (* z t) (* x y)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((z * t) <= -1e+38) {
tmp = (z * t) + (a * b);
} else if ((z * t) <= 5e+45) {
tmp = (a * b) + (x * y);
} else {
tmp = (z * t) + (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 ((z * t) <= (-1d+38)) then
tmp = (z * t) + (a * b)
else if ((z * t) <= 5d+45) then
tmp = (a * b) + (x * y)
else
tmp = (z * t) + (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 ((z * t) <= -1e+38) {
tmp = (z * t) + (a * b);
} else if ((z * t) <= 5e+45) {
tmp = (a * b) + (x * y);
} else {
tmp = (z * t) + (x * y);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (z * t) <= -1e+38: tmp = (z * t) + (a * b) elif (z * t) <= 5e+45: tmp = (a * b) + (x * y) else: tmp = (z * t) + (x * y) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(z * t) <= -1e+38) tmp = Float64(Float64(z * t) + Float64(a * b)); elseif (Float64(z * t) <= 5e+45) tmp = Float64(Float64(a * b) + Float64(x * y)); else tmp = Float64(Float64(z * t) + Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((z * t) <= -1e+38) tmp = (z * t) + (a * b); elseif ((z * t) <= 5e+45) tmp = (a * b) + (x * y); else tmp = (z * t) + (x * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(z * t), $MachinePrecision], -1e+38], N[(N[(z * t), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+45], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+38}:\\
\;\;\;\;z \cdot t + a \cdot b\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+45}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot t + x \cdot y\\
\end{array}
\end{array}
if (*.f64 z t) < -9.99999999999999977e37Initial program 98.0%
Taylor expanded in x around 0 86.5%
if -9.99999999999999977e37 < (*.f64 z t) < 5e45Initial program 99.3%
Taylor expanded in x around inf 92.8%
if 5e45 < (*.f64 z t) Initial program 98.1%
Taylor expanded in b around inf 80.5%
associate-+r+80.5%
associate-/l*75.1%
associate-/l*73.2%
Simplified73.2%
Taylor expanded in b around 0 87.2%
Final simplification90.4%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -1.1e-22) (not (<= (* a b) 7e-35))) (* a b) (* x y)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -1.1e-22) || !((a * b) <= 7e-35)) {
tmp = a * b;
} 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 (((a * b) <= (-1.1d-22)) .or. (.not. ((a * b) <= 7d-35))) then
tmp = a * b
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 (((a * b) <= -1.1e-22) || !((a * b) <= 7e-35)) {
tmp = a * b;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -1.1e-22) or not ((a * b) <= 7e-35): tmp = a * b else: tmp = x * y return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -1.1e-22) || !(Float64(a * b) <= 7e-35)) tmp = Float64(a * b); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (((a * b) <= -1.1e-22) || ~(((a * b) <= 7e-35))) tmp = a * b; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -1.1e-22], N[Not[LessEqual[N[(a * b), $MachinePrecision], 7e-35]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(x * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.1 \cdot 10^{-22} \lor \neg \left(a \cdot b \leq 7 \cdot 10^{-35}\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
\end{array}
if (*.f64 a b) < -1.1e-22 or 6.99999999999999992e-35 < (*.f64 a b) Initial program 99.2%
Taylor expanded in a around inf 62.3%
if -1.1e-22 < (*.f64 a b) < 6.99999999999999992e-35Initial program 98.3%
Taylor expanded in x around inf 56.4%
Taylor expanded in b around inf 43.9%
associate-/l*40.6%
Simplified40.6%
Taylor expanded in b around 0 48.3%
Final simplification55.8%
(FPCore (x y z t a b) :precision binary64 (+ (* a b) (+ (* z t) (* x y))))
double code(double x, double y, double z, double t, double a, double b) {
return (a * b) + ((z * t) + (x * y));
}
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) + ((z * t) + (x * y))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return (a * b) + ((z * t) + (x * y));
}
def code(x, y, z, t, a, b): return (a * b) + ((z * t) + (x * y))
function code(x, y, z, t, a, b) return Float64(Float64(a * b) + Float64(Float64(z * t) + Float64(x * y))) end
function tmp = code(x, y, z, t, a, b) tmp = (a * b) + ((z * t) + (x * y)); end
code[x_, y_, z_, t_, a_, b_] := N[(N[(a * b), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot b + \left(z \cdot t + x \cdot y\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 38.5%
Final simplification38.5%
herbie shell --seed 2024082
(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)))