Question: "sum" not working as expected

If one types

seq(cos((n mod 3)*Pi,n=2..13);

Maple returns, correctly,

1,1,-1,1,1,-1,1,1,-1,1,1,-1

If one types

sum(cos((n mod 3)*Pi),n=2..13);  # surely the sum of the above sequence = 4

Maple returns, incorrectly, the value 1.

Sure enough, if one types

sum(cos((n mod 3)*Pi)*exp(n),n=2..13); # expecting the sum of e^n with every third term negative

Maple returns

e^2-e^3+e^4-e^5+e^6-e^7+e^8-e^9+e^10-e11+e^12-e^13   # alternating!?!?!

Yep, in fact,

assme(N,integer);

sum(cos((n mod 3)*Pi),n=2..N);

generates

1/2*(-1)^N+1/2

as Maple ignores the mod 3.  In fact, if you input an infinite series with the cos((n mod 3)*Pi) multiplying an unsimplifiable positive expression, Maple returns the series with "cos(n Pi)" times that expression.

What is going on? 

Of course, there are ways to build the series in question using loops or naming the sequence and summing its elements, but why does "sum" fail to work properly?

Herb...

 

Please Wait...