# Fourier Series assistance

1. Aug 17, 2012

### ProPatto16

1. The problem statement, all variables and given/known data

Given the function f(x) = Acos(∏x/L), find its Fourier series

2. Relevant equations

Okay so, f(x) is even, so the fourier series is given by:

f(x) = a0 + $\sum$ancos(nx)

where a0 = 1/∏$\int$ f(x).dx with bounds ∏ and -∏

and an = 1/∏$\int$ f(x)cos(nx).dx with bounds ∏ and -∏

3. The attempt at a solution

okay, with range L

a0 = 2/L$\int$f(x).dx with bounds L to 0

and an = 2/L$\int$f(x)cos(n∏x/L).dx with bounds L to 0

starting with a0:

a0 = 2/L$\int$f(x).dx with bounds L to 0

a0 = 2A/L$\int$cos(∏x/L).dx

integrates to a sin, first sub in L gives sin∏ which = 0 and then sub the 0 gives sin0 which = 0 so therefore a0 = 0

now an:

and an = 2/L$\int$f(x)cos(n∏x/L).dx with bounds L to 0

an = 2A/L$\int$cos(∏x/L)cos(n∏x/L).dx

an = 2A/L$\int$cos2(n∏x/L).dx

integral of cos2x = x/2 + (1/4)sin2x

so : an = 2A/L[n∏x/2L + (1/4)sin(2n∏x/L)] between L and 0

sub in 0 gives 0 + sin0, so only need to sub L,

an = 2A/L[n∏/2 + (1/4)sin(2n∏)]

an = An∏/L + (2A/L)sin(2n∏)

so then subbing back into expression for fourier series with a0 = 0 gives:

f(x) = $\sum$ [An∏/L + (2A/L)sin(2n∏)](cos(nx))

doing this course by distance education and theres no textbook, and the online notes are fairly vague. so i just wanna check im on the right track or at least the right method of solving etc. sorry about the latex. not the best at that. thanks.

2. Aug 17, 2012

### gabbagabbahey

Re: Fourier Series assisstance

I haven't checked the rest of your solution, but $\cos \left( \frac{\pi x}{L} \right)\cos \left( \frac{n \pi x}{L} \right) \neq \cos^2 \left( \frac{n \pi x}{L} \right)$

3. Aug 17, 2012

### LCKurtz

Re: Fourier Series assisstance

That wouldn't be the natural FS to use. Your function $A\cos(\frac {\pi x}{L})$ has period $2L$ so you would normally expand it like this$$A\cos(\frac{\pi x}{L}) = a_0 +\sum_{n=1}^\infty \left( a_n\cos(\frac{n\pi x}{L})+b_n\sin(\frac{n\pi x}{L})\right)$$used for a function of period $2L$ instead of $2\pi$. And the formulas for $a_n$ and $b_n$ change accordingly.

Alert: There is also a very quick shortcut for calculating the $a_n$ and $b_n$ which you might notice if you look carefully at the FS and function you are expanding.

Last edited: Aug 17, 2012
4. Aug 17, 2012

### uart

Re: Fourier Series assisstance

Hi ProPat, I haven't read all of your solution, but just make sure you are totally clear about what function you are working with before you start.

All Fourier series require that the function be periodic. This is ideally stated explicitly in the function definition, but can be sometimes be implied by the domain you're given to work with. In this example if that domain was [0..2L] then answer would be trivial (and obtained by inspection). Given however that you appear to be working on [0..L], then your function is just a piece of that cosine wave (not a full cycle), repeated with period L.

This function is not "even", so I suspect you are missing something here from the get-go. Try making a sketch of the function before you begin.

Last edited: Aug 17, 2012
5. Aug 17, 2012

### dydxforsn

Re: Fourier Series assisstance

You should give people time to edit their posts... Though no offense taken. I made a mistake when I clicked "post" on that one instead of "preview post", so it's technically my mistake. Though I fixed the error and erased my post temporarily within a minute or so until I had finished, so your timing is especially impeccable.

As far as working the problem for the poster, I used my discretion when working the problem simply because he hinted that he possibly didn't have the required training to work the problem. I did it for pedagogical reasons which I feel will feel should always trump the rules.

Last edited: Aug 17, 2012
6. Aug 17, 2012

### George Jones

Staff Emeritus
Re: Fourier Series assisstance

The original poster actually wrote:
This makes it clear the original post was homework.
No. Physics Forums Rules state
Everyone agrees to the Physics Forums Rules when they register.

Your help is welcome, but try a give help one step/hint (or a small number of steps/hints) at a time.

7. Aug 17, 2012

### Staff: Mentor

Re: Fourier Series assisstance

No, it does not trump the rules. Do not do students' schoolwork for them.

