# Fourier series problem solving for an,bn

1. Jul 9, 2011

### dp182

1. The problem statement, all variables and given/known data
let f(x)={0;-2$\leq$x$\leq$0.
x;0$\leq$x$\leq$2
find a0
an
bn
given the period is 4
2. Relevant equations
a0=1/L$\int$f(x)dx
an=1/L$\int$f(x)cos(n$\pi$x/L)
bn=1/L$\int$f(x)sin(n$\pi$x/L)

3. The attempt at a solution
so I can get a0 = 1 but I run into trouble with an. so I plug
an=1/2$\int$xcos(n$\pi$x/L) for the interval 0$\leq$x$\leq$2 and I get the solution
=(1/n2$\pi$2)2xn$\pi$sin(n$\pi$x/2)+4cos(n$\pi$x/2) then subbing in for x I get (1/n2$\pi$2)(4n$\pi$sin(n$\pi$)+4cos(n$\pi$)-1) can anyone tell me what I am doing wrong here?

2. Jul 9, 2011

### micromass

Staff Emeritus
Hi dp182!

You made two mistakes: you forgot the term 1/L, so you still need to divide by 2. Secondly, when you "subbed for x", you made a mistake in "subbing for 0". That is, the correct formula is

$$\int_0^2{f(x)dx}=F(2)-F(0)$$

But somehow, you calculated F(0) wrong.

3. Jul 9, 2011

### dp182

but wouldn't F(0) be 4cos(0)/n2pi2 which is just 4/n2pi2

4. Jul 9, 2011

### micromass

Staff Emeritus
Indeed, but you wrote -1 instead of -4 in the end.

5. Jul 10, 2011

### dp182

ya but I brought out a 4/n2pi2 so its not -1 its -4/n2pi2