12
$\begingroup$

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

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))  *)
$\endgroup$
  • $\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$ – level1807 Oct 7 '17 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 Oct 8 '17 at 1:13
8
$\begingroup$

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

$\endgroup$
  • 1
    $\begingroup$ That's quite strange... $\endgroup$ – level1807 Oct 7 '17 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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