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 for a piecewise function help

  1. Apr 24, 2013 #1
    1. The problem statement, all variables and given/known data

    I'm trying to find a Fourier series for the piecewise function where f(x)=

    [itex] 0 \in -\pi \leq x \leq 0 [/itex]
    [itex] -1 \in 0 \leq x \leq \frac{\pi}{2} [/itex]
    [itex] 1 \in \frac{\pi}{2} \leq x \leq \pi [/itex]

    2. Relevant equations

    [tex]a_{n} = \frac{1}{\pi} \int_{0}^{2\pi}\cos(nx)y(x)\,dx[/tex]
    [tex]b_{n} = \frac{1}{\pi} \int_{0}^{2\pi}\sin(nx)y(x)\,dx[/tex]

    3. The attempt at a solution

    I found the pattern that every even a is 0, so that becomes
    [tex]a_{m} = \sum_{m=1}^{\infty}\frac{(-1)^{m}2}{(2m-1)\pi}[/tex]

    and the b coefficients are 0 when n is odd and 0 for every other even n, so that becomes
    [tex]b_{m} = \sum_{m=1}^{\infty}\frac{-2}{\frac{4m-2}{2}\pi}[/tex]

    however when I plot this, the plot between -pi and -pi/2 is switched with the plot between pi/2 and pi

    I attached a picture for reference along with a plot of f(x)

    Any ideas of where i went wrong?
    Last edited: Apr 24, 2013
  2. jcsd
  3. Apr 24, 2013 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Education Advisor

    Not really since you didn't show your work. Just posting your final, probably wrong answer isn't very helpful.
  4. Apr 24, 2013 #3
    Whoops sorry, I forgot I didn't do this all in mathematica:

    [itex]a_{0} = 0 [/itex]

    [itex]a_{1} = \frac{-2}{\pi}[/itex]

    [itex]a_{2} = 0[/itex]

    [itex]a_{3} = \frac{2}{3\pi}[/itex]

    [itex]a_{4} = 0[/itex]

    [itex]a_{5} = \frac{-2}{5\pi}[/itex]

    [itex]a_{6} = 0 [/itex]

    [itex]b_{1} = 0 [/itex]

    [itex]b_{2} = \frac{-2}{\pi}[/itex]

    [itex]b_{3} = 0 [/itex]

    [itex]b_{4} = 0 [/itex]

    [itex]b_{5} = 0 [/itex]

    [itex]b_{6} =\frac{-2}{3\pi}[/itex]

    [itex]b_{7} = 0 [/itex]

    [itex]b_{8} = 0 [/itex]

    [itex]b_{9} = 0 [/itex]

    [itex]b_{10} =\frac{-2}{5\pi}[/itex]

    [itex]b_{11} = 0 [/itex]

    [itex]b_{12} = 0 [/itex]

    [itex]b_{13} = 0 [/itex]

    [itex]b_{14} = \frac{-2}{7\pi}[/itex]
    Last edited: Apr 24, 2013
  5. Apr 24, 2013 #4
    And I figured out the summations from just looking at these in terms of n:

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

    [itex]b_{n} = \sum\frac{-2}{\frac{n}{2}\pi}[/itex]

    and then to get rid of the 0s I made it in terms of m:

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

    [itex]b_{m} = \sum\frac{-2}{\frac{4m-2}{2}\pi}[/itex]

    The function is then:

    [tex]g(x) = \sum_{m=1}^{\infty} a_m Cos((2m-1)x) + \sum_{m=1}^{\infty} b_m Sin((2m-1)x)[/tex]
    Last edited: Apr 24, 2013
  6. Apr 24, 2013 #5
    I figured out what I did wrong, but thanks!
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted