1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Fourier Series Coefficients of an Even Square Wave

  1. Oct 20, 2016 #1
    1. The problem statement, all variables and given/known data
    klFmtTH.png
    Link: http://i.imgur.com/klFmtTH.png

    2. Relevant equations
    [itex]a_0=\frac{1}{T_0}\int ^{T_0}_{0}x(t)dt[/itex]
    [itex]a_n=\frac{2}{T_0}\int ^{\frac{T_0}{2}}_{\frac{-T_0}{2}}x(t)cos(n\omega t)dt[/itex]
    [itex]\omega =2\pi f=\frac{2\pi}{T_0}[/itex]

    3. The attempt at a solution
    Firstly, x(t) is an even function because x=1/2 when [itex]t=-t_0[/itex] and [itex]t=t_0[/itex]. Therefore, all bn coefficients of the Fourier series will be zero.

    [itex]T_0=4, \omega =\frac{2\pi}{4}=\frac{\pi}{2}, t_0=1[/itex]

    a0 is basicly the average value of x(t) over the period. By inspection a0 = 2/4 = 1/2

    It makes sense to me to split up x(t) into regions:
    x(t) = 0 when [itex]\frac{-T_0}{2}<t<-t_0, t_0<t<\frac{T_0}{2}[/itex]
    x(t) = 1/2 when [itex]t=^+_-t_0[/itex]
    x(t) = 1 when [itex]-t_0<t<t_0[/itex]

    [itex]a_n=\frac{2}{T_0}[\frac{1}{2}\int ^{-t_0}_{-t_0}cos(n\omega t)dt+\int ^{t_0}_{-t_0}cos(n\omega t)dt+\frac{1}{2}\int ^{t_0}_{t_0}cos(n\omega t)][/itex]

    [itex]=\frac{2}{n\omega T_0}(1+[sin(\frac{\pi}{2}nt)]^{t_0}_{-t_0})[/itex]

    [itex]=\frac{2}{n\omega T_0}[1+(sin(\frac{\pi}{2}nt_0)-sin(\frac{-\pi}{2}nt_0)][/itex]

    [itex]=\frac{2}{n\omega T_0}[1+2sin(\frac{\pi n}{2})][/itex]

    [itex]a_0=\frac{1}{2}, a_1=\frac{3}{\pi}, a_2=\frac{1}{2\pi}, a_3=\frac{-1}{3\pi}, a_4=\frac{1}{4\pi}, a_5=\frac{3}{5\pi}, a_6=\frac{1}{6\pi}[/itex]

    (1) asks for coefficients in exponential and trigonometric forms. Are the coefficients I calculated above correct for either of those forms? How do I get the coefficients in the other form?

    (2) & (3) ask for a MatLab plots. We haven't gone over any MatLab in class. If someone could point me in the right direction I think I can figure it out. I've worked with MatLab in the past.

    Thanks for your time.
    -Captain1024
     
  2. jcsd
  3. Oct 21, 2016 #2

    vela

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Education Advisor


    You should be able to answer the first question yourself, or are you really just blindly using formulas with no idea why? You really should know what "exponential form" and "trigonometric form" mean.
     
  4. Oct 21, 2016 #3
    I probably knew the difference at some point in the past, but I could use a refresher.

    I believe the answers i have calculated are in the trig form. To get the exponential form, I'm thinking I will need to use Euler's formula. Is this correct?
     
  5. Oct 25, 2016 #4
    Complex coefficients [itex]c_n[/itex] (exponential form?)

    [itex]c_0[/itex] will remain the same value of 1/2

    [itex]c_n=\frac{1}{T_0}\int ^{\frac{T_0}{2}}_{\frac{-T_0}{2}}x(t)\mathrm{exp}(-j\omega nt)dt[/itex]
    [itex]=\frac{1}{T_0}(1+\int ^{t_0}_{-t_0}e^{-j\omega nt}dt)[/itex]
    [itex]=\frac{1}{T_0}(1+[\frac{-1}{j\omega n}e^{-j\omega nt}]^{t_0}_{-t_0})[/itex]
    [itex]=\frac{1}{T_0}(1+(\frac{-1}{j\omega n})[e^{-j\omega nt_0}-e^{j\omega nt_0}])[/itex]

    When [itex]\omega=\frac{\pi}{2}, T_0=4, t_0=1[/itex];
    [itex]c_1=\frac{\frac{\pi}{4}+1}{\pi}, c_2=\frac{1}{4}, c_3=\frac{\frac{3\pi}{4}-1}{3\pi}, c_4=\frac{1}{4}, c_5=\frac{\frac{5\pi}{4}+1}{5\pi}, c_6=\frac{1}{4}[/itex]

    Am I on the right track here?
     
  6. Oct 25, 2016 #5

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    No, your computed ##c_n## are incorrect; I don't know where on earth you got the formulas you are using.

    Besides, the Fourier series in exponential form is ##f(t) = \sum_{n=-\infty}^{\infty} c_n e^{j \omega n t}##, so you need to consider terms with ##n < 0## also.
     
    Last edited: Oct 26, 2016
  7. Oct 26, 2016 #6
    Fine. Based on the reply's to this thread thus far, I know next to nothing about how to solve this problem. I accept this.

    So, if you are willing, I would like to solve this problem together step by step.

    Based on what I read at this link: Any periodic function may be expressed as an infinite series of the form [itex]x(t)=\sum ^{\infty}_{m=0}a_mcos(\frac{2\pi mt}{T})+\sum ^{\infty}_{n=1}b_nsin(\frac{2\pi nt}{T})[/itex], where [itex]a_m[/itex] and [itex]b_n[/itex] are real constants. This series is called a Fourier series.

    Now, after reading the same website, I believe I need to use the following equations in order to find the real coefficients up to the 7th harmonic:
    [itex]a_0=\frac{1}{2}\int ^{T}_{0}x(t)dt[/itex]
    [itex]a_m=\frac{2}{T}\int ^{T}_{0}x(t)cos(\frac{2\pi mt}{T})dt[/itex]
    [itex]b_n=\frac{2}{T}\int ^{T}_{0}x(t)sin(\frac{2\pi nt}{T})dt[/itex]

    Am I right so far?
     
  8. Oct 26, 2016 #7

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    No, not really, unless you re-define your function as
    $$ x(t) = \begin{cases}
    1 & 0 < t < t_0\\
    0 & t_0 < t < T-0-t_0\\
    1 & T_0-t_0 < t < T_0
    \end{cases}
    $$
    That would be your original function, but built on a base ##[0,T_0]##. It would be much easier to use the original definition of ##x(t)## based on ##[-T_0/2,T_0/2]## , but to use the Fourier series formulas that are appropriate to that case.

    Note: you had done it correctly in your first post, when you computed the ##a_n## and ##b_n## for the Fourier series with sines and cosines. Where you went all wrong is where you tried to do the ##\exp(j n \omega t)## form, and your current posting still does not deal with that problem!
     
  9. Oct 27, 2016 #8
    I guess what I am getting at is, does there exist a set of equations that works for every periodic function to find the Fourier coefficients? Or, do you have to modify your approach every time?

    I hadn't been receiving much positive feedback, so I just wanted to take a step back first.

    So, just to clarify, is the ##a_0## I calculated the DC component or is it the coefficient of the 1st harmonic? Looking at it again, I think it's the DC component. If ##a_0## is the dc component, I think I need to keep calculating coefficients until n=7. In other words, do I need to calculate ##a_n## up to n=6 or n=7 to obtain the coefficient of the 7th harmonic?

    For determining the complex coefficients, is the following formula correct: ##c_n=\frac{1}{T_0}\int ^{\frac{T_0}{2}}_{\frac{-T_0}{2}}x(t)\mathrm{exp}(-j\omega nt)dt##
    If so, do I need to find ##c_n## when n=1, -1, 3, -3, 5, -5, & 7 (assuming the even subscripts yield 0's) in order to find the coefficients up to the 7th harmonic?

    Thank you for your time. I know it probably isn't easy being a helper on this forum.
     
  10. Oct 27, 2016 #9

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    Basically, you need to start with some standard formula for Fourier coefficients, either based on ##[-\pi, \pi]## or ##[0, 2 \pi]##, then do a change-of-variable to translate those into formulas for ##[A,B]##. So, if we start with
    $$f(t) = \frac{1}{2} a_0 + \sum_{n=1}^{\infty} [ a_n \cos(n t) + b_n \sin(n t)],\\
    a_n = \frac{1}{\pi} \int_0^{2 \pi} \cos(n t) f(t) \, dt, \; b_n = \frac{1}{\pi} \int_0^{2 \pi} \sin(n t) f(t) \, dt,
    $$
    based on ##[0, 2 \pi]##, we are looking at trigonometric functions whose arguments go from ##0## to ##2 \pi n## for integer ##n##. On ##[A,B]## we want the arguments of our trigonometric functions to go from ##0## when ##t = A## to ##2 \pi n## when ##t = B##, so the argument is of the form ##2\pi n (t-A)/(B-A)## in the series and in the integrals that give the coefficients. This is just a straight change-of-variable problem.

    I recommend that you do it once and file the results for future reference.

    I now take back my statement that you calculated the trigonometric form coefficients correctly; looking at what you did, you made some puzzling blunders. I suggest you start again, carefully. Hint: you should get ##a_0 = 1## (so that the series starts off as ##(1/2)1 + \cdots = 1/2 + \cdots##), ##a_1 = 2/\pi##, ##a_2 = 0##, ##a_3 = -2/(3 \pi)##, etc.

    Below, I show a plot of my series (up to n = 6) and of yours (up to n=6); mine is in blue and yours is in red. As you can see, the blue graph looks much closer to the function than does the red graph.

    upload_2016-10-27_7-31-49.png
     
    Last edited: Oct 27, 2016
  11. Nov 27, 2016 #10
    I'm finally making some progress on this:

    Trig form:
    ##x(t)=a_0+\sum ^{\infty} _{n=1}a_ncos(2\pi ftn)+\sum ^{\infty}_{n=1}b_nsin(2\pi ftn)##, where n is the harmonic number.
    Where ##a_0=\frac{1}{T}\int ^{\frac{t}{2}}_{\frac{-T}{2}}x(t)dt##. Simplifying, ##a_0=\frac{1}{T}\int ^{\frac{T}{4}}_{\frac{-T}{4}}x(t)dt=\frac{1}{4}[t]^1_{-1}=\frac{1}{4}*2,\ \therefore a_0=\frac{1}{2}##.

    Where ##a_n=\frac{2}{T}\int ^{\frac{T}{2}}_{\frac{-T}{2}}cos(\frac{2\pi tn}{T})dt=\frac{2}{T}\int ^{\frac{T}{4}}_{\frac{-T}{4}}cos(\frac{2\pi tn}{T})dt=\frac{2}{T}[\frac{T}{2\pi n}sin(\frac{2\pi tn}{T})]^{\frac{T}{4}}_{\frac{-T}{4}}##
    ##=\frac{1}{\pi n}[sin(\frac{2\pi n\frac{T}{4}}{T})-sin(\frac{2\pi n\frac{-T}{4}}{T})]=\frac{1}{\pi n}[sin(\frac{\pi n}{2})-sin(\frac{-\pi n}{2})]=\frac{2}{\pi n}sin(\frac{\pi n}{2})##.

    Then, ##a_1=\frac{2}{\pi}, a_2=0, a_3=\frac{-2}{3\pi}, a_4=0, a_5=\frac{2}{5\pi}, a_6=0, a_7=\frac{-2}{7\pi}##.

    Graph:
    sTPtTlP.png
    Link: http://i.imgur.com/sTPtTlP.png

    Exp form:
    ##x(t)=\sum ^{\infty}_{n=-\infty}c_nexp(j\omega _0tn)##

    Where, ##c_0=\frac{1}{T}\int ^{\frac{t}{2}}_{\frac{-T}{2}}x(t)dt=a_0\ \therefore \ c_0=\frac{1}{2}##

    ##\mathrm{Where,}\ c_n=\frac{1}{T}\int ^{\frac{T}{2}}_{\frac{-T}{2}}x(t)exp(-j\omega _0tn)=\frac{1}{T}\int ^{\frac{T}{4}}_{\frac{-T}{4}}x(t)exp(-j\omega _0tn)=\frac{1}{T}[\frac{-1}{j\omega _0n}exp(-j\omega _0tn)]^{\frac{T}{4}}_{\frac{-T}{4}}=\frac{-1}{j\omega _0nT}[exp(-j\omega _0n\frac{T}{4})-exp(j\omega _0n\frac{T}{4})]=\frac{-1}{j\omega _0nT}(-2cos(\omega _0n\frac{T}{4}))=\frac{2cos(\frac{\pi n}{2})}{j2\pi n}##

    Then, ##c_1=0, c_2=\frac{-1}{j2\pi}, c_3=0, c_4=\frac{1}{j4\pi}, c_5=0, c_6=\frac{-1}{j6\pi}, c_7=0##

    Am I correct up to this point?

    It was nice to check my trig form answer with the matlab graph. I believe the graph I have above is part of what he is looking for in part (2). The other part being a plot of the original rectangular pulse function, which is proving a little more difficult to accomplish in matlab. How do I plot the given function?

    Next, I don't think I can check the exp form the same way. Part (3) asks for the magnitude spectrum plots up to n=7. I think he wants 3 plots; One for each non-zero ##c_n## coefficient. I poked around matlab help and couldn't find a straightforward way to accomplish this. How do I plot the magnitude spectrum plots?

    Thanks.
     
  12. Nov 28, 2016 #11

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    I do not have access to Matlab, so I use Maple instead. In Maple, if I want to plot two graphs ##y = f_1(x)## and ##y = f_2(x)## together on a common interval ##x \in [a,b]## I would just say "plot([f1(x),f2(x)], x=a..b, color = [red,blue])" to get ##f_1(x)## in red and ##f_2(x)## in blue; or I could leave out the "color" option and let Maple choose the two colors. Is there a Matlab-equivalent method?

    I don't know about how Matlab would deal with your other questions.

    BTW: for future reference, the USUAL way of writing the Fourier series, say on ##[0, 2\pi]##, is exactly as I wrote it in post #9. That means that the series has ##\frac{1}{2}a_0## as the constant term, with the formula for ##a_0## being the same as the formula for ##a_n## by putting ##n = 0##. I recommend that you stick with the standard convention, because if you use one that is different from everybody else's it is more difficult to check your work for errors.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Fourier Series Coefficients of an Even Square Wave
Loading...