What is the Fourier series for f(x) = |x|?

Niles
Messages
1,834
Reaction score
0
[SOLVED] Fourier series

Homework Statement


Hi.

Please take a look at:

https://www.physicsforums.com/showthread.php?t=104306

It is part 1 (finding the Fourier-series for f(x) = |x|) I am having trouble with.

The Attempt at a Solution


Ok, I can write f(x) = |x| for -pi =< x < pi as:

f(x) = x for 0 =< x < pi and
f(x) = -x for -pi =< x =< 0.

The function has period T=2.

I want to find a_n = int[f(x)*cos(n*pi*x)]dx with limits -1 .. 1. I split this integral up in two:

a_0 = int[-x}dx + ... but what are the limits? Are they -pi..0 or -1..0? The way I see it, neither of the limits work since a_0 must be pi.
 
Last edited:
Physics news on Phys.org
Ehh, on wikipedia they define a_n = (1/Pi)*int[f(x)*cos(nx)]dx, but in my book they don't use 1/pi, but 2/T where T is the period?
 
Do'h my period is all wrong. It's not 2, but 2*pi.
 
Ok, I'm stuck finding a_n. This is the expression for a_n:

(int(-x*cos(n*Pi*x), x = -Pi .. 0))/Pi+(int(x*cos(n*Pi*x), x = 0 .. Pi))/Pi

This I get to be:

(2*(cos(Pi^2*n)+sin(Pi^2*n)*n*Pi^2-1))/(Pi^3*n^2),

which does not make sense at all. Can you guys help?
 
Ehh ok, my a_n was wrong!

The correct a_n is:

(2*(cos(n*Pi)+sin(n*Pi)*n*Pi-1))/(Pi*n^2). This is zero for even n. Now I just need to write it as they ask me to. How to do that?
 
okay so you want the Fourier coefficients of f(x) = |x|. I haven't read all because I find it difficult to read when it's not in tex. Here's what I would take as plan of campaign though:

what you do is say c_{k} = \frac{1}{2\pi} {\int^{\pi}_{-\pi} |x| e^{-ikx} dx

this integral is not too hard, I imagine it's either something with partial integration, or else just straightforward, maybe cut something up in two pieces or something ;)

after that you say the Fourier series is \sum_{k} c_{k} e^{ikx}
 
Last edited:
I have found this for a_0 = Pi.

I have found this for b_n = 0.

I have found this for a_n = 2\,{\frac {\cos \left( n\pi \right) +\sin \left( n\pi \right) n\pi -<br /> 1}{\pi \,{n}^{2}}}<br />.

Now I want to write it as they want to me - with the sum, but I can't see how I should do that?
 
a0 = pi/2

for the other part you should just check your calculations and use wolfram integrator (search google) to see if you did everything correct. Also mathematica if you have it.

It would be as much work for me as you to find the error.

Sorry, maybe someone else will help you out.
 
What is the value of the following functions:

sin(n\pi)

and

cos(n\pi)

for n=1,2,3,...
 
  • #10
the integral gives - \frac{2}{\pi} \frac{coskx}{k^{2}}

where my k is his 2m

now you take the infinite summation and take back the sum one step :)
 
  • #11
Niles said:
I have found this for a_0 = Pi.

I have found this for b_n = 0.

I have found this for a_n = 2\,{\frac {\cos \left( n\pi \right) +\sin \left( n\pi \right) n\pi -<br /> 1}{\pi \,{n}^{2}}}<br />.

Now I want to write it as they want to me - with the sum, but I can't see how I should do that?

For a_0, it depends on the way you use the Fourier series. There are several ways going around for calculating the coefficients. The formula I use it is the following:

f(x)=\frac{a_0}{2}+\sum_{n=1}^{\infty}\left(a_n\cdot cos\left(\frac{2\pi nx}{T} \right) + b_n\cdot sin\left(\frac{2\pi nx}{T} \right) \right)

With:

a_n=\frac{2}{T}\int_{0}^{T}f(x)\cdot cos\left(\frac{2\pi nx}{T} \right)dx
b_n=\frac{2}{T}\int_{0}^{T}f(x)\cdot sin\left(\frac{2\pi nx}{T} \right)dx

In which T the period of the function. This can be shifted for the interval of the integral. But it is the complete period. Sometimes you see it used as an interval of 0 to 2 pi or -pi to pi, etc. This causes confusion. So, a_o=pi might be correct in your integral. The result in the Fourier series has to be pi/2.

jacobrhcp said:
a0 = pi/2

for the other part you should just check your calculations and use wolfram integrator (search google) to see if you did everything correct. Also mathematica if you have it.

It would be as much work for me as you to find the error.

Sorry, maybe someone else will help you out.

Mmmm, using code for these basic integrals... The result is at -first sight- correct. As I posted before, calculate

sin(n\pi)

it is always 0 and the cos function needs to be split up in even and odd n. You will arrive at the result you are seeking for.
 
  • #12
I used Maple to find the integrals.

I agree with what you wrote coomast - I used those "versions" as well. For n being even, a_n is 0. When n is odd, a_n is different from 0.

From these things I have to write the sum. This is where I am stuck.

EDIT: I read your post again, and noted what you said about sin(n*pi). I'll look at it and return.
 
  • #13
Ok, since sin(n*Pi) = 0 for all n, I get the expression for a_n:

2\,{\frac {\cos \left( \pi \,n \right) -1}{\pi \,{n}^{2}}}.

I must multiply this with cos(n*x) (actually it's cos(2xnpi/L), but L=2pi). This gives me the following sum in the Fourier-series:

2\,{\frac { \left( \cos \left( \pi \,n \right) -1 \right) \cos \left( <br /> {\it nx} \right) }{\pi \,{n}^{2}}}.

For n being even a_n = b_n = 0. For n being odd I get:

-4\,{\frac {\cos \left( {\it nx} \right) }{\pi \,{n}^{2}}}. This isn't quite what we want?
 
Last edited:
  • #14
You are almost at the result. The function:

cos(n\pi)-1=0 \qquad \forall n \qquad even

For odd this is:

cos(n\pi)-1=-2 \qquad \forall n \qquad odd

Instead of writing odd and even, you can say that:

n \qquad odd \rightarrow n=2k+1 \qquad for \qquad k=0,1,2,...

Thus in the Fourier series you have only those terms left in n which are odd or if you change n by 2k+1 you get the final result. In case this in unclear please post, I'm going to be online for a while.
 
  • #15
Sorry, but I am a little unclear of what you wrote. I can't see why I should substitute with n = 2k+1? And if I do substitute, the it is cos((2k+1)*x), not cos(2k+1)*x as they want to me get.

Thanks for all your help so far.

EDIT: Oh, I see :-) But still, when substituting, x is inside cos(...) and not outside?
 
  • #16
I think you have it :-)

The x has to be part of the argument of the cos function. This is an error in the use of the brackets. This can also cause a lot of confusion.

Anyway, glad you found it.

best regards, Coomast
 
  • #17
Thanks so much for your patience.
 
  • #18
You're welcome :-)
 
Back
Top