
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
code = (((x * y) + (z * t)) + (a * b)) + (c * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
def code(x, y, z, t, a, b, c, i): return (((x * y) + (z * t)) + (a * b)) + (c * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((x * y) + (z * t)) + (a * b)) + (c * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
code = (((x * y) + (z * t)) + (a * b)) + (c * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
def code(x, y, z, t, a, b, c, i): return (((x * y) + (z * t)) + (a * b)) + (c * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((x * y) + (z * t)) + (a * b)) + (c * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\end{array}
(FPCore (x y z t a b c i) :precision binary64 (fma z t (fma y x (fma i c (* b a)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(z, t, fma(y, x, fma(i, c, (b * a))));
}
function code(x, y, z, t, a, b, c, i) return fma(z, t, fma(y, x, fma(i, c, Float64(b * a)))) end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(z * t + N[(y * x + N[(i * c + N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, \mathsf{fma}\left(i, c, b \cdot a\right)\right)\right)
\end{array}
Initial program 96.1%
lift-+.f64N/A
lift-+.f64N/A
associate-+l+N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6498.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.4
Applied rewrites98.4%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* x y) -1e+156)
(* y x)
(if (<= (* x y) -1e+92)
(* t z)
(if (<= (* x y) -2e-154)
(* i c)
(if (<= (* x y) 2e+102) (* b a) (* y x))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -1e+156) {
tmp = y * x;
} else if ((x * y) <= -1e+92) {
tmp = t * z;
} else if ((x * y) <= -2e-154) {
tmp = i * c;
} else if ((x * y) <= 2e+102) {
tmp = b * a;
} else {
tmp = y * x;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if ((x * y) <= (-1d+156)) then
tmp = y * x
else if ((x * y) <= (-1d+92)) then
tmp = t * z
else if ((x * y) <= (-2d-154)) then
tmp = i * c
else if ((x * y) <= 2d+102) then
tmp = b * a
else
tmp = y * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -1e+156) {
tmp = y * x;
} else if ((x * y) <= -1e+92) {
tmp = t * z;
} else if ((x * y) <= -2e-154) {
tmp = i * c;
} else if ((x * y) <= 2e+102) {
tmp = b * a;
} else {
tmp = y * x;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (x * y) <= -1e+156: tmp = y * x elif (x * y) <= -1e+92: tmp = t * z elif (x * y) <= -2e-154: tmp = i * c elif (x * y) <= 2e+102: tmp = b * a else: tmp = y * x return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -1e+156) tmp = Float64(y * x); elseif (Float64(x * y) <= -1e+92) tmp = Float64(t * z); elseif (Float64(x * y) <= -2e-154) tmp = Float64(i * c); elseif (Float64(x * y) <= 2e+102) tmp = Float64(b * a); else tmp = Float64(y * x); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((x * y) <= -1e+156) tmp = y * x; elseif ((x * y) <= -1e+92) tmp = t * z; elseif ((x * y) <= -2e-154) tmp = i * c; elseif ((x * y) <= 2e+102) tmp = b * a; else tmp = y * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e+156], N[(y * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -1e+92], N[(t * z), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -2e-154], N[(i * c), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+102], N[(b * a), $MachinePrecision], N[(y * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+156}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{+92}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;x \cdot y \leq -2 \cdot 10^{-154}:\\
\;\;\;\;i \cdot c\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+102}:\\
\;\;\;\;b \cdot a\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -9.9999999999999998e155 or 1.99999999999999995e102 < (*.f64 x y) Initial program 93.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6435.5
Applied rewrites35.5%
Taylor expanded in c around 0
Applied rewrites22.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6475.5
Applied rewrites75.5%
if -9.9999999999999998e155 < (*.f64 x y) < -1e92Initial program 99.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in c around 0
Applied rewrites88.4%
Taylor expanded in z around 0
Applied rewrites12.2%
Taylor expanded in z around inf
lower-*.f6477.5
Applied rewrites77.5%
if -1e92 < (*.f64 x y) < -1.9999999999999999e-154Initial program 95.9%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6443.6
Applied rewrites43.6%
if -1.9999999999999999e-154 < (*.f64 x y) < 1.99999999999999995e102Initial program 98.2%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6492.9
Applied rewrites92.9%
Taylor expanded in c around 0
Applied rewrites67.1%
Taylor expanded in z around 0
Applied rewrites42.7%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* x y) -5e+239)
(* y x)
(if (<= (* x y) -1e+92)
(fma a b (* t z))
(if (<= (* x y) 2e+102) (fma b a (* c i)) (* y x)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((x * y) <= -5e+239) {
tmp = y * x;
} else if ((x * y) <= -1e+92) {
tmp = fma(a, b, (t * z));
} else if ((x * y) <= 2e+102) {
tmp = fma(b, a, (c * i));
} else {
tmp = y * x;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -5e+239) tmp = Float64(y * x); elseif (Float64(x * y) <= -1e+92) tmp = fma(a, b, Float64(t * z)); elseif (Float64(x * y) <= 2e+102) tmp = fma(b, a, Float64(c * i)); else tmp = Float64(y * x); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -5e+239], N[(y * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -1e+92], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+102], N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision], N[(y * x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+239}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{+92}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+102}:\\
\;\;\;\;\mathsf{fma}\left(b, a, c \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -5.00000000000000007e239 or 1.99999999999999995e102 < (*.f64 x y) Initial program 92.2%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6433.0
Applied rewrites33.0%
Taylor expanded in c around 0
Applied rewrites17.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6478.9
Applied rewrites78.9%
if -5.00000000000000007e239 < (*.f64 x y) < -1e92Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6478.3
Applied rewrites78.3%
Taylor expanded in c around 0
Applied rewrites72.7%
if -1e92 < (*.f64 x y) < 1.99999999999999995e102Initial program 97.5%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6478.3
Applied rewrites78.3%
Taylor expanded in x around 0
Applied rewrites70.5%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -5e+49) (not (<= (* a b) 1e+34))) (fma b a (fma i c (* y x))) (fma y x (fma c i (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((a * b) <= -5e+49) || !((a * b) <= 1e+34)) {
tmp = fma(b, a, fma(i, c, (y * x)));
} else {
tmp = fma(y, x, fma(c, i, (t * z)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(a * b) <= -5e+49) || !(Float64(a * b) <= 1e+34)) tmp = fma(b, a, fma(i, c, Float64(y * x))); else tmp = fma(y, x, fma(c, i, Float64(t * z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -5e+49], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1e+34]], $MachinePrecision]], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * x + N[(c * i + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+49} \lor \neg \left(a \cdot b \leq 10^{+34}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, x, \mathsf{fma}\left(c, i, t \cdot z\right)\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -5.0000000000000004e49 or 9.99999999999999946e33 < (*.f64 a b) Initial program 96.4%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.4
Applied rewrites91.4%
if -5.0000000000000004e49 < (*.f64 a b) < 9.99999999999999946e33Initial program 95.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6495.9
Applied rewrites95.9%
Applied rewrites96.6%
Final simplification94.3%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* a b) -5e+49) (not (<= (* a b) 1e+34))) (fma b a (fma i c (* y x))) (fma i c (fma t z (* y x)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((a * b) <= -5e+49) || !((a * b) <= 1e+34)) {
tmp = fma(b, a, fma(i, c, (y * x)));
} else {
tmp = fma(i, c, fma(t, z, (y * x)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(a * b) <= -5e+49) || !(Float64(a * b) <= 1e+34)) tmp = fma(b, a, fma(i, c, Float64(y * x))); else tmp = fma(i, c, fma(t, z, Float64(y * x))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -5e+49], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1e+34]], $MachinePrecision]], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+49} \lor \neg \left(a \cdot b \leq 10^{+34}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\end{array}
\end{array}
if (*.f64 a b) < -5.0000000000000004e49 or 9.99999999999999946e33 < (*.f64 a b) Initial program 96.4%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.4
Applied rewrites91.4%
if -5.0000000000000004e49 < (*.f64 a b) < 9.99999999999999946e33Initial program 95.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6495.9
Applied rewrites95.9%
Final simplification93.9%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* z t) -2e+53) (not (<= (* z t) 2e+113))) (fma b a (fma i c (* t z))) (fma b a (fma i c (* y x)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((z * t) <= -2e+53) || !((z * t) <= 2e+113)) {
tmp = fma(b, a, fma(i, c, (t * z)));
} else {
tmp = fma(b, a, fma(i, c, (y * x)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(z * t) <= -2e+53) || !(Float64(z * t) <= 2e+113)) tmp = fma(b, a, fma(i, c, Float64(t * z))); else tmp = fma(b, a, fma(i, c, Float64(y * x))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -2e+53], N[Not[LessEqual[N[(z * t), $MachinePrecision], 2e+113]], $MachinePrecision]], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+53} \lor \neg \left(z \cdot t \leq 2 \cdot 10^{+113}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -2e53 or 2e113 < (*.f64 z t) Initial program 89.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6486.7
Applied rewrites86.7%
if -2e53 < (*.f64 z t) < 2e113Initial program 99.4%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6494.8
Applied rewrites94.8%
Final simplification92.0%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -5e+239) (not (<= (* x y) 2e+106))) (* y x) (fma b a (fma i c (* t z)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((x * y) <= -5e+239) || !((x * y) <= 2e+106)) {
tmp = y * x;
} else {
tmp = fma(b, a, fma(i, c, (t * z)));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -5e+239) || !(Float64(x * y) <= 2e+106)) tmp = Float64(y * x); else tmp = fma(b, a, fma(i, c, Float64(t * z))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -5e+239], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2e+106]], $MachinePrecision]], N[(y * x), $MachinePrecision], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+239} \lor \neg \left(x \cdot y \leq 2 \cdot 10^{+106}\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -5.00000000000000007e239 or 2.00000000000000018e106 < (*.f64 x y) Initial program 92.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6432.1
Applied rewrites32.1%
Taylor expanded in c around 0
Applied rewrites16.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6479.9
Applied rewrites79.9%
if -5.00000000000000007e239 < (*.f64 x y) < 2.00000000000000018e106Initial program 97.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6488.0
Applied rewrites88.0%
Final simplification85.6%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -5e+239) (not (<= (* x y) 2e+106))) (* y x) (fma a b (* t z))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((x * y) <= -5e+239) || !((x * y) <= 2e+106)) {
tmp = y * x;
} else {
tmp = fma(a, b, (t * z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(x * y) <= -5e+239) || !(Float64(x * y) <= 2e+106)) tmp = Float64(y * x); else tmp = fma(a, b, Float64(t * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -5e+239], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2e+106]], $MachinePrecision]], N[(y * x), $MachinePrecision], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+239} \lor \neg \left(x \cdot y \leq 2 \cdot 10^{+106}\right):\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -5.00000000000000007e239 or 2.00000000000000018e106 < (*.f64 x y) Initial program 92.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6432.1
Applied rewrites32.1%
Taylor expanded in c around 0
Applied rewrites16.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6479.9
Applied rewrites79.9%
if -5.00000000000000007e239 < (*.f64 x y) < 2.00000000000000018e106Initial program 97.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6488.0
Applied rewrites88.0%
Taylor expanded in c around 0
Applied rewrites61.6%
Final simplification67.0%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* c i) -2e+159) (not (<= (* c i) 5e+273))) (* i c) (* b a)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((c * i) <= -2e+159) || !((c * i) <= 5e+273)) {
tmp = i * c;
} else {
tmp = b * a;
}
return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
real(8) :: tmp
if (((c * i) <= (-2d+159)) .or. (.not. ((c * i) <= 5d+273))) then
tmp = i * c
else
tmp = b * a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((c * i) <= -2e+159) || !((c * i) <= 5e+273)) {
tmp = i * c;
} else {
tmp = b * a;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if ((c * i) <= -2e+159) or not ((c * i) <= 5e+273): tmp = i * c else: tmp = b * a return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((Float64(c * i) <= -2e+159) || !(Float64(c * i) <= 5e+273)) tmp = Float64(i * c); else tmp = Float64(b * a); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if (((c * i) <= -2e+159) || ~(((c * i) <= 5e+273))) tmp = i * c; else tmp = b * a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(c * i), $MachinePrecision], -2e+159], N[Not[LessEqual[N[(c * i), $MachinePrecision], 5e+273]], $MachinePrecision]], N[(i * c), $MachinePrecision], N[(b * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+159} \lor \neg \left(c \cdot i \leq 5 \cdot 10^{+273}\right):\\
\;\;\;\;i \cdot c\\
\mathbf{else}:\\
\;\;\;\;b \cdot a\\
\end{array}
\end{array}
if (*.f64 c i) < -1.9999999999999999e159 or 4.99999999999999961e273 < (*.f64 c i) Initial program 92.9%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6479.5
Applied rewrites79.5%
if -1.9999999999999999e159 < (*.f64 c i) < 4.99999999999999961e273Initial program 97.3%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6464.8
Applied rewrites64.8%
Taylor expanded in c around 0
Applied rewrites57.2%
Taylor expanded in z around 0
Applied rewrites35.1%
Final simplification47.2%
(FPCore (x y z t a b c i) :precision binary64 (* b a))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return b * a;
}
real(8) function code(x, y, z, t, a, b, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
code = b * a
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return b * a;
}
def code(x, y, z, t, a, b, c, i): return b * a
function code(x, y, z, t, a, b, c, i) return Float64(b * a) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = b * a; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(b * a), $MachinePrecision]
\begin{array}{l}
\\
b \cdot a
\end{array}
Initial program 96.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6471.4
Applied rewrites71.4%
Taylor expanded in c around 0
Applied rewrites48.3%
Taylor expanded in z around 0
Applied rewrites28.8%
herbie shell --seed 2024337
(FPCore (x y z t a b c i)
:name "Linear.V4:$cdot from linear-1.19.1.3, C"
:precision binary64
(+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))