1. Limited time only! Sign up for a free 30min personal 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!

Homework Help: Fourier Series - Square Wave

  1. Oct 1, 2015 #1

    I think that I have done this correctly, but this is the first problem I have done on my own and would appreciate confirmation.

    1. The problem statement, all variables and given/known data

    Find the Fourier series corresponding to the following functions that are periodic over the interval [itex](−π, π)[/itex] with: (a) [itex]f(x) = 1[/itex] for [itex]−\frac{π}{2} < x < \frac{π}{2}[/itex] and [itex]f(x) = 0[/itex] otherwise.

    2. Relevant equations

    3. The attempt at a solution

    The first coefficient [itex]a_{0} = \frac{1}{\pi} \int^{0.5\pi}_{-0.5\pi} f(x) dx = 1[/itex]

    [itex]a_{n} = \frac{1}{\pi} \int^{0.5\pi}_{-0.5\pi} \cos(nx) dx[/itex]

    which leads to the following;

    [itex]a_{n} = - \frac{1}{n \pi} ((-1^{n}) - 1)[/itex]

    [itex]b_{n} = \frac{1}{\pi} \int^{0.5 \pi}_{-0.5 \pi} \sin(nx) dx = 0[/itex]

    so my Fourier series is;

    [itex]f(x) = 1/2 + \frac{2}{\pi}(\cos(x) - \frac{1}{3}\cos(3x) + \frac{1}{5}\cos(5x) - ... + ) [/itex]

    or [itex]f(x) = \frac{1}{2} + \Sigma^{\infty}_{n = 1} (- \frac{1}{n \pi}( (-1)^{n} - 1)) \cos(nx)[/itex]

    Does this look ok?

    Last edited: Oct 1, 2015
  2. jcsd
  3. Oct 1, 2015 #2
    all sins looks good. seems to add up to 1 at origin.
  4. Oct 1, 2015 #3
    I think I have made a mistake somewhere, based on some plots I made in mathematica.

    It does not appear to be creating a square wave.

    I will go through it again.
  5. Oct 1, 2015 #4
    Aha! I have found the mistake.

    The [itex]a_{n}[/itex] coefficients are related to [itex]\cos(nx)[/itex] not [itex]\sin(nx)[/itex]
  6. Oct 1, 2015 #5

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    No, it is not OK. Your formula for the coefficients give results that are either 0 or positive, because ##-[(-1)^n - 1] = 1 - (-1)^n## is 0 for even n and 2 for odd n. In fact, the ##a_n## for successive odd n should alternate in sign. (However, when you subsequently wrote out the first few terms of the series, you did have alternating signs. How did that happen?)
  7. Oct 1, 2015 #6
    I computed several coefficients for a, which lead me to observe the alternating sign pattern. My mistaken formula was not used there, I evaluated the expression for each.

    I don't know if this is the prettiest formula, but it does the trick.

    [itex]a_{n} = \frac{2}{\pi + 2(n-1) \pi} (-1)^{n-1}[/itex]
  8. Oct 1, 2015 #7

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    Another one is
    [tex] a_n = \frac{2}{\pi} \frac{\sin(n \pi/2)}{n}. [/tex]
  9. Oct 1, 2015 #8
    This result pops out very easily when performing the integral that defines a_n.

    I was trying to find an algebraic expression to model that, mainly because it's what I saw on an example in class. Am I just making things harder on myself, or is there any benefit to showing it like this?
  10. Oct 1, 2015 #9

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    Well, the numerator of the second fraction is 0 for even n, is +1 for n = 1, 5, 9, ... and is -1 for n = 3, 7, 11, ... .All you need to do is find a nifty way of describing that in a formula that does not involve trig functions, etc. It might be easier to write the relevant n in the form n = 2m+1, m = 0, 1, 2, ... . Now we need +1 for even m and -1 for odd m, so ##(-1)^m## will do it. That is,
    [tex] a_{2m+1} = \frac{2 (-1)^m}{\pi (2m+1)} [/tex]
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted