1
$\begingroup$
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?

$\endgroup$
  • 1
    $\begingroup$ Why not rescale your function first so that the function applies, and scale back after the operation? $\endgroup$ – J. M. is away May 19 '16 at 11:56
  • $\begingroup$ @J.M. I don't really know how to do that..:) $\endgroup$ – Filkor May 19 '16 at 12:02
  • 2
    $\begingroup$ Oh we use one of the magic words of math for that: let $x=2u$… $\endgroup$ – J. M. is away May 19 '16 at 12:13
  • $\begingroup$ @J.M. Okay, thanks:) $\endgroup$ – Filkor May 19 '16 at 12:23
  • $\begingroup$ Did you try FourierParameters settings ? $\endgroup$ – Lotus May 19 '16 at 12:31
2
$\begingroup$
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] *)

enter image description here

$\endgroup$
  • $\begingroup$ Wow , Jesus, nice! $\endgroup$ – Filkor May 19 '16 at 12:48
0
$\begingroup$

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

$\endgroup$

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.