Simplify evaluation of Apply expressions with commutative numeric functions (add/multiply) and multiple constant args
Simplify evaluation of Apply expressions with commutative numeric functions (add/multiply) and multiple constant args:
If the numeric function f is commutative (add or multiply) and multiple args are constant C1,...Cm, we can simplify args as follows:
f(x1,..., x_{n1-1}, C1, x_n1, ..., x_{n2-1} C2, x_n2, ..., Cm, x_nm...) = f( C, x1.., x_{n1-1}, x_n1, x_{n2-2}, x_n2...), where C (constant) = f(C1, C2..., Cm)
Therefore, we can replace all constant args with C arg.