Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Find the fourier series representation of x^2

  1. Mar 12, 2006 #1
    ok, i wasn't sure if i ought put this in math or phys, we're going over it my phys class, but its just math... whatever..

    So i had to find the fourier series representation of x^2 in the intervals (-pi, pi) and (0, 2pi). i haven't even started the (0, 2pi) one, cause i can't get the first half.

    so i started with the coefficients, and for a_0 i got

    [tex] a_0= 1/\pi \int_{-\pi}^\pi (0)^2 * cos(0*\pi) dx= 0[/tex] and i don't think that's right, the answer in the back of the book was... ok turns out i didn't write it down, but it was something + stuff*cos. So i assumed the something was the a_0/2 but i think it had pi^2 and i think it was over 3 or something, it seemed like maybe it wasn't a_0, so i kept going, with my a_n's.

    so for a_n, i set it up, do integration by parts twice, and i get 0 again. same for b_n. i dunno what i'm doing wrong but everything keeps cancelling out and i get zeros. so could someone maybe help me through this problem? this isn't even an assigned problem, but i thought i'd try one i knew the answer to first, to make sure i knew what i was doing, but turns out i have no idea. help???
    Last edited: Mar 12, 2006
  2. jcsd
  3. Mar 12, 2006 #2
    ok, apparently my equation for a_0 is wrong for starters, i googled fourier series of x^2 and found some sites, but they don't show all the steps, or the equation for a_0 that they start with. i don't have a book so i'm looking at online sources, and i'm not really sure whats going on any more. here's what i though,

    [tex] a_n= 1/\pi \int_{-\pi}^\pi f(x)* cos(nx) dx[/tex]

    then for a_0 you eval f and cos at x=0. apparently this isn't the case? i'm confused.
  4. Mar 12, 2006 #3


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member


    [tex] a_n= 1/\pi \int_{-\pi}^\pi f(x)* cos(nx) dx[/tex]

    then looking for [itex]a_0[/itex] means plugging in n = 0 into that equation. (It wouldn't make sense to plug in x = 0 anyways, because that's a dummy variable)

    FYI, I think the [itex]a_0[/itex] term goes by a different formula than all the others... I think it's [itex]1/2\pi[/itex] out front, but I don't remember for sure.

    I can't tell what's going wrong with your integration if you don't show your work. :wink:
    Last edited: Mar 12, 2006
  5. Mar 12, 2006 #4
    ok, i plug in n=0, thats good to know. now i've been looking online and in my notes, and in different places it says a_0 has 1/pi and others say 1/2pi. then some say the general formula is a_0/2 and some just say a_0, and i thought this mad sense until i realized some of the places say a_0 = 1/2pi also had a_0/2 and i'm like ugh. i can't find stuff that makes sense.

    also, i was doing the series for sin(pi*x) and i figured, you don't use any cosines, (why would you) but then when i solve for b_n's i get 0, so it means no sins! ugh. i don't know what the problem is! these seem so straight forward and i can't get a single answer!
  6. Mar 12, 2006 #5
    ok ok, some work:

    [tex] f(x)= sin(\pi*x); x= (-1/2, 1/2)[/tex]

    i thought there was no cosines so no a_n's..

    [tex] a_0= 1/\pi \int_{-1/2}^{1/2} sin(\pi x) dx) = 0 [/tex]

    [tex] b_n= 1/\pi \int_{-1/2}^{1/2} sin(\pi x)*sin(2n\pi x)dx= \frac {(-1)^n}{\pi} \int_{-1/2}^{1/2} sin^2(2 \pi nx)= \frac {(-1)^n}{2 \pi}*-cos^3(2\pi nx)*(\frac{1}{2\pi n} |_{-1/2}^{1/2}= \frac{(-1)^{n+1}}{4\pi^2 n} cos^3(2\pi nx) |_{-1/2}^{1/2}= 0[/tex]

    cause cos(pi)=cos(-pi) right? sooooo....
  7. Mar 12, 2006 #6


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Oh, did you change problems? You're not working on f(x) = x² anymore?

    1/\pi \int_{-1/2}^{1/2} sin(\pi x)*sin(2n\pi x)dx
    = \frac {(-1)^n}{\pi} \int_{-1/2}^{1/2} sin^2(2 \pi nx)

    How did you do this? I don't think [itex]\sin (\pi x) = (-1)^n \sin(2 \pi n x)[/itex].

    Also, the next step is wrong too: it looks like you tried to use the chain rule for derivatives. You don't have that here -- the analogous concept is making a substitution. Your calc book probably has a whole section on trig integrals if you want to look up how to do that one... but that integral doesn't matter since the first step is wrong.

    What you want to use is a trig identity!
    Last edited: Mar 12, 2006
  8. Mar 12, 2006 #7
    i dunno, i quit, never mind.
  9. Mar 12, 2006 #8
    PF rules state that Gale is not allowed to quit, reread the material and try again.
  10. Mar 12, 2006 #9
    ok, once i stopped crying, finished some other homework, and tried to feel less stupid, i tried again.

    so, yes i changed problems because x^2 isn't on my homework, and i'd rather be working on a homework problem, so i can at least have one problem to turn in tomorrow...

    there's no a_n terms because the function is sin(pi x); x=(-1/2, 1/2)

    [tex]b_n= 1/\pi \int_{-1/2}{1/2}sin(\pi x)*sin(2n\pi x) dx= 1/\pi\[1/2( \frac {(sin(2n-1)\pi x}{(2n-1)\pi} - \frac{sin(2n+1)\pi x}{(2n+1)\pi}) |_{-1/2}^{1/2}[/tex]

    i used a table of integrals, which is fine for this class. now, when i evaluate it, i think i just get twice the integral at the upper limit, cause sin(-A)=-sin(A), get what i mean? i didn't want to write it all out in tex. yeah... so i get

    [tex] 1/\pi^2( \frac {sin(2n-1) \pi/2}{(2n-1)}-sin(2n+1)\pi/2}{(2n+1))}[/tex]

    k, then i'm trying to simplify the sin's. so for the first one i do

    [tex]sin(2n-1)\pi/2= sin(n\pi -\pi/2)=sin(n\pi)cos(\pi/2)-sin(\pi/2)cos(n\pi)= 1[/tex]

    the second:

    [tex]sin(2n+1)\pi/2= sin(n\pi +\pi/2)=sin(n\pi)cos(\pi/2)+sin(\pi/2)cos(n\pi)= -[/tex]

    then we use those, and get a common denom, and i get:

    [tex]b_n= \frac {(2n+1)+(2n-1)}{4n^2-1}=\frac {4n}{4n^2-1}[/tex]
    that's wrong though...
  11. Mar 13, 2006 #10


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    1. Regarding the a0 confusion. My textbook says that if you decide to call the first (constant) term in the Fourier series a0/2, then this has the advantage that all of the an's can be calculated from the same formula, including a0.

    2. My formula for bn is as follows:

    [tex] b_n = \frac{1}{L}\int_{-L}^{L} f(x) \sin\frac{n \pi x}{L} \ dx [/tex]

    Substituting L = 1/2, I get:

    [tex] b_n = 2 \int_{-1/2}^{1/2} \sin(\pi x) \sin(2n \pi x) \ dx [/tex]

    So i guess my question is, where is the 1/pi coming from in front of your integrals? Did I just overlook something simple?
  12. Mar 13, 2006 #11


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    3. It's really handy to have some common trig identities at your fingertips. Whenever I see sinAsinB, I think of the trig identities where those sin-sin terms occur:

    cos(A+B) = cosAcosB - sinAsinB
    cos(A-B) = cosAcosB + sinAsinB

    How do we get rid of those pesky cos-cos terms? They have the same sign in each equation, so try subtracting the upper equation from the lower!

    cos(A-B) - cos(A+B) = sinAsinB - (-sinAsinB) = 2sinAsinB

    So sinAsinB = 1/2[cos(A-B) - cos(A+B)], and that's a good one to remember.

    Let A = 2n(pi)x, B = pi*(x)

    The integrand becomes:

    [tex] \frac{1}{2}[\cos(2n-1)\pi x - \cos (2n+1)\pi x] [/tex]

    The integral becomes:

    [tex] b_n = \int_{-1/2}^{1/2}{\cos(2n-1)\pi x \ dx} - \int_{-1/2}^{1/2}{\cos(2n+1)\pi x \ dx} [/tex]

    Now you can see where that antiderivative you found in the table comes from! Remember these trig identities, in quantum mechanics class, for instance, we were just sort of expected to know them off the tops of our heads (lol).

    You sound overworked. I know the feeling. For me the 'day of homework convergence' is Friday, not Monday. I almost always have a weekly quantum mechanics assignment and complex analysis assignment due on that day. This week it will be much worse because I also have a Friday midterm in my Signals and Systems course on none other than Fourier series and Fourier transforms. =\

    Don't know what else to suggest except to keep calm. You win some, you lose some. Stress is your worst enemy. (I have to keep telling myself that too.)
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook