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}]

  • 1
    $\begingroup$ This is the wrong place to report bugs. Please report bugs directly to Wolfram Research: wolfram.com/support/contact/email. $\endgroup$
    – QuantumDot
    Commented Oct 7, 2017 at 15:38
  • 3
    $\begingroup$ @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. $\endgroup$
    – bbgodfrey
    Commented Oct 7, 2017 at 17:36

2 Answers 2


The problem is not with Sum:

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

FourierCoefficient[Cos[x], x, k]

Mathematica graphics

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))  *)
  • $\begingroup$ 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. $\endgroup$ Commented Oct 7, 2017 at 23:06
  • $\begingroup$ @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. $\endgroup$
    – Michael E2
    Commented Oct 8, 2017 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:

enter image description here

  • 1
    $\begingroup$ That's quite strange... $\endgroup$ Commented Oct 7, 2017 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.