# Homework Help: Fourier series expansion problem

Tags:
1. Aug 11, 2015

### bbq pizza

< Mentor Note -- thread moved to HH from the technical forums, so no HH Template is shown >

hi I've got a problem that I've partially worked but don't understand the next part/have made a mistake?

f(x)=0 for -π<x<0 and f(x)=x for 0≤x≤π
i got a0=π/4 and an=0 and bn=0 if n is even and 2/n if n is odd

so.... f(x)= π/4 + ∑ (2/(2n+1)) * sin(2n+1) * π * x
n=0
now i need to show π/4 = 1 - 1/3 + 1/5 ......... using suitable values of x
how would i go about doing this?
any help is much appreciated

Last edited by a moderator: Aug 11, 2015
2. Aug 11, 2015

### BvU

Hello bbq, welcome to PF !

Can you show how you found these Fourier coefficients ?

Your choices for x are pretty limited, right ? If you try $x=\pi$ (not the right answer I suppose) what does the series give you ?

3. Aug 11, 2015

### bbq pizza

http://imageshack.com/a/img911/5796/jhLmo0.jpg [Broken]
http://imageshack.com/a/img673/1972/xQeDHn.jpg [Broken]
x=pi gives too high so i must have made a mistake on calculation of ceoffiscients but i don't see it

Last edited by a moderator: May 7, 2017
4. Aug 11, 2015

### BvU

Wow. So you write it as a cosine series ? No sines ? Wouldn't that ($b_n = 0$ the coefficents for sin nx for all n) give an even function as a result ?

 oh, wait, the picture continues further down. Need some time to decrypt...

And $$a_n \equiv {1\over 2\pi} \int_0^\pi x\cos (nx)\; dx\quad {\rm ?}$$

5. Aug 11, 2015

### BvU

I can see $a_n = 0$ for n = even. What if n is odd ?

6. Aug 11, 2015

### BvU

could that be f(x)= π/4 + 1/(2π) ∑ (2π/(2n+1)) * sin((2n+1) * x) ? And then you choose x = π/2 to get the (-1)n ?

(a choice that gets rid of the cosines too ! )

Modulo further errors on my part ....

7. Aug 11, 2015

### bbq pizza

thanks BvU.
I looked over it and noticed some mistakes, so.. an=( (-1)^n -1) / (π * n^2)
and bn= - ( (-1)^n ) / n
i see the π/2 getting rid of cosine but how do i achieve the π/4 = 1 - 1/3 + 1/5 ......... using suitable values of x.
do i set x=π/4 then get 1 for ??

8. Aug 11, 2015

### BvU

You're real close now !
But I suspect the (-1)n-1 and (-1)n is wishful thinking ? Could you explain ?

On the one hand you have $f(x) = x$
On the other you have $f(x) = π/4 + ...\Sigma ... \cos((2n+1)x)\ + \ ... \sin ((2n+1)x)$
Now make sure you have the right multipliers and coefficients
and pick an x that lets the cosines disappear and the sines be (-1)n

9. Aug 19, 2015

### bbq pizza

i got π/4 + ( ( -1)n-1 ) cos(nx) ) /π*n2+( (-1)nsin(nx) ) /n
with the an=(-1)n-1) / (πn2) because during the an calculation i get an=( cos(nπ)-cos(n0) ) / (πn2) and cos1π=-1 and cos(0)=cos2π=1 so -1n=+1 for n=even and =-1 for n=odd
and bn= - ( (-1)n ) / n from ( -nπcos(nπ) )/πn2

I'm still unsure if I've made a mistake or not, as when i make x=π/4 i don't get 1 at n=0 like in the sequence but do get -0.37 for n=1. could that mean a mistake in the equation for the even term?

Last edited: Aug 19, 2015
10. Aug 20, 2015

### BvU

Hi there,

Yes, sorry, the (-1)n re-appears if you go back from summing 2n+1 to summing n .

I've been piling error on top of error in this exercise (*) as well (nobody is perfect), but I convinced myself you are perfectly correct (I cheated by finding the series in a textbook example). Even made a plot for the first eight terms:

Nice to see a triangle (no discontinuities) is easier to reproduce than a sawtooth !

Now I'm not sure what you mean with "when i make x=π/4 i don't get 1 at n=0 like in the sequence"

You make x a certain value and you add a good number of terms. At n = 0 you are supposed to get only the π/4 and the summation for the sines and cosines start at n = 1.

Going back to your original exercise: to show π/4 = 1 - 1/3 + 1/5 you need a value for x that makes the cosine terms to go away. In fact the plot above makes the choice obvious ! So sorry for spoiling ...

(*) E.g. the $\ ... \sin ((2n+1)x)$ in post #8 should have been $\ ... \sin (nx)$