# Summation bug in 11.2

If I sum all the positive-numbered Fourier coefficients of $\cos(x)$, I get the correct answer. If I sum the negative-numbered ones, I get a wrong answer. Splitting the sum into two parts somehow fixes the issue.

Sum[FourierCoefficient[Cos[x], x, k], {k, 1, Infinity}]
Sum[FourierCoefficient[Cos[x], x, -k], {k, 1, Infinity}]
Sum[FourierCoefficient[Cos[x], x, -k], {k, 1, 2}] +  Sum[FourierCoefficient[Cos[x], x, -k], {k, 3, Infinity}]

Out:
1/2
0
1/2

• This is the wrong place to report bugs. Please report bugs directly to Wolfram Research: wolfram.com/support/contact/email. – QuantumDot Oct 7 '17 at 15:38
• @QuantumDot is correct that bugs should be reported directly to Wolfram, Inc. Nonetheless, warning StackExchange uses about bugs is a useful service, and I thank you for doing so. Be sure to attached the usual bug header to your question, along with the case number that Wolfram, Inc assigns to your report, in a day or so, after others have had a chance to comment on the problem you identified here. – bbgodfrey Oct 7 '17 at 17:36

The problem is not with Sum:

FourierCoefficient[Cos[x], x, -k]
(*  0  *)

FourierCoefficient[Cos[x], x, k]


The second code is also much faster. It suggests to me that FourierCoefficient calls Integrate in the first case and uses a short-cut in the second. In fact Integrate (from a Trace of FourierCoefficient) gives a result that is only generically correct:

Integrate[E^(I k x) Cos[x], {x, -π, π},
Assumptions -> k ∈ Integers, GenerateConditions -> False]
(* -((2 k Sin[k π])/(-1 + k^2))  *)

• Interesting, so it's a consequence of the fact that the symbolic value of that integral formally breaks down at $k=\pm 1$? I wonder how FourierCoefficient normally avoids this problem. – level1807 Oct 7 '17 at 23:06
• @level1807 It seems for a simple symbol k as opposed to an expression -k, that instead of integration, Cos[x] is expanded as a series in q = Exp[I x] and SeriesCoefficient is used to get the general series coefficient of order k. SeriesCoefficient does a better job than Integrate in this case. – Michael E2 Oct 8 '17 at 1:13

This is not an answer as why it happens. But the change happened after version 7.

I went back to verion 7 to be able to obtain different result. I tried versions 11, 10, 9, and 8 and they all gave same result as above. But in version 7:

• That's quite strange... – level1807 Oct 7 '17 at 17:37