# Fourier Coefficients in Mathematica [duplicate]

I'm calculating Fourier Coefficients by hand and trying to verify them in Mathematica.

However, in Mathematica I get them wrong by a factor of 2. Is there some part of the Mathematica functions I'm missing or am I doing something else wrong?

What almost makes me think there is something wrong with Mathematica is that $c_0$ should be equal to $1/2 a_0$. When computing by hand $c_0$ is indeed $1/4$ but $a_0$ should be $1/2$ (as I get by hand) and not 1 as Mathematica tells me.

Here is my code:

g[x_] := Piecewise[{{0, -Pi < x < 0}, {1, 0 < x < Pi/2}, {0,
Pi/2 < x < Pi}}]

makeper[f_, L_, offset_] := f[Mod[#, L, offset]] &

gTest = makeper[g, 2*Pi, -Pi]

Plot[gTest[x], {x, -4*Pi, 4*Pi}, PlotRange -> {0, 1},
Ticks -> {{-4 Pi, -3 Pi, -2 Pi, -Pi, 0, Pi, 2 Pi, 3 Pi, 4 Pi}, {-1,
0, 1}}, Filling -> Axis]

FourierCoefficient[gTest[x], x, n]

FourierCoefficient[gTest[x], x, 0]

FourierSinCoefficient[gTest[x], x, n]

FourierCosCoefficient[gTest[x], x, n]

FourierCosCoefficient[gTest[x], x, 0]


Any help would be appreciated!

## marked as duplicate by J. M. is away♦Apr 9 '13 at 5:57

• As already noted, FourierParameters is there, since each field that uses Fourier series has a favorite convention. If you'll mention what convention you're using, we could be more helpful... – J. M. is away Nov 7 '12 at 3:54