EDIT -- George beat me to it!

8. Aug 17, 2012

### ProPatto16

Re: Fourier Series assisstance

∫hey guys,

LCKurtz:

in my attempt at a solution part i defined

an = 2/L ∫ f(x)cos(n∏x/L)... is that not correct?

i can see the relationship there between the FS definition and an bn, and i assumed the period was L. im pretty sure the lecture notes and the assignment questions are from two completely different places, because all through the lecture notes "D" is used as "repeats" and theres not an L in sight, so im not entirely sure how to relate L and D inside the different forms of the FS. like i said, ambiguous study notes, pretty much re-teaching myself from internet resources.

gabbagabbahey: we meet again :) hah

like 2 minutes after i originally posted i realised that sweet screw up haha.

∫cos(n∏x/L .dx = -1/n*sin(n∏x/L)

if i take ∫cos(∏x/L)cos(n∏x/L) .dx and try integrate by parts its never ending.
i plugged it into an online integral caclulator and its a massive result so im assuming im missing something somewhere.

can someone please elaborate on the relationship between L and D and ill have a go from there. using the FS definition that LCKurtz posted, which is what i was using in the end, but i am using it with range L, so bounds 0 > L.

in my study notes is this definition

f(x) = A0/2 + Ʃ ancos(2∏nx/D) + Ʃ bnsin(2∏nx/D)

A0 = 2/D ∫ f(x).dx

an = 2/D ∫ f(x)cos(2∏nx/D).dx

bn = 2/D ∫ f(x)sin(2∏nx/D).dx

so from the given equation and that definition, D = 2L yes? does L have a meaning? D is the period i thought. is L just another way to define the range?

so if thats the case, as "uart" posted (sorry if thats not the full username, some appears to have not loaded on my browser) the answer should be obtainable by inspection using the exponential FS?

the original problem statement posted is all im given by the way.

thanks guys

Last edited: Aug 17, 2012
9. Aug 17, 2012

### gabbagabbahey

Re: Fourier Series assisstance

Use a trig identity instead of integration by parts; $\cos u \cos v = \cos (u+v) + \cos (u-v)$, and be very careful to break this into two cases: $n=1$ and $n \neq 1$ before integrating.

Let's give this a little more rigour first:

The Fourier series of a periodic function $f$, with period $D$ on the entire $x$ axis, which is piecewise smooth on the interval $- \frac{D}{2} < x < \frac{D}{2}$, and defined at each point $x$ where it is discontinuous as the mean value of the one-sided limits $f(x+)$ and $f(x-)$, valid for each $x \in (-\infty, \infty)$ is given by:

$$f(x) = \frac{a_0}{2} + \sum_{ n=1 }^{ \infty }a_n \cos \frac{2n \pi x}{D} + b_n \sin \frac{2n \pi x}{D}$$

where

$$a_n = \frac{2}{D} \int_{ - \frac{D}{2} }^{ \frac{D}{2} } f(x) \cos \frac{2n \pi x}{D} dx \quad ( n = 0,1,2, \ldots )$$

$$b_n = \frac{2}{D} \int_{ - \frac{D}{2} }^{ \frac{D}{2} } f(x) \sin \frac{2n \pi x}{D} dx \quad ( n = 1,2, \ldots )$$

Does this definition agree with the one in your notes/textbook? If so, does $f(x) = \cos \frac{ \pi x }{L} \quad 0 < x < L$ (and $f(x) = 0$ elsewhere!) satisfy the conditions given in the above definition? If so, what is $D$ in this case?

10. Aug 17, 2012

### ProPatto16

Re: Fourier Series assisstance

okay so this is the integral i got

$$\int \cos \frac{ \pi x}{L} \cos \frac{n \pi x}{L} dx$$ = $$\frac{ ((n-1) \sin \frac{ ((n \pi + \pi )x}{L}) + (n+1) \sin \frac{ ((n \pi - \pi )x}{L}))}{2 \pi n^2 - 2 \pi}$$

but now if i take bounds L and 0 and sub them in all sin terms become sin(∏(n-1)) and any integer multiple of sin∏ = 0 so an = 0

11. Aug 17, 2012

### LCKurtz

Re: Fourier Series assisstance

You are assuming that the period is $2L$ with this formula. That is also what I would assume. But notice that your answer doesn't work when $n=1$ because it gives $\frac 0 0$. You have to do that case separately. Write out that integral separately and use a different method on it. You should wind up with $a_1=A$. Then you might look again at the "Alert" hint in my first post.

I am also going to comment on your other post.

12. Aug 17, 2012

### LCKurtz

Re: Fourier Series assisstance

No. The period is $2L$ for that formula and it is pretty standard to use it that way.

In those formulas $D$ is the full period so, yes, $D=2L$. I must say I have never seen a text that expressed the formulas in terms of the full period $D$ that way. If you put $D=2L$ in those formulas you will get the standard formulas given in most texts. In fact, it is quite common to denote the full period by $P$ and use $P=2p$ in the formulas.

13. Aug 17, 2012

### ProPatto16

Re: Fourier Series assisstance

yeah i noticed that you get 0/0 but then sin0 is just zero anyway ? same as the rest.

with the splitting of the integral,

do i take the integral

$$\int \cos \frac{ \pi x}{L} \cos \frac{n \pi x}{L} dx$$

and then evaluate it with n = 1 and then n = everything else.

so the integral i did was n = everything else which is all zero, then integrate the integral with n = 1 so it becomes

$$\int \cos \frac{ \pi x}{L} \cos \frac{ \pi x}{L} dx$$

and then integrating that, this is what i got

$$\frac{ \sin \frac{2 \pi x}{L}L + 2 \pi x }{4 \pi}$$

then subbing in L there, the sin term becomes sin2∏ which is 0, so its 2∏L/4∏ = L/2 and the subbing in of the 0 just results in a 0.

so an = 2A/L(L/2) and there it is, = A

so now work through bn the same way and i should get a good result. that will take some time.

14. Aug 17, 2012

### ProPatto16

Re: Fourier Series assisstance

i found this as a general formula with bounds [a,b]

$$f(x) = \frac{a_0}{2} + \sum_{ n=1 }^{ \infty }a_n \cos \frac{n \pi x}{L} + b_n \sin \frac{n \pi x}{L}$$

where L = (b-a)/2 and the co-efficients are :

$$a_n = \frac{1}{L} \int_{ a }^{ b } f(x) \cos \frac{n \pi x}{L} dx$$

$$b_n = \frac{1}{L} \int_{ a }^{ b } f(x) \sin \frac{n \pi x}{L} dx$$

is that a good general formula?

15. Aug 17, 2012

### LCKurtz

Re: Fourier Series assisstance

Yes. But almost always you will find you use [a,b] = [-L,L] or [a,b] = [0,2L]. But you can always integrate over any period since if $f(x)$ has period $P$ then$$\int_0^Pf(x)dx = \int_a^{a+P}f(x)dx$$for any $a$.

16. Aug 17, 2012

### LCKurtz

Re: Fourier Series assisstance

You mean $a_1=A$, not $a_n=A$. Now look back at my post #3. Do you see why you could have concluded $a_1=A$ and all the other coefficients are zero immediately?

17. Aug 17, 2012

### gabbagabbahey

What is the exact wording on the question as given to you? In particular, is the function $f(x)=\cos \left( \frac{\pi x}{L} \right)$ everywhere, or just for $0 < x <L$ (and presumably zero elsewhere except, perhaps at $x=L$ and $x=0$), because the answer is very different in the two cases.

18. Aug 18, 2012

### ProPatto16

LCKurts:

yeah i see, for n = 1, Acos(∏x/L) = ancos(∏x/L) and all sin terms are zero since any integer multiple of sin∏ is zero. so for n = 1, A = a1

what about for the rest of n? theyre all zero right? so when expressing the answer i dont specify its a1?

gabba: the problem statement originally posted is all i have.

the exact complete question is this:

Given the function f(x) = Acos(∏x/L), determine its Fourier series.

there is nothing else, no domain specified or anything.

so does that mean ive done everything wrong so far? or right? is a0 = A/L and an = A. or is that not all there is to ann? just trying to summarise.

thanks guys

19. Aug 18, 2012

### gabbagabbahey

In that case, your response to LCKurts is correct, a1=A and all other coefficients are zero... what does that make the Fourier Series? (don't be too shocked! There's a reason the answer is what it is...can you see it?)

If instead you were told, for example, that

$$f(x)=\left\{ \begin{array}{lr} A \cos \frac{\pi x}{L} & 0 < x < L \\ 0 & x<0 \;\text{or} \; x >L \end{array} \right.$$

with $f(0)=\frac{A}{2}$ and $f(L)=-\frac{A}{2}$ and asked to find the Fourier series over the interval $(-\infty, \infty)$ (which is a very typical problem on Fourier series), you would have found a very different result (the sine terms wouldn't be zero ... do you see why?)

Last edited: Aug 18, 2012
20. Aug 18, 2012

### ProPatto16

$$a_0 = 0$$

$$a_n = A$$

$$b_n = 0$$

So the whole Fourier series is:

f(x) = Sum (Acos(pi*x/L))
??
The same as the original formula? Is that the trick?

And so the series only iterates once since n = 1 then after that is zero?

Dunno if the latex will work I'm on my iPhone