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

2 Answers 2

4
$\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$
1
  • $\begingroup$ Wow , Jesus, nice! $\endgroup$
    – Filkor
    Commented May 19, 2016 at 12:48
1
$\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 and acknowledge you have read our privacy policy.

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