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

  1. Feb 29, 2008 #1
    [SOLVED] Fourier series

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

    Please take a look at:


    It is part 1 (finding the Fourier-series for f(x) = |x|) I am having trouble with.

    3. The attempt at a solution
    Ok, I can write f(x) = |x| for -pi =< x < pi as:

    f(x) = x for 0 =< x < pi and
    f(x) = -x for -pi =< x =< 0.

    The function has period T=2.

    I want to find a_n = int[f(x)*cos(n*pi*x)]dx with limits -1 .. 1. I split this integral up in two:

    a_0 = int[-x}dx + ... but what are the limits? Are they -pi..0 or -1..0? The way I see it, neither of the limits work since a_0 must be pi.
    Last edited: Feb 29, 2008
  2. jcsd
  3. Feb 29, 2008 #2
    Ehh, on wikipedia they define a_n = (1/Pi)*int[f(x)*cos(nx)]dx, but in my book they don't use 1/pi, but 2/T where T is the period?
  4. Feb 29, 2008 #3
    Do'h my period is all wrong. It's not 2, but 2*pi.
  5. Feb 29, 2008 #4
    Ok, I'm stuck finding a_n. This is the expression for a_n:

    (int(-x*cos(n*Pi*x), x = -Pi .. 0))/Pi+(int(x*cos(n*Pi*x), x = 0 .. Pi))/Pi

    This I get to be:


    which does not make sense at all. Can you guys help?
  6. Feb 29, 2008 #5
    Ehh ok, my a_n was wrong!

    The correct a_n is:

    (2*(cos(n*Pi)+sin(n*Pi)*n*Pi-1))/(Pi*n^2). This is zero for even n. Now I just need to write it as they ask me to. How to do that?
  7. Feb 29, 2008 #6
    okay so you want the fourier coefficients of f(x) = |x|. I haven't read all because I find it difficult to read when it's not in tex. Here's what I would take as plan of campaign though:

    what you do is say [tex] c_{k} = \frac{1}{2\pi} {\int^{\pi}_{-\pi} |x| e^{-ikx} dx [/tex]

    this integral is not too hard, I imagine it's either something with partial integration, or else just straightforward, maybe cut something up in two pieces or something ;)

    after that you say the fourier series is [tex] \sum_{k} c_{k} e^{ikx} [/tex]
    Last edited: Feb 29, 2008
  8. Feb 29, 2008 #7
    I have found this for a_0 = Pi.

    I have found this for b_n = 0.

    I have found this for a_n = [tex]2\,{\frac {\cos \left( n\pi \right) +\sin \left( n\pi \right) n\pi -
    1}{\pi \,{n}^{2}}}

    Now I want to write it as they want to me - with the sum, but I can't see how I should do that?
  9. Feb 29, 2008 #8
    a0 = pi/2

    for the other part you should just check your calculations and use wolfram integrator (search google) to see if you did everything correct. Also mathematica if you have it.

    It would be as much work for me as you to find the error.

    Sorry, maybe someone else will help you out.
  10. Feb 29, 2008 #9
    What is the value of the following functions:




    for n=1,2,3,...
  11. Feb 29, 2008 #10
    the integral gives [tex]- \frac{2}{\pi} \frac{coskx}{k^{2}}[/tex]

    where my k is his 2m

    now you take the infinite summation and take back the sum one step :)
  12. Feb 29, 2008 #11
    For a_0, it depends on the way you use the Fourier series. There are several ways going around for calculating the coefficients. The formula I use it is the following:

    [tex]f(x)=\frac{a_0}{2}+\sum_{n=1}^{\infty}\left(a_n\cdot cos\left(\frac{2\pi nx}{T} \right) + b_n\cdot sin\left(\frac{2\pi nx}{T} \right) \right)[/tex]


    [tex]a_n=\frac{2}{T}\int_{0}^{T}f(x)\cdot cos\left(\frac{2\pi nx}{T} \right)dx[/tex]
    [tex]b_n=\frac{2}{T}\int_{0}^{T}f(x)\cdot sin\left(\frac{2\pi nx}{T} \right)dx[/tex]

    In which T the period of the function. This can be shifted for the interval of the integral. But it is the complete period. Sometimes you see it used as an interval of 0 to 2 pi or -pi to pi, etc. This causes confusion. So, a_o=pi might be correct in your integral. The result in the Fourier series has to be pi/2.

    Mmmm, using code for these basic integrals... The result is at -first sight- correct. As I posted before, calculate


    it is always 0 and the cos function needs to be split up in even and odd n. You will arrive at the result you are seeking for.
  13. Feb 29, 2008 #12
    I used Maple to find the integrals.

    I agree with what you wrote coomast - I used those "versions" as well. For n being even, a_n is 0. When n is odd, a_n is different from 0.

    From these things I have to write the sum. This is where I am stuck.

    EDIT: I read your post again, and noted what you said about sin(n*pi). I'll look at it and return.
  14. Feb 29, 2008 #13
    Ok, since sin(n*Pi) = 0 for all n, I get the expression for a_n:

    [tex]2\,{\frac {\cos \left( \pi \,n \right) -1}{\pi \,{n}^{2}}}[/tex].

    I must multiply this with cos(n*x) (actually it's cos(2xnpi/L), but L=2pi). This gives me the following sum in the Fourier-series:

    [tex]2\,{\frac { \left( \cos \left( \pi \,n \right) -1 \right) \cos \left(
    {\it nx} \right) }{\pi \,{n}^{2}}}[/tex].

    For n being even a_n = b_n = 0. For n being odd I get:

    [tex]-4\,{\frac {\cos \left( {\it nx} \right) }{\pi \,{n}^{2}}}[/tex]. This isn't quite what we want?
    Last edited: Feb 29, 2008
  15. Feb 29, 2008 #14
    You are almost at the result. The function:

    [tex]cos(n\pi)-1=0 \qquad \forall n \qquad even[/tex]

    For odd this is:

    [tex]cos(n\pi)-1=-2 \qquad \forall n \qquad odd[/tex]

    Instead of writing odd and even, you can say that:

    [tex]n \qquad odd \rightarrow n=2k+1 \qquad for \qquad k=0,1,2,...[/tex]

    Thus in the fourier series you have only those terms left in n which are odd or if you change n by 2k+1 you get the final result. In case this in unclear please post, I'm going to be online for a while.
  16. Feb 29, 2008 #15
    Sorry, but I am a little unclear of what you wrote. I can't see why I should substitute with n = 2k+1? And if I do substitute, the it is cos((2k+1)*x), not cos(2k+1)*x as they want to me get.

    Thanks for all your help so far.

    EDIT: Oh, I see :-) But still, when substituting, x is inside cos(...) and not outside?
  17. Feb 29, 2008 #16
    I think you have it :-)

    The x has to be part of the argument of the cos function. This is an error in the use of the brackets. This can also cause a lot of confusion.

    Anyway, glad you found it.

    best regards, Coomast
  18. Mar 1, 2008 #17
    Thanks so much for your patience.
  19. Mar 1, 2008 #18
    You're welcome :-)
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook