
(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 11 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 (if (<= (+ (* b a) (+ (* t z) (* y x))) INFINITY) (fma z t (fma y x (fma i c (* b a)))) (* t z)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((b * a) + ((t * z) + (y * x))) <= ((double) INFINITY)) {
tmp = fma(z, t, fma(y, x, fma(i, c, (b * a))));
} else {
tmp = t * z;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(Float64(b * a) + Float64(Float64(t * z) + Float64(y * x))) <= Inf) tmp = fma(z, t, fma(y, x, fma(i, c, Float64(b * a)))); else tmp = Float64(t * z); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(N[(b * a), $MachinePrecision] + N[(N[(t * z), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(z * t + N[(y * x + N[(i * c + N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t * z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot a + \left(t \cdot z + y \cdot x\right) \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, \mathsf{fma}\left(i, c, b \cdot a\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) < +inf.0Initial program 97.6%
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.f6499.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
Applied rewrites99.2%
if +inf.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) Initial program 0.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6485.7
Applied rewrites85.7%
Taylor expanded in c around 0
Applied rewrites85.7%
Taylor expanded in z around 0
Applied rewrites0.7%
Taylor expanded in z around inf
lower-*.f6485.8
Applied rewrites85.8%
Final simplification98.8%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* t z) -1e+137)
(* t z)
(if (<= (* t z) -1e-26)
(* b a)
(if (<= (* t z) -5e-212)
(* y x)
(if (<= (* t z) 1e-76)
(* c i)
(if (<= (* t z) 4e+112) (* y x) (* t z)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((t * z) <= -1e+137) {
tmp = t * z;
} else if ((t * z) <= -1e-26) {
tmp = b * a;
} else if ((t * z) <= -5e-212) {
tmp = y * x;
} else if ((t * z) <= 1e-76) {
tmp = c * i;
} else if ((t * z) <= 4e+112) {
tmp = y * x;
} else {
tmp = t * z;
}
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 ((t * z) <= (-1d+137)) then
tmp = t * z
else if ((t * z) <= (-1d-26)) then
tmp = b * a
else if ((t * z) <= (-5d-212)) then
tmp = y * x
else if ((t * z) <= 1d-76) then
tmp = c * i
else if ((t * z) <= 4d+112) then
tmp = y * x
else
tmp = t * z
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 ((t * z) <= -1e+137) {
tmp = t * z;
} else if ((t * z) <= -1e-26) {
tmp = b * a;
} else if ((t * z) <= -5e-212) {
tmp = y * x;
} else if ((t * z) <= 1e-76) {
tmp = c * i;
} else if ((t * z) <= 4e+112) {
tmp = y * x;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (t * z) <= -1e+137: tmp = t * z elif (t * z) <= -1e-26: tmp = b * a elif (t * z) <= -5e-212: tmp = y * x elif (t * z) <= 1e-76: tmp = c * i elif (t * z) <= 4e+112: tmp = y * x else: tmp = t * z return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(t * z) <= -1e+137) tmp = Float64(t * z); elseif (Float64(t * z) <= -1e-26) tmp = Float64(b * a); elseif (Float64(t * z) <= -5e-212) tmp = Float64(y * x); elseif (Float64(t * z) <= 1e-76) tmp = Float64(c * i); elseif (Float64(t * z) <= 4e+112) tmp = Float64(y * x); else tmp = Float64(t * z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((t * z) <= -1e+137) tmp = t * z; elseif ((t * z) <= -1e-26) tmp = b * a; elseif ((t * z) <= -5e-212) tmp = y * x; elseif ((t * z) <= 1e-76) tmp = c * i; elseif ((t * z) <= 4e+112) tmp = y * x; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(t * z), $MachinePrecision], -1e+137], N[(t * z), $MachinePrecision], If[LessEqual[N[(t * z), $MachinePrecision], -1e-26], N[(b * a), $MachinePrecision], If[LessEqual[N[(t * z), $MachinePrecision], -5e-212], N[(y * x), $MachinePrecision], If[LessEqual[N[(t * z), $MachinePrecision], 1e-76], N[(c * i), $MachinePrecision], If[LessEqual[N[(t * z), $MachinePrecision], 4e+112], N[(y * x), $MachinePrecision], N[(t * z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \cdot z \leq -1 \cdot 10^{+137}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;t \cdot z \leq -1 \cdot 10^{-26}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;t \cdot z \leq -5 \cdot 10^{-212}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;t \cdot z \leq 10^{-76}:\\
\;\;\;\;c \cdot i\\
\mathbf{elif}\;t \cdot z \leq 4 \cdot 10^{+112}:\\
\;\;\;\;y \cdot x\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -1e137 or 3.9999999999999997e112 < (*.f64 z t) Initial program 90.2%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6493.1
Applied rewrites93.1%
Taylor expanded in c around 0
Applied rewrites81.5%
Taylor expanded in z around 0
Applied rewrites15.6%
Taylor expanded in z around inf
lower-*.f6469.7
Applied rewrites69.7%
if -1e137 < (*.f64 z t) < -1e-26Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6475.5
Applied rewrites75.5%
Taylor expanded in c around 0
Applied rewrites69.0%
Taylor expanded in z around 0
Applied rewrites52.6%
if -1e-26 < (*.f64 z t) < -5.00000000000000043e-212 or 9.99999999999999927e-77 < (*.f64 z t) < 3.9999999999999997e112Initial program 96.3%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6451.9
Applied rewrites51.9%
Taylor expanded in c around 0
Applied rewrites25.8%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6448.4
Applied rewrites48.4%
if -5.00000000000000043e-212 < (*.f64 z t) < 9.99999999999999927e-77Initial program 96.6%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6440.7
Applied rewrites40.7%
Final simplification53.1%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* y x) -5e+100)
(fma i c (fma t z (* y x)))
(if (<= (* y x) 2e-99)
(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 ((y * x) <= -5e+100) {
tmp = fma(i, c, fma(t, z, (y * x)));
} else if ((y * x) <= 2e-99) {
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(y * x) <= -5e+100) tmp = fma(i, c, fma(t, z, Float64(y * x))); elseif (Float64(y * x) <= 2e-99) 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[LessEqual[N[(y * x), $MachinePrecision], -5e+100], N[(i * c + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * x), $MachinePrecision], 2e-99], 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}\;y \cdot x \leq -5 \cdot 10^{+100}:\\
\;\;\;\;\mathsf{fma}\left(i, c, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\mathbf{elif}\;y \cdot x \leq 2 \cdot 10^{-99}:\\
\;\;\;\;\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 x y) < -4.9999999999999999e100Initial program 91.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6494.3
Applied rewrites94.3%
if -4.9999999999999999e100 < (*.f64 x y) < 2e-99Initial program 95.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6495.9
Applied rewrites95.9%
if 2e-99 < (*.f64 x y) Initial program 95.2%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6486.2
Applied rewrites86.2%
Final simplification92.5%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma b a (fma i c (* t z)))))
(if (<= (* t z) -4e+160)
t_1
(if (<= (* t z) 1e+112) (fma b a (fma i c (* y x))) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(b, a, fma(i, c, (t * z)));
double tmp;
if ((t * z) <= -4e+160) {
tmp = t_1;
} else if ((t * z) <= 1e+112) {
tmp = fma(b, a, fma(i, c, (y * x)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(b, a, fma(i, c, Float64(t * z))) tmp = 0.0 if (Float64(t * z) <= -4e+160) tmp = t_1; elseif (Float64(t * z) <= 1e+112) tmp = fma(b, a, fma(i, c, Float64(y * x))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t * z), $MachinePrecision], -4e+160], t$95$1, If[LessEqual[N[(t * z), $MachinePrecision], 1e+112], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{if}\;t \cdot z \leq -4 \cdot 10^{+160}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \cdot z \leq 10^{+112}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -4.00000000000000003e160 or 9.9999999999999993e111 < (*.f64 z t) Initial program 90.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6494.2
Applied rewrites94.2%
if -4.00000000000000003e160 < (*.f64 z t) < 9.9999999999999993e111Initial program 97.1%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.0
Applied rewrites91.0%
Final simplification92.0%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma i c (* y x))))
(if (<= (* y x) -5e+158)
t_1
(if (<= (* y x) 5e+86) (fma b a (fma i c (* t z))) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(i, c, (y * x));
double tmp;
if ((y * x) <= -5e+158) {
tmp = t_1;
} else if ((y * x) <= 5e+86) {
tmp = fma(b, a, fma(i, c, (t * z)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(i, c, Float64(y * x)) tmp = 0.0 if (Float64(y * x) <= -5e+158) tmp = t_1; elseif (Float64(y * x) <= 5e+86) tmp = fma(b, a, fma(i, c, Float64(t * z))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y * x), $MachinePrecision], -5e+158], t$95$1, If[LessEqual[N[(y * x), $MachinePrecision], 5e+86], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(i, c, y \cdot x\right)\\
\mathbf{if}\;y \cdot x \leq -5 \cdot 10^{+158}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \cdot x \leq 5 \cdot 10^{+86}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x y) < -4.9999999999999996e158 or 4.9999999999999998e86 < (*.f64 x y) Initial program 92.5%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6489.1
Applied rewrites89.1%
Taylor expanded in x around 0
Applied rewrites27.1%
Taylor expanded in c around 0
Applied rewrites76.9%
Taylor expanded in a around 0
Applied rewrites81.9%
if -4.9999999999999996e158 < (*.f64 x y) < 4.9999999999999998e86Initial program 96.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6491.3
Applied rewrites91.3%
Final simplification88.3%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* t z) -1e+137) (* t z) (if (<= (* t z) -1e-26) (* b a) (if (<= (* t z) 5e+128) (* 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 ((t * z) <= -1e+137) {
tmp = t * z;
} else if ((t * z) <= -1e-26) {
tmp = b * a;
} else if ((t * z) <= 5e+128) {
tmp = c * i;
} else {
tmp = t * z;
}
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 ((t * z) <= (-1d+137)) then
tmp = t * z
else if ((t * z) <= (-1d-26)) then
tmp = b * a
else if ((t * z) <= 5d+128) then
tmp = c * i
else
tmp = t * z
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 ((t * z) <= -1e+137) {
tmp = t * z;
} else if ((t * z) <= -1e-26) {
tmp = b * a;
} else if ((t * z) <= 5e+128) {
tmp = c * i;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (t * z) <= -1e+137: tmp = t * z elif (t * z) <= -1e-26: tmp = b * a elif (t * z) <= 5e+128: tmp = c * i else: tmp = t * z return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(t * z) <= -1e+137) tmp = Float64(t * z); elseif (Float64(t * z) <= -1e-26) tmp = Float64(b * a); elseif (Float64(t * z) <= 5e+128) tmp = Float64(c * i); else tmp = Float64(t * z); end return tmp end
function tmp_2 = code(x, y, z, t, a, b, c, i) tmp = 0.0; if ((t * z) <= -1e+137) tmp = t * z; elseif ((t * z) <= -1e-26) tmp = b * a; elseif ((t * z) <= 5e+128) tmp = c * i; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(t * z), $MachinePrecision], -1e+137], N[(t * z), $MachinePrecision], If[LessEqual[N[(t * z), $MachinePrecision], -1e-26], N[(b * a), $MachinePrecision], If[LessEqual[N[(t * z), $MachinePrecision], 5e+128], N[(c * i), $MachinePrecision], N[(t * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \cdot z \leq -1 \cdot 10^{+137}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;t \cdot z \leq -1 \cdot 10^{-26}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;t \cdot z \leq 5 \cdot 10^{+128}:\\
\;\;\;\;c \cdot i\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (*.f64 z t) < -1e137 or 5e128 < (*.f64 z t) Initial program 90.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6493.0
Applied rewrites93.0%
Taylor expanded in c around 0
Applied rewrites82.4%
Taylor expanded in z around 0
Applied rewrites15.8%
Taylor expanded in z around inf
lower-*.f6470.4
Applied rewrites70.4%
if -1e137 < (*.f64 z t) < -1e-26Initial program 100.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6475.5
Applied rewrites75.5%
Taylor expanded in c around 0
Applied rewrites69.0%
Taylor expanded in z around 0
Applied rewrites52.6%
if -1e-26 < (*.f64 z t) < 5e128Initial program 96.5%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6436.7
Applied rewrites36.7%
Final simplification49.3%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma a b (* t z))))
(if (<= (* t z) -1e-26)
t_1
(if (<= (* t z) 5e+128) (fma i c (* y x)) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(a, b, (t * z));
double tmp;
if ((t * z) <= -1e-26) {
tmp = t_1;
} else if ((t * z) <= 5e+128) {
tmp = fma(i, c, (y * x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(a, b, Float64(t * z)) tmp = 0.0 if (Float64(t * z) <= -1e-26) tmp = t_1; elseif (Float64(t * z) <= 5e+128) tmp = fma(i, c, Float64(y * x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t * z), $MachinePrecision], -1e-26], t$95$1, If[LessEqual[N[(t * z), $MachinePrecision], 5e+128], N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{if}\;t \cdot z \leq -1 \cdot 10^{-26}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \cdot z \leq 5 \cdot 10^{+128}:\\
\;\;\;\;\mathsf{fma}\left(i, c, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -1e-26 or 5e128 < (*.f64 z t) Initial program 92.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6488.2
Applied rewrites88.2%
Taylor expanded in c around 0
Applied rewrites78.7%
if -1e-26 < (*.f64 z t) < 5e128Initial program 96.5%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6492.8
Applied rewrites92.8%
Taylor expanded in x around 0
Applied rewrites60.9%
Taylor expanded in c around 0
Applied rewrites60.3%
Taylor expanded in a around 0
Applied rewrites70.0%
Final simplification73.8%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma a b (* t z))))
(if (<= (* t z) -4e+160)
t_1
(if (<= (* t z) 1e+112) (fma b a (* y x)) t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(a, b, (t * z));
double tmp;
if ((t * z) <= -4e+160) {
tmp = t_1;
} else if ((t * z) <= 1e+112) {
tmp = fma(b, a, (y * x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) t_1 = fma(a, b, Float64(t * z)) tmp = 0.0 if (Float64(t * z) <= -4e+160) tmp = t_1; elseif (Float64(t * z) <= 1e+112) tmp = fma(b, a, Float64(y * x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t * z), $MachinePrecision], -4e+160], t$95$1, If[LessEqual[N[(t * z), $MachinePrecision], 1e+112], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{if}\;t \cdot z \leq -4 \cdot 10^{+160}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \cdot z \leq 10^{+112}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -4.00000000000000003e160 or 9.9999999999999993e111 < (*.f64 z t) Initial program 90.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6494.2
Applied rewrites94.2%
Taylor expanded in c around 0
Applied rewrites83.5%
if -4.00000000000000003e160 < (*.f64 z t) < 9.9999999999999993e111Initial program 97.1%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.0
Applied rewrites91.0%
Taylor expanded in x around 0
Applied rewrites60.3%
Taylor expanded in c around 0
Applied rewrites63.2%
Final simplification69.5%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* y x) -5e+158) (* y x) (if (<= (* y x) 5e+86) (fma a b (* 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 ((y * x) <= -5e+158) {
tmp = y * x;
} else if ((y * x) <= 5e+86) {
tmp = fma(a, b, (t * z));
} else {
tmp = y * x;
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(y * x) <= -5e+158) tmp = Float64(y * x); elseif (Float64(y * x) <= 5e+86) tmp = fma(a, b, Float64(t * z)); else tmp = Float64(y * x); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(y * x), $MachinePrecision], -5e+158], N[(y * x), $MachinePrecision], If[LessEqual[N[(y * x), $MachinePrecision], 5e+86], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot x \leq -5 \cdot 10^{+158}:\\
\;\;\;\;y \cdot x\\
\mathbf{elif}\;y \cdot x \leq 5 \cdot 10^{+86}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot x\\
\end{array}
\end{array}
if (*.f64 x y) < -4.9999999999999996e158 or 4.9999999999999998e86 < (*.f64 x y) Initial program 92.5%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6440.8
Applied rewrites40.8%
Taylor expanded in c around 0
Applied rewrites28.0%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f6469.7
Applied rewrites69.7%
if -4.9999999999999996e158 < (*.f64 x y) < 4.9999999999999998e86Initial program 96.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6491.3
Applied rewrites91.3%
Taylor expanded in c around 0
Applied rewrites64.1%
Final simplification65.8%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* b a) -2e+259) (* b a) (if (<= (* b a) 1e+30) (* c i) (* b a))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((b * a) <= -2e+259) {
tmp = b * a;
} else if ((b * a) <= 1e+30) {
tmp = c * i;
} 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 ((b * a) <= (-2d+259)) then
tmp = b * a
else if ((b * a) <= 1d+30) then
tmp = c * i
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 ((b * a) <= -2e+259) {
tmp = b * a;
} else if ((b * a) <= 1e+30) {
tmp = c * i;
} else {
tmp = b * a;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): tmp = 0 if (b * a) <= -2e+259: tmp = b * a elif (b * a) <= 1e+30: tmp = c * i else: tmp = b * a return tmp
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(b * a) <= -2e+259) tmp = Float64(b * a); elseif (Float64(b * a) <= 1e+30) tmp = Float64(c * i); 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 ((b * a) <= -2e+259) tmp = b * a; elseif ((b * a) <= 1e+30) tmp = c * i; else tmp = b * a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(b * a), $MachinePrecision], -2e+259], N[(b * a), $MachinePrecision], If[LessEqual[N[(b * a), $MachinePrecision], 1e+30], N[(c * i), $MachinePrecision], N[(b * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot a \leq -2 \cdot 10^{+259}:\\
\;\;\;\;b \cdot a\\
\mathbf{elif}\;b \cdot a \leq 10^{+30}:\\
\;\;\;\;c \cdot i\\
\mathbf{else}:\\
\;\;\;\;b \cdot a\\
\end{array}
\end{array}
if (*.f64 a b) < -2e259 or 1e30 < (*.f64 a b) Initial program 90.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6480.8
Applied rewrites80.8%
Taylor expanded in c around 0
Applied rewrites77.4%
Taylor expanded in z around 0
Applied rewrites63.7%
if -2e259 < (*.f64 a b) < 1e30Initial program 97.0%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6435.4
Applied rewrites35.4%
Final simplification44.9%
(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 94.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6475.5
Applied rewrites75.5%
Taylor expanded in c around 0
Applied rewrites52.8%
Taylor expanded in z around 0
Applied rewrites27.1%
herbie shell --seed 2024308
(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)))