Fourier Series for a piecewise function help

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 3K views
dinospamoni
Messages
90
Reaction score
0

Homework Statement



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]

Homework 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]

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?
 

Attachments

  • Screen capture00000000000000000 2013-04-24 at 4.01.46 PM.JPG
    Screen capture00000000000000000 2013-04-24 at 4.01.46 PM.JPG
    17.1 KB · Views: 550
  • Screen capture00000000000000000 2013-04-24 at 4.02.58 PM.JPG
    Screen capture00000000000000000 2013-04-24 at 4.02.58 PM.JPG
    8 KB · Views: 458
Last edited:
Physics news on Phys.org
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:
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:
I figured out what I did wrong, but thanks!