Skip to main content
added 67 characters in body
Source Link

Bug introduced in Version 8 or earlier, and persisting through 12.1.


I have the following code:

ser[x_] = FourierSeries[(\[Pi]^2π^2 + a)/(3 x^2 + a), x, 10] // N // Chop

It gives me some series, which I then try to plot. And surprisingly, the result isn't even similar to the function I passed to FourierSeries[]: for comparison, I've used this code:

Plot[{ser[x], 1000 (\[Pi]^2π^2 + a)/(3 x^2 + a)}, {x, -\[Pi]π, \[Pi]π}]

output

Fourier transform for function given in documentation works correctly, while for this one doesn't. I've tried using directly the formula given in documentation as default formula (used NIntegrate[]), and that gives me expected results.
What have I done wrong? Is this a bug?

Addition to answer comments: some more code

As one can see, the Fourier coefficients computed via NIntegrate[] are quite different from ones generated by FourierCoefficient[].

Update:
As pointed in comments, setting GenerateConditions->True appears to yield correct result, not generating any conditions though. Why should this be needed?

I have the following code:

ser[x_] = FourierSeries[(\[Pi]^2 + a)/(3 x^2 + a), x, 10] // N // Chop

It gives me some series, which I then try to plot. And surprisingly, the result isn't even similar to the function I passed to FourierSeries[]: for comparison, I've used this code:

Plot[{ser[x], 1000 (\[Pi]^2 + a)/(3 x^2 + a)}, {x, -\[Pi], \[Pi]}]

output

Fourier transform for function given in documentation works correctly, while for this one doesn't. I've tried using directly the formula given in documentation as default formula (used NIntegrate[]), and that gives me expected results.
What have I done wrong? Is this a bug?

Addition to answer comments: some more code

As one can see, the Fourier coefficients computed via NIntegrate[] are quite different from ones generated by FourierCoefficient[].

Update:
As pointed in comments, setting GenerateConditions->True appears to yield correct result, not generating any conditions though. Why should this be needed?

Bug introduced in Version 8 or earlier, and persisting through 12.1.


I have the following code:

ser[x_] = FourierSeries[(π^2 + a)/(3 x^2 + a), x, 10] // N // Chop

It gives me some series, which I then try to plot. And surprisingly, the result isn't even similar to the function I passed to FourierSeries[]: for comparison, I've used this code:

Plot[{ser[x], 1000 (π^2 + a)/(3 x^2 + a)}, {x, -π, π}]

output

Fourier transform for function given in documentation works correctly, while for this one doesn't. I've tried using directly the formula given in documentation as default formula (used NIntegrate[]), and that gives me expected results.
What have I done wrong? Is this a bug?

Addition to answer comments: some more code

As one can see, the Fourier coefficients computed via NIntegrate[] are quite different from ones generated by FourierCoefficient[].

Update:
As pointed in comments, setting GenerateConditions->True appears to yield correct result, not generating any conditions though. Why should this be needed?

Notice removed Draw attention by Oleksandr R.
Bounty Ended with David E Speyer's answer chosen by Oleksandr R.
edited tags
Link
Tweeted twitter.com/#!/StackMma/status/333084539981271041
Notice added Draw attention by Oleksandr R.
Bounty Started worth 50 reputation by Oleksandr R.
added 183 characters in body
Source Link
Ruslan
  • 7.2k
  • 1
  • 23
  • 53

I have the following code:

ser[x_] = FourierSeries[(\[Pi]^2 + a)/(3 x^2 + a), x, 10] // N // Chop

It gives me some series, which I then try to plot. And surprisingly, the result isn't even similar to the function I passed to FourierSeries[]FourierSeries[]: for comparison, I've used this code:

Plot[{ser[x], 1000 (\[Pi]^2 + a)/(3 x^2 + a)}, {x, -\[Pi], \[Pi]}]

output

Fourier transform for function given in documentation works correctly, while for this one doesn't. I've tried using directly the formula given in documentation as default formula (used NIntegrate[]NIntegrate[]), and that gives me expected results.
What have I done wrong? Is this a bug?

Addition to answer comments: some more code

As one can see, the Fourier coefficients computed via NIntegrate[]NIntegrate[] are quite different from ones generated by FourierCoefficient[]FourierCoefficient[].

Update:
As pointed in comments, setting GenerateConditions->True appears to yield correct result, not generating any conditions though. Why should this be needed?

I have the following code:

ser[x_] = FourierSeries[(\[Pi]^2 + a)/(3 x^2 + a), x, 10] // N // Chop

It gives me some series, which I then try to plot. And surprisingly, the result isn't even similar to the function I passed to FourierSeries[]: for comparison, I've used this code:

Plot[{ser[x], 1000 (\[Pi]^2 + a)/(3 x^2 + a)}, {x, -\[Pi], \[Pi]}]

output

Fourier transform for function given in documentation works correctly, while for this one doesn't. I've tried using directly the formula given in documentation as default formula (used NIntegrate[]), and that gives me expected results.
What have I done wrong? Is this a bug?

Addition to answer comments: some more code

As one can see, the Fourier coefficients computed via NIntegrate[] are quite different from ones generated by FourierCoefficient[].

I have the following code:

ser[x_] = FourierSeries[(\[Pi]^2 + a)/(3 x^2 + a), x, 10] // N // Chop

It gives me some series, which I then try to plot. And surprisingly, the result isn't even similar to the function I passed to FourierSeries[]: for comparison, I've used this code:

Plot[{ser[x], 1000 (\[Pi]^2 + a)/(3 x^2 + a)}, {x, -\[Pi], \[Pi]}]

output

Fourier transform for function given in documentation works correctly, while for this one doesn't. I've tried using directly the formula given in documentation as default formula (used NIntegrate[]), and that gives me expected results.
What have I done wrong? Is this a bug?

Addition to answer comments: some more code

As one can see, the Fourier coefficients computed via NIntegrate[] are quite different from ones generated by FourierCoefficient[].

Update:
As pointed in comments, setting GenerateConditions->True appears to yield correct result, not generating any conditions though. Why should this be needed?

added 236 characters in body
Source Link
Ruslan
  • 7.2k
  • 1
  • 23
  • 53
Loading
Source Link
Ruslan
  • 7.2k
  • 1
  • 23
  • 53
Loading