# Fourier Series of an Odd Piecewise function

1. Apr 28, 2012

### JackFlash

1. The problem statement, all variables and given/known data
Fourier Series of the following function f(x).

f(x) is -1 for -.5<x<0
f(x) is 1 for 0<x<.5

2. Relevant equations
b$_{n}$ = $\frac{1}{L}$$\int$$^{L}_{-L}$f(x)sin(nπx/L)dx
Where L is half the period.

3. The attempt at a solution
Graphing the solution, I know that it is odd, which is why I didn't include the given function for the "even" cos(nπ) portion of the Fourier series.
Since the period is 1, L would be .5. So the function would look like this:

2$\int$$^{0}_{-.5}$(–sin(2nπx)dx) + 2$\int$$^{.5}_{0}$(sin(2nπx)dx)

To cut some work short, I get to:
$\frac{1}{πn}$ - $\frac{cos(nπ}{πn}$ - $\frac{cos(nπ}{πn}$ + $\frac{1}{πn}$

Which becomes:
$\frac{4}{πn}$sin$^{2}$($\frac{πn}{2}$)

I check my solution on Mathematica using these commands:
a = If[-.5 < x < 0, -1, If[0 < x < .5, 1]]
FourierTrigSeries[a, x, 5]

And see that there are terms for values where my b$_{n}$ should be zero.

EDIT: I was looking at another attempt I had made to this problem, so I corrected for that.

Last edited: Apr 28, 2012