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 Concept Help!

  1. May 6, 2009 #1
    1. The problem statement, all variables and given/known data

    Compute the fourier sine series for the given function:

    f(x) = -1 0<x<1

    2. Relevant equations


    3. The attempt at a solution

    I got:

    bn = 2 * integral( (-1) * sin(npix) dx) from 0 to 1
    = 2*(-1)^n/(npi)

    however, the answer in the back of the book turns n=2k-1
    I don't get why it does this! For most of the problems I've done so far, n has always just been n, why did they suddenly replace it with 2k-1?
    How do I know when I should set n equal to something and when not to? How do I know what n should be equal to?
  2. jcsd
  3. May 6, 2009 #2


    User Avatar
    Gold Member

    You did not do your integral correctly. Also, there is no reason to multiply the integral by 2. Redo the integration and you'll see why the index is 2n-1 (since n and k are both simply indices) instead of just n.
  4. May 6, 2009 #3
    In that case, I do not know how to do the integral. I'm not sure what's wrong, here's a step by step:

    bn = 2 * integral (-1 * sin(n pi x) dx) limits 0 to 1
    = -2 * [-cos(n pi x) / (n pi)] from 0 to 1
    = 2 * (cos(n pi)/(n pi)
    = 2 * (-1)^n / (n pi)
  5. May 6, 2009 #4


    User Avatar
    Gold Member

    Remember, Cos[n*pi*0] isnt 0 :)

    Also, so that there is no confusion, you will see that half the terms of the summation disappear so remember to write your final summation with that in mind (namely, the denominator in the summation will not be simply n*pi.)
  6. May 6, 2009 #5
    AH! Too much frustration has made me delusional!

    However, with the new answer:

    bn = (2/(n pi)) * (cos(n pi) - 1)

    I still don't get the correct answer as the book

    My final answer would be

    f(x) = sum of bn * sin(n pi x) according to the formula

    however, the books answer is:

    f(x) = (-4/pi) * sum of ( (1/(2k-1)) * sin(2k-1)*pi x)
  7. May 6, 2009 #6


    User Avatar
    Gold Member

    Well think about it, [tex]Cos(n\pi ) - 1 = ( - 1)^n - 1[/tex] which is 0 for n = even, -2 for n=odd. [tex]B_n [/tex] is 0 for every other term which introduces that 2k-1. Thus your [tex] B_n [/tex] can be reduced to odd n's (that is, say [tex] B_n = 0 [/tex] for even values of n and [tex]B_n = \frac{{ - 2}}{{n\pi }}[/tex] for odd n). You can rewrite n in terms of that new index, 2k-1 so that you can keep your fourier series as a sum from 1 to infinity in your final product.
  8. May 6, 2009 #7
    Sorry I'm kinda slow but you totally lost me. Unfortunately my book doesn't really explain this part.

    So is my answer "correct" but the book's answer is just a different way to write it?

    If not, is my fourier series no longer a sum from 1 to infinity? If not, what is it and why did it change?

    Also, I don't understand the even and odd stuff, why is that important? Why do I need to change cosine to (-1)^n?

    And finally, how exactly did you get (2k-1) from all of that?

    Sorry for all of the questions but I'm quite confused!
  9. May 6, 2009 #8


    User Avatar
    Gold Member

    Ok made a mistake earlier, you do multiply by 2, i forgot the function was constant. Here's what's going on:

    f(x) = \sum\limits_{n = 1}^\infty {B_n \sin (n\pi x)} \\
    B_n = 2\int_0^1 { - 1\sin (n\pi x)dx} \\
    B_n = 2\left[ {\frac{{\cos (n\pi x)}}{{n\pi }}} \right]_0^1 \\
    B_n = 2\frac{{\cos (n\pi ) - \cos (0)}}{{n\pi }} \\
    B_n = 2\frac{{( - 1)^n - 1}}{{n\pi }} \\

    But you know cos(n*pi) = (-1)^n so you know for every even n, [tex] B_n = 0 [/tex] and for every odd n,[tex] B_n = 2\frac{{ - 2}}{{n\pi }}[/tex] Which means your fourier series looks like

    [tex]f(x) = \sum\limits_{n = 1}^\infty {2\frac{{( - 1)^n - 1}}{{n\pi }}\sin (n\pi x)} [/tex]

    However, since only the odd n's exist in this series, you can write the series as

    [tex]f(x) = \sum\limits_{n = 1,odd}^\infty {-4\frac{1}{{n\pi }}} \sin (n\pi x)[/tex]

    Which can be written out in a hopefully more helpful way...

    [tex]f(x) ~2\frac{{ - 2}}{{1\pi }}\sin (1\pi x) + 2\frac{{ - 2}}{{3\pi }}\sin (3\pi x) + 2\frac{{ - 2}}{{5\pi }}\sin (5\pi x) + ...[/tex]

    Thus the change to n=2k-1 allows you to write it back in a fourier series form of

    f(x) = \sum\limits_{k = 1}^\infty { - 4\frac{1}{{(2k - 1)\pi }}} \sin ((2k - 1)\pi x)[/tex]
    Last edited: May 6, 2009
  10. May 6, 2009 #9


    User Avatar
    Gold Member

    Ok that shoudl be finally right, i keep making stupid mistakes :)
  11. May 6, 2009 #10
    It's starting to make a little more sense, thanks.

    First off, is it just known that cos(npi) = (-1)^n?
    Does sin(npi) equal anything useful then? I also see (-1)^(n+1) in some of the solutions, is there a "formula" for that as well?

    So what if every even Bn did not = 0. How would I "combine" the odd and even summations to form a final answer?

    Also, it seems like
    f(x) = \sum\limits_{n = 1,odd}^\infty {2\frac{{( - 1)^n - 1}}{{n\pi }}\sin (n\pi x)}

    is equal to

    f(x) = \sum\limits_{k = 1}^\infty { - 4\frac{1}{{(2k - 1)\pi }}} \sin ((2k - 1)\pi x)

    So both answers should be correct if I answered them on a test?

    And, I see what the (2k-1) does and how it works here. However, how did you know to use n=2k-1 without "guessing"?

    Thanks for all the help so far, I really appreciate it!
  12. May 6, 2009 #11


    User Avatar
    Gold Member

    [tex]\cos (n\pi ) = \mathop { - 1}\nolimits^n [/tex] is fairly obvious if you look at the graph of cosine. At n=1, [tex] \cos (\pi) = -1 [/tex], at n=2, [tex] \cos (2\pi) = 1 [/tex] and so on and so forth. Now [tex] \sin (n\pi) = 0 [/tex] always because at every integer pi, sine is 0.

    Typically [tex] B_n [/tex] is not going to have this even and odd business going on, you're simply going to get [tex] B_n [/tex] equal to some function of n.

    Both answers are correct, as you can see if you start expanding it out although the first one could be changed to simply -4 instead of -2*((-1)^n - 1) since you already say that n = odd.
  13. May 6, 2009 #12
    Thanks for all the help! I definitely get almost all of the content now but I still don't really understand how you know to equate n=2k-1, instead of n= something else
    I know why 2k-1 works in this place but how do I think to use that when I'm doing the problem from scratch (without peeking at the answer first)

    Also, I feel foolish to have to ask this, but I'm somehow integrating wrong for a different problem:

    bn = (1/pi) * integral(x sin(nx) dx) from -pi to pi

    I attempt to do this with substitution u=nx


    bn = 1/(n pi) * integral(u sinu du) from -n*pi to n*pi
    = 1/(n pi)* [sinu - ucosu] from -npi to npi
    = 1/(n pi)* (2sin(npi) - 2(npi)cos(npi)

    However, doing the integral on my calculator, I get this: http://integrals.wolfram.com/index.jsp?expr=x*sin[nx]&random=false which is also my book's answer
  14. May 6, 2009 #13


    User Avatar
    Homework Helper

    Integration by parts f(x)=x, g'(x)=sin(nx). Which you've already done at second glance. It looks like you didn't take du=ndx into account, that should give you the n^2.
    Last edited: May 6, 2009
  15. May 6, 2009 #14


    User Avatar
    Gold Member

    Well the only terms left are the n=1,3,5,7,9,11.... etc etc terms, but you like your series to be from some index = 1,2,3,4,5,6... and so on and so forth. How can you change your index to keep the original summation? Well If you let the index go as 2k-1, for k=1,2,3,4,5... you see that you retain the n= 2(1) - 1 = 1, 2(2) - 1 = 3, 2(3) -1 = 5... terms. When you're skipping odds or evens, the change of index will always be 2n plus or minus 1, depending which are skipped and where you start your index (1 or 0, although 1 is customary it seems).

    For your second problem, you didn't plug in your limits correctly. Sin(u) = 0 in your limits and ucos(u) will be n*pi*cos(n*pi)+n*pi*cos(-n*pi). Also as noted, you're missing another n from either not substituting in for x correctly or not taking into account du=n*dx
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook