# FourierSeries command , for arbitrary period T?

ExptoTrig[FourierSeries[Piecewise[{{-Pi,-2Pi<x<=0},{Pi,0<x<=2Pi}}],x,3]]


You can see, the function goes from $(-2\pi,2\pi]$

But Wolfram Alpha gives a wrong answer to this, because she computes it as if the function would go from $-\pi$ to $\pi$.

(The right answer should be $4\sin(\frac{x}{2}) + ..$.)

So, how can I use this command when the function's period T is not 2$\pi$ exactly?

• Why not rescale your function first so that the function applies, and scale back after the operation? May 19, 2016 at 11:56
• @J.M. I don't really know how to do that..:) May 19, 2016 at 12:02
• Oh we use one of the magic words of math for that: let $x=2u$… May 19, 2016 at 12:13
• @J.M. Okay, thanks:) May 19, 2016 at 12:23
• Did you try FourierParameters settings ? May 19, 2016 at 12:31

f[x_] = Piecewise[{{-Pi, -2 Pi < x <= 0}, {Pi, 0 < x <= 2 Pi}}];
T = 4 \[Pi];
fr = FourierTrigSeries[f[x], x, 3, FourierParameters -> {1, 2 \[Pi]/T}]
(* 4 Sin[x/2] + 4/3 Sin[(3 x)/2] *) • Wow , Jesus, nice! May 19, 2016 at 12:48

Thanks @rewi. I just write down the Wolfram Alpha version, (based on his answer). So I can remember.

FourierTrigSeries[Piecewise[{{-Pi, -2 Pi < x <= 0}, {Pi, 0 < x <= 2 Pi}}], x, 3, FourierParameters -> {1, 1/2}]


where FourierParameters' second parameter is $\omega = \frac{2\pi}{T}$