# Issue with symbolic summation [duplicate]

Here is the sum:

$$\sum_{j=0}^{n-1}r^{a+b}\cos^a\left(\frac{2\pi j}{n}+t\right)\sin^b\left(\frac{2\pi j}{n}+t\right)$$

Code:

F[n_, a_, b_, r_, t_] :=
Sum[r^(a + b)*Cos[2*Pi/n*j + t]^a*Sin[2*Pi/n*j + t]^b, {j, 0, n - 1}]


I do not expect it to have a simple formula for general n, but Mathematica gives this one:

F[n, 2, 2, r, t]

(n r^4)/8


The issue here is that the generic formula is incorrect. For example, the correct expression for n=4:

F[4, 2, 2, r, t]

4 r^4 Cos[t]^2 Sin[t]^2


Why is an obviously wrong result generated in symbolic summation? Is it a bug or feature?

Would appreciate any help.

• It looks to be a generically correct result: With[{a = 2, b = 2}, Table[FullSimplify[Sum[r^(a + b) Cos[2 π/n j + t]^a Sin[2 π/n j + t]^b, {j, 0, n - 1}]] == n r^4/8, {n, 20}]] Jul 28 '16 at 4:05
• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! Jul 28 '16 at 4:16
• I am pretty sure that Sum[...] in LHS was reduced to incorrect formula first. So that this example just proves the issue. Jul 28 '16 at 6:53
• It's a correct result, except possibly on a set of zero measure. That's the meaning of "generically correct". Your case of interest happens to be the case where the formula does not work. Jul 28 '16 at 6:58
• Actually it doesn't work in all cases when a and b are both even. Jul 28 '16 at 6:59

## 1 Answer

I believe this will cast some light on the problem.

F[n_, a_, b_, r_, t_] :=
r^(a + b)*
Sum[Cos[2*Pi/n*j + t]^a*Sin[2*Pi/n*j + t]^b, {j, 0, n - 1},
GenerateConditions -> True]

F[n, 2, 2, r, t]


ConditionalExpression[(n r^4)/8, n ∈ Integers && 4/n ∉ Integers && n >= 1]

This tells us the general case (n r^4)/8 won't be valid for n = 4 as indeed it is not. In fact, the general expression fails for n = 1, 2 & 4 and is valid for all other positive integers.

• Absolutely, thank you! Jul 28 '16 at 7:09