
(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 (let* ((t_1 (+ (* a b) (+ (* x y) (* z t))))) (if (<= t_1 INFINITY) t_1 (* y (+ x (* a (/ b 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 = y * (x + (a * (b / 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 = y * (x + (a * (b / 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 = y * (x + (a * (b / 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(y * Float64(x + Float64(a * Float64(b / 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 = y * (x + (a * (b / 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[(y * N[(x + N[(a * N[(b / y), $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}:\\
\;\;\;\;y \cdot \left(x + a \cdot \frac{b}{y}\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) < +inf.0Initial program 100.0%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
Taylor expanded in x around inf 50.0%
Taylor expanded in y around inf 50.0%
associate-*r/83.3%
Simplified83.3%
Final simplification99.6%
(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 97.6%
associate-+l+97.6%
fma-define98.0%
fma-define98.8%
Simplified98.8%
(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 97.6%
+-commutative97.6%
fma-define98.4%
fma-define98.8%
Simplified98.8%
(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 97.6%
fma-define98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x y z t a b)
:precision binary64
(if (<= (* a b) -1.15e+156)
(* a b)
(if (<= (* a b) -8.5e-76)
(* x y)
(if (<= (* a b) -9.5e-198)
(* z t)
(if (<= (* a b) 3.2e+52) (* x y) (* a b))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -1.15e+156) {
tmp = a * b;
} else if ((a * b) <= -8.5e-76) {
tmp = x * y;
} else if ((a * b) <= -9.5e-198) {
tmp = z * t;
} else if ((a * b) <= 3.2e+52) {
tmp = x * y;
} else {
tmp = a * b;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((a * b) <= (-1.15d+156)) then
tmp = a * b
else if ((a * b) <= (-8.5d-76)) then
tmp = x * y
else if ((a * b) <= (-9.5d-198)) then
tmp = z * t
else if ((a * b) <= 3.2d+52) then
tmp = x * y
else
tmp = a * b
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -1.15e+156) {
tmp = a * b;
} else if ((a * b) <= -8.5e-76) {
tmp = x * y;
} else if ((a * b) <= -9.5e-198) {
tmp = z * t;
} else if ((a * b) <= 3.2e+52) {
tmp = x * y;
} else {
tmp = a * b;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -1.15e+156: tmp = a * b elif (a * b) <= -8.5e-76: tmp = x * y elif (a * b) <= -9.5e-198: tmp = z * t elif (a * b) <= 3.2e+52: tmp = x * y else: tmp = a * b return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -1.15e+156) tmp = Float64(a * b); elseif (Float64(a * b) <= -8.5e-76) tmp = Float64(x * y); elseif (Float64(a * b) <= -9.5e-198) tmp = Float64(z * t); elseif (Float64(a * b) <= 3.2e+52) tmp = Float64(x * y); else tmp = Float64(a * b); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((a * b) <= -1.15e+156) tmp = a * b; elseif ((a * b) <= -8.5e-76) tmp = x * y; elseif ((a * b) <= -9.5e-198) tmp = z * t; elseif ((a * b) <= 3.2e+52) tmp = x * y; else tmp = a * b; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -1.15e+156], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -8.5e-76], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -9.5e-198], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 3.2e+52], N[(x * y), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.15 \cdot 10^{+156}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -8.5 \cdot 10^{-76}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq -9.5 \cdot 10^{-198}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 3.2 \cdot 10^{+52}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\end{array}
if (*.f64 a b) < -1.1499999999999999e156 or 3.2e52 < (*.f64 a b) Initial program 95.0%
fma-define95.0%
Simplified95.0%
Taylor expanded in a around inf 84.2%
if -1.1499999999999999e156 < (*.f64 a b) < -8.50000000000000038e-76 or -9.4999999999999997e-198 < (*.f64 a b) < 3.2e52Initial program 99.3%
Taylor expanded in x around inf 64.4%
Taylor expanded in y around inf 63.8%
associate-*r/60.5%
Simplified60.5%
Taylor expanded in x around inf 51.8%
if -8.50000000000000038e-76 < (*.f64 a b) < -9.4999999999999997e-198Initial program 95.8%
fma-define100.0%
Simplified100.0%
Taylor expanded in y around inf 92.2%
+-commutative92.2%
associate-/l*88.1%
Simplified88.1%
Taylor expanded in t around inf 72.7%
Taylor expanded in y around 0 60.0%
Final simplification62.7%
(FPCore (x y z t a b) :precision binary64 (if (<= (* a b) -200000000000.0) (+ (* a b) (* x y)) (if (<= (* a b) 1e+49) (+ (* x y) (* z t)) (+ (* a b) (* z t)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -200000000000.0) {
tmp = (a * b) + (x * y);
} else if ((a * b) <= 1e+49) {
tmp = (x * y) + (z * t);
} 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 ((a * b) <= (-200000000000.0d0)) then
tmp = (a * b) + (x * y)
else if ((a * b) <= 1d+49) then
tmp = (x * y) + (z * t)
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 ((a * b) <= -200000000000.0) {
tmp = (a * b) + (x * y);
} else if ((a * b) <= 1e+49) {
tmp = (x * y) + (z * t);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -200000000000.0: tmp = (a * b) + (x * y) elif (a * b) <= 1e+49: tmp = (x * y) + (z * t) else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -200000000000.0) tmp = Float64(Float64(a * b) + Float64(x * y)); elseif (Float64(a * b) <= 1e+49) tmp = Float64(Float64(x * y) + Float64(z * t)); 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 ((a * b) <= -200000000000.0) tmp = (a * b) + (x * y); elseif ((a * b) <= 1e+49) tmp = (x * y) + (z * t); else tmp = (a * b) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -200000000000.0], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1e+49], N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -200000000000:\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 10^{+49}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -2e11Initial program 93.7%
Taylor expanded in x around inf 89.3%
if -2e11 < (*.f64 a b) < 9.99999999999999946e48Initial program 99.3%
fma-define100.0%
Simplified100.0%
Taylor expanded in y around inf 95.6%
+-commutative95.6%
associate-/l*90.4%
Simplified90.4%
Taylor expanded in t around inf 83.8%
Taylor expanded in y around 0 87.5%
if 9.99999999999999946e48 < (*.f64 a b) Initial program 97.6%
fma-define97.6%
Simplified97.6%
Taylor expanded in x around 0 93.1%
Final simplification88.8%
(FPCore (x y z t a b) :precision binary64 (if (<= (* a b) -1.45e+156) (* a b) (if (<= (* a b) 1.8e+50) (+ (* x y) (* z t)) (+ (* a b) (* z t)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((a * b) <= -1.45e+156) {
tmp = a * b;
} else if ((a * b) <= 1.8e+50) {
tmp = (x * y) + (z * t);
} 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 ((a * b) <= (-1.45d+156)) then
tmp = a * b
else if ((a * b) <= 1.8d+50) then
tmp = (x * y) + (z * t)
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 ((a * b) <= -1.45e+156) {
tmp = a * b;
} else if ((a * b) <= 1.8e+50) {
tmp = (x * y) + (z * t);
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (a * b) <= -1.45e+156: tmp = a * b elif (a * b) <= 1.8e+50: tmp = (x * y) + (z * t) else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(a * b) <= -1.45e+156) tmp = Float64(a * b); elseif (Float64(a * b) <= 1.8e+50) tmp = Float64(Float64(x * y) + Float64(z * t)); 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 ((a * b) <= -1.45e+156) tmp = a * b; elseif ((a * b) <= 1.8e+50) tmp = (x * y) + (z * t); else tmp = (a * b) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -1.45e+156], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1.8e+50], N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.45 \cdot 10^{+156}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 1.8 \cdot 10^{+50}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -1.45000000000000005e156Initial program 92.1%
fma-define92.1%
Simplified92.1%
Taylor expanded in a around inf 94.5%
if -1.45000000000000005e156 < (*.f64 a b) < 1.79999999999999993e50Initial program 98.8%
fma-define99.4%
Simplified99.4%
Taylor expanded in y around inf 95.2%
+-commutative95.2%
associate-/l*89.0%
Simplified89.0%
Taylor expanded in t around inf 81.4%
Taylor expanded in y around 0 84.6%
if 1.79999999999999993e50 < (*.f64 a b) Initial program 97.6%
fma-define97.6%
Simplified97.6%
Taylor expanded in x around 0 93.1%
Final simplification87.4%
(FPCore (x y z t a b) :precision binary64 (if (or (<= y -1.85e+135) (not (<= y 1.85e+154))) (* x y) (+ (* a b) (* z t))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -1.85e+135) || !(y <= 1.85e+154)) {
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 ((y <= (-1.85d+135)) .or. (.not. (y <= 1.85d+154))) 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 ((y <= -1.85e+135) || !(y <= 1.85e+154)) {
tmp = x * y;
} else {
tmp = (a * b) + (z * t);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (y <= -1.85e+135) or not (y <= 1.85e+154): tmp = x * y else: tmp = (a * b) + (z * t) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((y <= -1.85e+135) || !(y <= 1.85e+154)) 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 ((y <= -1.85e+135) || ~((y <= 1.85e+154))) tmp = x * y; else tmp = (a * b) + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[y, -1.85e+135], N[Not[LessEqual[y, 1.85e+154]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.85 \cdot 10^{+135} \lor \neg \left(y \leq 1.85 \cdot 10^{+154}\right):\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\end{array}
if y < -1.84999999999999999e135 or 1.84999999999999997e154 < y Initial program 94.1%
Taylor expanded in x around inf 83.0%
Taylor expanded in y around inf 83.0%
associate-*r/84.4%
Simplified84.4%
Taylor expanded in x around inf 69.8%
if -1.84999999999999999e135 < y < 1.84999999999999997e154Initial program 98.9%
fma-define98.9%
Simplified98.9%
Taylor expanded in x around 0 80.1%
Final simplification77.3%
(FPCore (x y z t a b) :precision binary64 (if (or (<= (* a b) -2.1e+106) (not (<= (* a b) 8.1e+27))) (* a b) (* z t)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((a * b) <= -2.1e+106) || !((a * b) <= 8.1e+27)) {
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) <= (-2.1d+106)) .or. (.not. ((a * b) <= 8.1d+27))) 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) <= -2.1e+106) || !((a * b) <= 8.1e+27)) {
tmp = a * b;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((a * b) <= -2.1e+106) or not ((a * b) <= 8.1e+27): tmp = a * b else: tmp = z * t return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((Float64(a * b) <= -2.1e+106) || !(Float64(a * b) <= 8.1e+27)) 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) <= -2.1e+106) || ~(((a * b) <= 8.1e+27))) 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], -2.1e+106], N[Not[LessEqual[N[(a * b), $MachinePrecision], 8.1e+27]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -2.1 \cdot 10^{+106} \lor \neg \left(a \cdot b \leq 8.1 \cdot 10^{+27}\right):\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if (*.f64 a b) < -2.10000000000000005e106 or 8.1000000000000003e27 < (*.f64 a b) Initial program 95.7%
fma-define95.7%
Simplified95.7%
Taylor expanded in a around inf 76.1%
if -2.10000000000000005e106 < (*.f64 a b) < 8.1000000000000003e27Initial program 98.7%
fma-define99.4%
Simplified99.4%
Taylor expanded in y around inf 95.3%
+-commutative95.3%
associate-/l*88.7%
Simplified88.7%
Taylor expanded in t around inf 82.3%
Taylor expanded in y around 0 45.1%
Final simplification56.5%
(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 97.6%
fma-define98.0%
Simplified98.0%
Taylor expanded in a around inf 38.3%
herbie shell --seed 2024145
(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)))