How to simplify Sum's and Product's of arbitrary length?
sumRule =
Sum[expr1_, iter_List] + Sum[expr2_, iter_List] :>
Sum[expr1 + expr2, iter];
productRule =
Product[expr1_, iter_List]*Product[expr2_, iter_List] :>
Product[expr1*expr2, iter];
Sum[Subscript[x, i], {i, 1, n}] +
Sum[-Subscript[x, i], {i, 1, n}] /. sumRule
(* 0 *)
Product[Subscript[x, i], {i, 1, n}]*
Product[Subscript[x, i]^-1, {i, 1, n}] /. productRule
(* 1 *)
rule1 = Sum[a_Times, b : {i_, __}] :> Select[FreeQ[i]][a] Sum[Select[Not@*FreeQ[i]][a], b]
rule2 = Product[Power[a_, b_.], c_] :> Product[a, c]^b;
Examples:
expr1 = Sum[Subscript[x, i], {i, 1, n}] + Sum[-Subscript[x, i], {i, 1, n}];
TeXForm @ expr1
$\sum _{i=1}^n -x_i+\sum _{i=1}^n x_i$
expr1 /. rule1
0
expr2 = Product[Subscript[x, i], {i, 1, n}]*Product[Subscript[x, i]^-1, {i, 1, n}];
TeXForm @ expr2
$\left(\prod _{i=1}^n \frac{1}{x_i}\right) \prod _{i=1}^n x_i$
expr2 /. rule2
1