Message Boards Message Boards

Fourier series coefficients of a periodic function defined by a base signal

GROUPS:

Hello everyone. I have the following periodic function:

x(t)=summation [x0(t-nT)] from n=-infinity to n=+infinity

where x0(t)=(1+cos(2 pi f0 t)) rect(t/T)

How can I get the coefficients for k=0,1,2 of the Fourier series?

Thank you for your time.

POSTED BY: Gennaro Arguzzi
Answer
8 days ago

What's your WL code for rect[t/T]?

POSTED BY: Michael Rogers
Answer
8 days ago

Hello @Michael Rogers. This is the code: rect(t/T)=HeavisideTheta[t + (T/2)] - HeavisideTheta[t - (T/2)].

POSTED BY: Gennaro Arguzzi
Answer
8 days ago

I still feel like I'm assuming something, but perhaps this is what you're after?:

rect[t_, T_] := HeavisideTheta[t + (T/2)] - HeavisideTheta[t - (T/2)]

x0[t_] := (1 + Cos@(2 Pi f0 t)) rect[t, T]

sum = Sum[x0@(t - n T), {n, -Infinity, Infinity},  Assumptions -> f0 > 0 && T > 0]

FourierCoefficient[sum, t, 0, FourierParameters -> {1, 2 Pi/T},  Assumptions -> f0 > 0 && T > 0]
FourierCoefficient[sum, t, 1, FourierParameters -> {1, 2 Pi/T},  Assumptions -> f0 > 0 && T > 0]
FourierCoefficient[sum, t, 2, FourierParameters -> {1, 2 Pi/T},  Assumptions -> f0 > 0 && T > 0]
POSTED BY: Michael Rogers
Answer
8 days ago

Thank you so much Michael! I have another question: if I want to impose f0=1/(2T), how can I modify the code? I tried in the following way, but Mathematica shows errors:

rect[t_, T_] := HeavisideTheta[t + (T/2)] - HeavisideTheta[t - (T/2)]

x0[t_] := (1 + Cos@(2 Pi f0 t)) rect[t, T]

f0 := 1/(2T)

sum = Sum[x0@(t - n T), {n, -Infinity, Infinity}, Assumptions -> T > 0]

FourierCoefficient[sum, t, 0, FourierParameters -> {1, 2 Pi/T}, 
 Assumptions -> T > 0]
FourierCoefficient[sum, t, 1, FourierParameters -> {1, 2 Pi/T}, 
 Assumptions -> T > 0]
FourierCoefficient[sum, t, 2, FourierParameters -> {1, 2 Pi/T}, 
 Assumptions -> T > 0]
POSTED BY: Gennaro Arguzzi
Answer
7 days ago

Hi,

Sorry for the delay.

One way is to take the old coefficient and plug in the value for f0 like this:

oldFourierCoefficient /. f0 -> 1/(2 T)

It seems faster than recomputing the integrals. Also, I found the coefficient 1 gave an odd and incorrect result, which sometimes happens with integration.

I don't get any errors, so maybe you're using a different version (or perhaps you have defined some variable earlier that is causing some problem). I'm using V11.1.1.

POSTED BY: Michael Rogers
Answer
6 days ago

Hi,

Sorry for the delay.

One way is to take the old coefficient and plug in the value for f0 like this:

oldFourierCoefficient /. f0 -> 1/(2 T)

It seems faster than recomputing the integrals. Also, I found the coefficient 1 gave an odd and incorrect result, which sometimes happens with integration.

I don't get any errors, so maybe you're using a different version (or perhaps you have defined some variable earlier that is causing some problem). I'm using V11.1.1.

POSTED BY: Gennaro Arguzzi
Answer
6 days ago

Hi @Michael Rogers. I tried to use your statement after and also before the code.

rect[t_, T_] := HeavisideTheta[t + (T/2)] - HeavisideTheta[t - (T/2)]

x0[t_] := (1 + Cos@(2 Pi f0 t)) rect[t, T]

sum = Sum[x0@(t - n T), {n, -Infinity, Infinity}, 
  Assumptions -> f0 > 0 && T > 0]

FourierCoefficient[sum, t, 0, FourierParameters -> {1, 2 Pi/T}, 
 Assumptions -> f0 > 0 && T > 0]
FourierCoefficient[sum, t, 1, FourierParameters -> {1, 2 Pi/T}, 
 Assumptions -> f0 > 0 && T > 0]
FourierCoefficient[sum, t, 2, FourierParameters -> {1, 2 Pi/T}, 
 Assumptions -> f0 > 0 && T > 0]
oldFourierCoefficient /. f0 -> 1/(2 T)

In this case the output does not change. Actually Mathematica shows two outputs, the first is the same as before and the second is "oldFourierCoefficient".

Returning to the error that you noted about coefficient 1, after the (manual) substitution of f0=1/2T, the result is 2/(3 Pi). This is right, is the result of my professor.

POSTED BY: Gennaro Arguzzi
Answer
6 days ago

You should use one of the three old Fourier Coefficients in place of oldFourierCoefficient. In the code just posted, they would be represented by %, %%, %%%. You could also store them in a list:

generalcoeffs = {
 FourierCoefficient[sum, t, 0, FourierParameters -> {1, 2 Pi/T}, Assumptions -> f0 > 0 && T > 0]
 FourierCoefficient[sum, t, 1, FourierParameters -> {1, 2 Pi/T}, Assumptions -> f0 > 0 && T > 0]
 FourierCoefficient[sum, t, 2, FourierParameters -> {1, 2 Pi/T}, Assumptions -> f0 > 0 && T > 0]};
generalcoeffs  /. f0 -> 1/(2 T)
POSTED BY: Michael Rogers
Answer
6 days ago

Group Abstract Group Abstract