
(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 (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.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6498.8
Applied rewrites98.8%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* c i) -5e+34)
(fma i c (* t z))
(if (<= (* c i) -5e-217)
(fma b a (* y x))
(if (<= (* c i) 2e+32)
(fma a b (* t z))
(if (<= (* c i) 5e+152) (fma i c (* y x)) (fma b a (* c i)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if ((c * i) <= -5e+34) {
tmp = fma(i, c, (t * z));
} else if ((c * i) <= -5e-217) {
tmp = fma(b, a, (y * x));
} else if ((c * i) <= 2e+32) {
tmp = fma(a, b, (t * z));
} else if ((c * i) <= 5e+152) {
tmp = fma(i, c, (y * x));
} else {
tmp = fma(b, a, (c * i));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(c * i) <= -5e+34) tmp = fma(i, c, Float64(t * z)); elseif (Float64(c * i) <= -5e-217) tmp = fma(b, a, Float64(y * x)); elseif (Float64(c * i) <= 2e+32) tmp = fma(a, b, Float64(t * z)); elseif (Float64(c * i) <= 5e+152) tmp = fma(i, c, Float64(y * x)); else tmp = fma(b, a, Float64(c * i)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -5e+34], N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -5e-217], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 2e+32], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e+152], N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+34}:\\
\;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\right)\\
\mathbf{elif}\;c \cdot i \leq -5 \cdot 10^{-217}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{fma}\left(i, c, y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, c \cdot i\right)\\
\end{array}
\end{array}
if (*.f64 c i) < -4.9999999999999998e34Initial program 96.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6491.7
Applied rewrites91.7%
Taylor expanded in x around 0
Applied rewrites84.9%
if -4.9999999999999998e34 < (*.f64 c i) < -5.0000000000000002e-217Initial program 100.0%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6480.6
Applied rewrites80.6%
Taylor expanded in x around 0
Applied rewrites43.2%
Taylor expanded in c around 0
Applied rewrites77.4%
if -5.0000000000000002e-217 < (*.f64 c i) < 2.00000000000000011e32Initial program 95.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6473.6
Applied rewrites73.6%
Taylor expanded in c around 0
Applied rewrites71.3%
if 2.00000000000000011e32 < (*.f64 c i) < 5e152Initial program 100.0%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6478.4
Applied rewrites78.4%
Taylor expanded in x around 0
Applied rewrites43.2%
Taylor expanded in c around 0
Applied rewrites44.5%
Taylor expanded in a around 0
Applied rewrites70.3%
if 5e152 < (*.f64 c i) Initial program 90.2%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6488.0
Applied rewrites88.0%
Taylor expanded in x around 0
Applied rewrites84.5%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* z t) -5e+152)
(* t z)
(if (<= (* z t) -5e-41)
(fma b a (* y x))
(if (<= (* z t) 2e+68) (fma b a (* c i)) (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 ((z * t) <= -5e+152) {
tmp = t * z;
} else if ((z * t) <= -5e-41) {
tmp = fma(b, a, (y * x));
} else if ((z * t) <= 2e+68) {
tmp = fma(b, a, (c * i));
} else {
tmp = fma(a, b, (t * z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -5e+152) tmp = Float64(t * z); elseif (Float64(z * t) <= -5e-41) tmp = fma(b, a, Float64(y * x)); elseif (Float64(z * t) <= 2e+68) tmp = fma(b, a, Float64(c * i)); else tmp = fma(a, b, Float64(t * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+152], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -5e-41], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+68], N[(b * a + N[(c * i), $MachinePrecision]), $MachinePrecision], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+152}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq -5 \cdot 10^{-41}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+68}:\\
\;\;\;\;\mathsf{fma}\left(b, a, c \cdot i\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -5e152Initial program 96.2%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6492.7
Applied rewrites92.7%
Taylor expanded in c around 0
Applied rewrites85.3%
Taylor expanded in z around 0
Applied rewrites6.1%
Taylor expanded in z around inf
lower-*.f6485.3
Applied rewrites85.3%
if -5e152 < (*.f64 z t) < -4.9999999999999996e-41Initial program 97.3%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6478.5
Applied rewrites78.5%
Taylor expanded in x around 0
Applied rewrites45.1%
Taylor expanded in c around 0
Applied rewrites63.2%
if -4.9999999999999996e-41 < (*.f64 z t) < 1.99999999999999991e68Initial program 97.2%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6494.1
Applied rewrites94.1%
Taylor expanded in x around 0
Applied rewrites73.8%
if 1.99999999999999991e68 < (*.f64 z t) Initial program 92.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6483.6
Applied rewrites83.6%
Taylor expanded in c around 0
Applied rewrites73.6%
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma i c (* y x))))
(if (<= (* c i) -2e+38)
t_1
(if (<= (* c i) -5e-217)
(fma b a (* y x))
(if (<= (* c i) 2e+32) (fma a b (* 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 ((c * i) <= -2e+38) {
tmp = t_1;
} else if ((c * i) <= -5e-217) {
tmp = fma(b, a, (y * x));
} else if ((c * i) <= 2e+32) {
tmp = fma(a, b, (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(c * i) <= -2e+38) tmp = t_1; elseif (Float64(c * i) <= -5e-217) tmp = fma(b, a, Float64(y * x)); elseif (Float64(c * i) <= 2e+32) tmp = fma(a, b, 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[(c * i), $MachinePrecision], -2e+38], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], -5e-217], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 2e+32], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(i, c, y \cdot x\right)\\
\mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+38}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;c \cdot i \leq -5 \cdot 10^{-217}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 c i) < -1.99999999999999995e38 or 2.00000000000000011e32 < (*.f64 c i) Initial program 95.0%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6481.9
Applied rewrites81.9%
Taylor expanded in x around 0
Applied rewrites70.4%
Taylor expanded in c around 0
Applied rewrites28.5%
Taylor expanded in a around 0
Applied rewrites71.5%
if -1.99999999999999995e38 < (*.f64 c i) < -5.0000000000000002e-217Initial program 100.0%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6478.4
Applied rewrites78.4%
Taylor expanded in x around 0
Applied rewrites42.1%
Taylor expanded in c around 0
Applied rewrites75.4%
if -5.0000000000000002e-217 < (*.f64 c i) < 2.00000000000000011e32Initial program 95.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6473.6
Applied rewrites73.6%
Taylor expanded in c around 0
Applied rewrites71.3%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* z t) -5e+152)
(* t z)
(if (<= (* z t) 5e-109)
(fma b a (* y x))
(if (<= (* z t) 1e+22) (* i c) (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 ((z * t) <= -5e+152) {
tmp = t * z;
} else if ((z * t) <= 5e-109) {
tmp = fma(b, a, (y * x));
} else if ((z * t) <= 1e+22) {
tmp = i * c;
} else {
tmp = fma(a, b, (t * z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(z * t) <= -5e+152) tmp = Float64(t * z); elseif (Float64(z * t) <= 5e-109) tmp = fma(b, a, Float64(y * x)); elseif (Float64(z * t) <= 1e+22) tmp = Float64(i * c); else tmp = fma(a, b, Float64(t * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+152], N[(t * z), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e-109], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 1e+22], N[(i * c), $MachinePrecision], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+152}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{-109}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{elif}\;z \cdot t \leq 10^{+22}:\\
\;\;\;\;i \cdot c\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -5e152Initial program 96.2%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6492.7
Applied rewrites92.7%
Taylor expanded in c around 0
Applied rewrites85.3%
Taylor expanded in z around 0
Applied rewrites6.1%
Taylor expanded in z around inf
lower-*.f6485.3
Applied rewrites85.3%
if -5e152 < (*.f64 z t) < 5.0000000000000002e-109Initial 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.2
Applied rewrites91.2%
Taylor expanded in x around 0
Applied rewrites64.0%
Taylor expanded in c around 0
Applied rewrites65.1%
if 5.0000000000000002e-109 < (*.f64 z t) < 1e22Initial program 96.8%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6462.9
Applied rewrites62.9%
if 1e22 < (*.f64 z t) Initial program 93.3%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6486.4
Applied rewrites86.4%
Taylor expanded in c around 0
Applied rewrites70.1%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* x y) -1e+58) (not (<= (* x y) 2e+92))) (fma b a (fma i c (* 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) <= -1e+58) || !((x * y) <= 2e+92)) {
tmp = fma(b, a, fma(i, c, (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) <= -1e+58) || !(Float64(x * y) <= 2e+92)) tmp = fma(b, a, fma(i, c, 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], -1e+58], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2e+92]], $MachinePrecision]], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $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 -1 \cdot 10^{+58} \lor \neg \left(x \cdot y \leq 2 \cdot 10^{+92}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\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) < -9.99999999999999944e57 or 2.0000000000000001e92 < (*.f64 x y) Initial program 90.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6485.2
Applied rewrites85.2%
if -9.99999999999999944e57 < (*.f64 x y) < 2.0000000000000001e92Initial program 98.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6493.4
Applied rewrites93.4%
Final simplification90.6%
(FPCore (x y z t a b c i)
:precision binary64
(if (<= (* z t) -1e+117)
(fma i c (fma t z (* y x)))
(if (<= (* z t) 2e+18)
(fma b a (fma i c (* 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 ((z * t) <= -1e+117) {
tmp = fma(i, c, fma(t, z, (y * x)));
} else if ((z * t) <= 2e+18) {
tmp = fma(b, a, fma(i, c, (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(z * t) <= -1e+117) tmp = fma(i, c, fma(t, z, Float64(y * x))); elseif (Float64(z * t) <= 2e+18) tmp = fma(b, a, fma(i, c, 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[LessEqual[N[(z * t), $MachinePrecision], -1e+117], N[(i * c + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 2e+18], N[(b * a + N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+117}:\\
\;\;\;\;\mathsf{fma}\left(i, c, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\
\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+18}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\end{array}
\end{array}
if (*.f64 z t) < -1.00000000000000005e117Initial program 96.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6493.9
Applied rewrites93.9%
if -1.00000000000000005e117 < (*.f64 z t) < 2e18Initial program 96.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6492.0
Applied rewrites92.0%
if 2e18 < (*.f64 z t) Initial program 93.4%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6486.6
Applied rewrites86.6%
(FPCore (x y z t a b c i) :precision binary64 (if (<= (* x y) -1e+58) (fma b a (* y x)) (if (<= (* x y) 2e+143) (fma b a (fma i c (* t z))) (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 ((x * y) <= -1e+58) {
tmp = fma(b, a, (y * x));
} else if ((x * y) <= 2e+143) {
tmp = fma(b, a, fma(i, c, (t * z)));
} else {
tmp = fma(i, c, (y * x));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(x * y) <= -1e+58) tmp = fma(b, a, Float64(y * x)); elseif (Float64(x * y) <= 2e+143) tmp = fma(b, a, fma(i, c, Float64(t * z))); else tmp = fma(i, c, Float64(y * x)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -1e+58], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+143], N[(b * a + N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+58}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+143}:\\
\;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 x y) < -9.99999999999999944e57Initial program 88.4%
Taylor expanded in z around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6482.4
Applied rewrites82.4%
Taylor expanded in x around 0
Applied rewrites35.4%
Taylor expanded in c around 0
Applied rewrites73.0%
if -9.99999999999999944e57 < (*.f64 x y) < 2e143Initial program 98.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6493.2
Applied rewrites93.2%
if 2e143 < (*.f64 x y) Initial program 92.6%
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 rewrites33.1%
Taylor expanded in c around 0
Applied rewrites64.7%
Taylor expanded in a around 0
Applied rewrites85.6%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= (* c i) -2e+38) (not (<= (* c i) 5e+19))) (* 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+38) || !((c * i) <= 5e+19)) {
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+38)) .or. (.not. ((c * i) <= 5d+19))) 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+38) || !((c * i) <= 5e+19)) {
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+38) or not ((c * i) <= 5e+19): 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+38) || !(Float64(c * i) <= 5e+19)) 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+38) || ~(((c * i) <= 5e+19))) 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+38], N[Not[LessEqual[N[(c * i), $MachinePrecision], 5e+19]], $MachinePrecision]], N[(i * c), $MachinePrecision], N[(b * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+38} \lor \neg \left(c \cdot i \leq 5 \cdot 10^{+19}\right):\\
\;\;\;\;i \cdot c\\
\mathbf{else}:\\
\;\;\;\;b \cdot a\\
\end{array}
\end{array}
if (*.f64 c i) < -1.99999999999999995e38 or 5e19 < (*.f64 c i) Initial program 95.1%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6459.0
Applied rewrites59.0%
if -1.99999999999999995e38 < (*.f64 c i) < 5e19Initial program 97.0%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6470.1
Applied rewrites70.1%
Taylor expanded in c around 0
Applied rewrites67.7%
Taylor expanded in z around 0
Applied rewrites41.4%
Final simplification49.8%
(FPCore (x y z t a b c i) :precision binary64 (if (or (<= c -1.2e+181) (not (<= c 8.4e+25))) (* i c) (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 ((c <= -1.2e+181) || !(c <= 8.4e+25)) {
tmp = i * c;
} else {
tmp = fma(a, b, (t * z));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i) tmp = 0.0 if ((c <= -1.2e+181) || !(c <= 8.4e+25)) tmp = Float64(i * c); else tmp = fma(a, b, Float64(t * z)); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[c, -1.2e+181], N[Not[LessEqual[c, 8.4e+25]], $MachinePrecision]], N[(i * c), $MachinePrecision], N[(a * b + N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.2 \cdot 10^{+181} \lor \neg \left(c \leq 8.4 \cdot 10^{+25}\right):\\
\;\;\;\;i \cdot c\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, t \cdot z\right)\\
\end{array}
\end{array}
if c < -1.20000000000000001e181 or 8.3999999999999996e25 < c Initial program 94.5%
Taylor expanded in c around inf
*-commutativeN/A
lower-*.f6452.3
Applied rewrites52.3%
if -1.20000000000000001e181 < c < 8.3999999999999996e25Initial program 96.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6477.1
Applied rewrites77.1%
Taylor expanded in c around 0
Applied rewrites60.4%
Final simplification57.5%
(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-*.f6477.5
Applied rewrites77.5%
Taylor expanded in c around 0
Applied rewrites51.1%
Taylor expanded in z around 0
Applied rewrites28.8%
herbie shell --seed 2024326
(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)))