# Representing a real periodic valued function with Fourier series

1. Mar 13, 2014

### Jdraper

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

Hey, the question i have been given reads:

By a simple change of variables, show that if g(x) is a periodic real valued function with
period L it can be represented as

g(x)~ ∑n=-∞ An exp(-2$\pi$inx/L)

where the complex constants An are given by

LAm =[L/2,-L/2] ∫ g(x)exp(-2$\pi$imx/L) dx

2. Relevant equations

N/A

3. The attempt at a solution

I used the fact that the generic Fourier series has the form ∑n=-∞ An exp(-2$\pi$inx/L) and then used the fact that L is the period to rewrite g(x) in the required form.

Then i used

Lbm=[L,-L] ∫ g(x)sin(m$\pi$x/L)dx and

Lam=[L,-L] ∫ g(x)cos(m$\pi$x/L)dx

I added these two to give me

L(bm+am)=[L,-L] ∫ g(x)(sin(m$\pi$x/L)+cos(m$\pi$x/L))dx

Then i used 0.5(am +bm)=Am to give me

2LAm=[L,-L] ∫ g(x)(sin(m$\pi$x/L)+cos(m$\pi$x/L))dx

Any help or indication of where i'm going wrong/ right would be a lot of help. Thanks in advance, John :). Also, if you don't understand any of my notation let me know and i'll try and explain it.
1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution

2. Mar 13, 2014

### jbunniii

I think one of the exponentials should not have the negative sign in the argument. Is there a typo?

This is true but not quite what you need. The goal is to use the fact that $\cos(x) + i\sin(x) = e^{ix}$, so try introducing a factor of $i$ in the appropriate place before adding.

3. Mar 13, 2014

### Jdraper

Yes, it's a typo. The exponential in the g(x) term is meant to be positive. Thanks.

Ahh thanks Am = (am +ibm) not (am+bm)

So now i use the relations

Libm=[L,-L] ∫ g(x)isin(mπx/L)dx and

Lam= [L,-L] ∫g(x)cos(mπx/L)dx

To give me

L(am+ibm)=[L,-L] ∫g(x)*e^(im$\pi$x/L) dx

and then as Am = (am +ibm)

this becomes

L( Am)=[L,-L] ∫g(x)*e^(im$\pi$x/L) dx

My initial thoughts were initially to use symmetry to change the limits to get the missing factors but i don't think that would get me the missing -2 factor in the exponential. Any ideas?

4. Mar 13, 2014

### jbunniii

Hmm, shouldn't there be factors of 2 in the arguments to the cosine and sine? Like this:

5. Mar 13, 2014

### Jdraper

Reading through my course notes they are written here as they are printed. However what your suggesting does make sense, I might be using the wrong equations for this scenario but i'm unsure. I can't see your suggestions in my notes.

6. Mar 13, 2014

### jbunniii

Oh, I see: you are taking your integrals from $-L$ to $L$, an interval of length $2L$. So the cosine and sine will have the arguments $(2\pi m x) / (2L)$ which reduces to $\pi m x / L$. So your formulas are correct, assuming the function has period $2L$. But if the period is $L$ then you should only be integrating from $-L/2$ to $L/2$ (or $0$ to $L$). In that case, the arguments will be $2 \pi m x / L$.

7. Mar 13, 2014

### Jdraper

The period of the function is L which means this all works out nicely. Thanks, i'll try and read the question properly next time. Much a appreciated :)

8. Mar 18, 2014

### Jdraper

Hi again, when reviewing my workings I noticed an error. The answer you helped me work out is:

L-L f(x)eim$\pi*x/L$

However the answer requested in the question is:

L-L f(x)e-im$\pi*x/L$

I've looked through my workings multiple times and have failed to spot my error, my only thoughts are setting m=-n or something along those lines.

Thanks again, John

9. Mar 18, 2014

### jbunniii

It depends on how you define the Fourier series. If the series has a negative exponent, then the formula for the coefficients should have a positive exponent, and vice versa.

In your original problem statement, you defined the Fourier series with a negative exponent:
$$f(x) = \sum_{n=-\infty}^{\infty}A_n \exp(-2\pi i n x / L)$$
So the coefficient formula should have a positive exponent:
$$A_n = \frac{1}{L} \int_{-L/2}^{L/2} f(x) \exp(2\pi i n x / L) dx$$
If you change the signs of both exponents, it will still be correct.

10. Mar 19, 2014

### Jdraper

Hello again, thanks for you help. I discovered the error was due to the fact that i assumed n<0 which meant Am=0.5(an+ibn) as opposed the condition where n>0 which gives Am=0.5(an-ibn).

