1
$\begingroup$

I have to define the function f:

  • π for x ∈ (-1,1)
  • 0 for all the others.

How do I find the n-th coefficient of this function in the Fourier series expansion for (-3π, 3π)?

$\endgroup$
  • $\begingroup$ Is this a question about the computing software Mathematica? In that case, look up the functions Piecewise and Integrate in the documentation for proper syntax for defining piecewise-defined function and how to integrate functions. If not, perhaps you meant to ask this on Mathematics. $\endgroup$ – march Jan 23 at 19:19
1
$\begingroup$

Define the function,

f[x_] := If[x < 1 && x > -1, \[Pi], 0]

or

f[x_] := Piecewise[{{\[Pi], x > -1 && x < 1}}, 0]

Do the series expansion, b=1/3 for the required region $(-3\pi,3\pi)$ (check documentation of FourierSeries and FourierParameters) for details, here choosing a=0, and up to the 30th order

fx = FourierSeries[f[x], x, 30, FourierParameters -> {0, 1/3}];

You may plot it to see the approximation

Plot[fx, {x, -3 \[Pi], 3 \[Pi]}, PlotRange -> All]

enter image description here

and to collect the terms by order, use

fxc = Collect[fx, E^((I x)/3) ]

1/3 + E^(-((I x)/3)) Sin[1/3] + E^((I x)/3) Sin[1/3] + 1/2 E^(-((2 I x)/3)) Sin[2/3] + 1/2 E^((2 I x)/3) Sin[2/3] + 1/3 E^(-I x) Sin1 + 1/3 E^(I x) Sin1+... (truncated)

where you may then access each one by array index e.g. fxc[[3]] (notice the grouping of negative and positive n)

$\endgroup$
  • $\begingroup$ Okay, but I have to make the draw of expansion of Fourier series of n-th order in (-3π,3π). How am I suppose to do that? n=1,3,5,7...15 $\endgroup$ – Crunchips Jan 23 at 19:41
  • $\begingroup$ @Crunchips something like Plot[fxc[[3]] // ReIm // Evaluate, {x, -3 \[Pi], 3 \[Pi]}] $\endgroup$ – egwene sedai Jan 23 at 19:44
  • $\begingroup$ Why is there a difference in FourrierParamers in in our answers? Did you look in Mma help? $\endgroup$ – user64494 Jan 24 at 14:44
  • $\begingroup$ @user64494 FourierSeries gives the whole series expansion, FourierCoefficient outputs the coefficient before the $n$-th order $e^{int}$, so there's actually no difference. notice for the whole expansion, the n in FourierCoefficient goes from negative "cut" $-n_c$ to the positive $n_c$ $\endgroup$ – egwene sedai Jan 24 at 15:20
0
$\begingroup$

This can be done as follows.

f[x_] := Piecewise[{{\[Pi], x > -1 && x < 1}}, 0];
FourierCoefficient[f[x], x, n, FourierParameters -> {1, 1/3}] // TeXForm

$$ \begin{cases} \frac{1}{3} & n=0 \\ \frac{\sin \left(\frac{n}{3}\right)}{n} & \text{True} \end{cases} $$

See Mathematica help to FourierCoefficient for more info.

$\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.