However when working through this again i got the final answer:

2LAm=[L/2,-L/2] ∫g(x)e(-2$\pi*mx/L)$ dx

As opposed to

LAm=[L/2,-L/2] ∫g(x)e(-2$\pi*mx/L)$ dx

The factor of two was from the 2Am=0(an-ibn), when working through this previously i simply forgot the two, you can see this mistake if you look at my earlier posts.

I ran through my workings and found no way to cancel this two out, do you have any suggestions/ ideas?

This question will end eventually! Haha!

11. Mar 19, 2014

### jbunniii

I scrolled up but I couldn't see exactly where you obtained $2A_m = 0(a_n - i b_n)$. (Is there a typo? Doesn't this mean $A_m = 0$ for all $m$?) Can you show how you got this equation?

12. Mar 19, 2014

### Jdraper

Yet another typo, it should read. Am=0.5(am+ibm)

I stated it correctly, initially but then in the 8th line of my second post i write:

"and then as Am = (am +ibm)" which is incorrect according to my notes. using this however would give me the correct answer.

13. Mar 19, 2014

### jbunniii

Can we review how you are defining $a_n$ and $b_n$? Are these the definitions you are using:
$$a_n = \frac{1}{L}\int_{-L/2}^{L/2} g(x) \cos(2\pi n x / L) dx$$
$$b_n = \frac{1}{L}\int_{-L/2}^{L/2} g(x) \sin(2\pi n x / L) dx$$
If so, then
\begin{align} a_n + i b_n &= \frac{1}{L} \int_{-L/2}^{L/2} g(x) (\cos(2\pi n x / L) + i \sin(2\pi n x / L)) dx \\ &= \frac{1}{L} \int_{-L/2}^{L/2} g(x) \exp(2\pi i n x / L) dx \\ \end{align}
which is indeed the Fourier coefficient $A_n$ assuming the Fourier series is defined as
$$g(x) = \sum_{n=-\infty}^{\infty} A_n \exp(-2\pi i n x / L)$$
If your definitions for $a_n$ and $b_n$ are not as above, then that will change things. Indeed, I believe the formulas for $a_n$ and $b_n$ should be multiplied by 2 if they represent the coefficients of the Fourier series when written as follows:
$$g(x) = \frac{a_0}{2} + \sum_{n=1}^{\infty} [a_n \cos(2\pi n x / L) + b_n \sin(2\pi n x / L)]$$
Can you please clarify whether that is the case?

14. Mar 19, 2014

### Jdraper

The definitions i am using for an and bn are:

an = $\frac{1}{L}$ ∫$^{L}$$_{-L}$ f(x) cos($\frac{npix}{L}$) dx

and

bn = $\frac{1}{L}$ ∫$^{L}$$_{-L}$ f(x) sin($\frac{npix}{L}$) dx

Since I am integrating over the period L, meaning my limits are L/2 to -L/2 rather than L to -L does this mean i get a factor of 2 which means the 2's cancel?

I am also using An=0.5(an-ibn), where An is indeed the Fourier coefficient.

John

15. Mar 19, 2014

### jbunniii

It looks like those formulas are correct if the period is $2L$. I can rewrite them as follows to make it more obvious:
$$a_n = \frac{2}{2L} \int_{-L}^{L} f(x) \cos\left(\frac{2\pi n x}{2L}\right) dx$$
$$b_n = \frac{2}{2L} \int_{-L}^{L} f(x) \sin\left(\frac{2\pi n x}{2L}\right) dx$$

If the period of your function is $L$ then you should replace $2L$ by $L$, and $L$ by $L/2$, to get
$$a_n = \frac{2}{L} \int_{-L/2}^{L/2} f(x) \cos\left(\frac{2\pi n x}{L}\right) dx$$
$$b_n = \frac{2}{L} \int_{-L/2}^{L/2} f(x) \sin\left(\frac{2\pi n x}{L}\right) dx$$
Using these definitions we can see that you need to define $A_n = (a_n + i b_n) / 2$ to compensate for the $2/L$.

16. Mar 19, 2014

### Jdraper

Yup that works perfectly. 2's cancel because it's a period of L, not 2L those were just the definitions given to me in my notes.

Can't thank you enough for your help, cheers :)

17. Mar 19, 2014

### jbunniii

I would suggest scratching out the formulas in your notes and replacing them with the ones for period $L$, otherwise they will probably continue to confuse you in the future. Glad you got it sorted out. Working with Fourier series, one constantly runs up against annoyances with sign errors, factors of $2$ or $2\pi$, etc., because not everyone uses the same definitions. Just a fact of life.