# Fourier Series.

## Homework Statement

Hi I'm stuck with the following problem:

Find the fourier series of:

f(t) = { -sint for -pi < t < 0 and sint for 0 < t < pi }

## The Attempt at a Solution

since they are both even functions I expanded both using the cosine series and I get two integrals which are the same if i swap the limits of integration around. So I add them together and I get:

1/pi [ ʃ sin(t)cos(nx)] in the limits of -pi to pi

Im trying to use a trig identity so that i can then integrate it but this is where I'm a bit lost.

Any help will be greatly appreciated.

## Answers and Replies

Dick
Science Advisor
Homework Helper
That is not the integral you want to do. It's going to be zero for any choice of n. Do you see why? What you want to do is integrate -sin(x)cos(nx) from -pi to 0 and sin(x)cos(nx) from 0 to pi and add them. The first integral is the same as the second, so just do the second one and double it. To actually do the integral there is a trig identity that expresses sin(a)cos(b) in terms sin(a+b) and sin(a-b). Can you find it?

That is not the integral you want to do. It's going to be zero for any choice of n. Do you see why? What you want to do is integrate -sin(x)cos(nx) from -pi to 0 and sin(x)cos(nx) from 0 to pi and add them. The first integral is the same as the second, so just do the second one and double it. To actually do the integral there is a trig identity that expresses sin(a)cos(b) in terms sin(a+b) and sin(a-b). Can you find it?

Yes that integral contains an odd function so through those limits it will go to 0 I'm guessing?

Yes thats whats I thought, although by multiplying one of them by 2 would i need to change the limits of integration or simply just multiply what I get by integrating one of the terms by 2?

Im guessing the integral would then be:

1/2 sin (u + v) + 1/2 sin(u - v) with limits 0 to pi ?

Dick
Science Advisor
Homework Helper
Just realize the integral from -pi to 0 is the same as the integral from 0 to pi and double one. Don't change the limits of integration. And, yes, you have the correct trig identity.

Just realize the integral from -pi to 0 is the same as the integral from 0 to pi and double one. Don't change the limits of integration. And, yes, you have the correct trig identity.

Ok, Im sorry im finding this quite hard, i got the following integral then:

1/(pi).1/2 [∫sin(t + nt) + sin(t - nt) dt

I then get:

1/n(pi)[ -cos(t + nt) + cos(t -nt) through the limits pi and 0 right?

How do i make this equal to 1/2 when n is even? where am I going wrong?

Cyosis
Homework Helper
Something went wrong with the integration.

\begin{align*} a_n & = \frac{1}{\pi}\int_{-\pi}^\pi f(t) \cos(nt)dt \\ & = \frac{1}{\pi} \left(\int_{-\pi}^0 -\sin(t) \cos(nt)dt +\int_0^\pi \sin(t) \cos(nt)dt\right) \\ & = \frac{2}{\pi} \int_0^\pi \sin(t) \cos(nt)dt \\ & = \frac{1}{\pi} \int_0^\pi (\sin(t+nt) +\sin(t-nt))dt \\ & = \frac{1}{\pi} \left[- \frac{1}{1+n} \cos(t+nt)-\frac{1}{1-n} \cos(t-nt)\right]_0^\pi \end{align*}

Last edited:
Something went wrong with the integration.

\begin{align*} a_n & = \frac{1}{\pi}\int_{-\pi}^\pi f(t) \cos(nt)dt \\ & = \frac{1}{\pi} \left(\int_{-\pi}^0 -\sin(t) \cos(nt)dt +\int_0^\pi \sin(t) \cos(nt)dt\right) \\ & = \frac{2}{\pi} \int_0^\pi \sin(t) \cos(nt)dt \\ & = \frac{1}{\pi} \int_0^\pi (\sin(t+nt) +\sin(t-nt))dt \\ & = \frac{1}{\pi} \left[- \frac{1}{1+n} \cos(t+nt)-\frac{1}{1-n} \cos(t-nt)\right]_0^\pi \end{align*}

Thanks very much. How would I be able to deduce that when n = even , it equals to 1/2?

Cyosis
Homework Helper
Try to take it from this calculation on. If you get stuck we'll help you get unstuck.

Ok yes. so If i put the limits in I get:

1/pi [1/(1 + n) + 1/(1 - n)] - 1/pi [ -1/(1 + n) - 1/(1 - n) ]

I have tried subtituting this into the cosine series formula and then for n =even...

f(x) = 2/pi sigma[ cos(nt)/-n ]

But How can I get 1/2 I really need to solve this question. Thanks for the help.

Cyosis
Homework Helper
Ok yes. so If i put the limits in I get:

1/pi [1/(1 + n) + 1/(1 - n)] - 1/pi [ -1/(1 + n) - 1/(1 - n) ]

This isn't right, you ignored all cosines for some reason. For example $\cos((1+n)\pi) \neq 1 \;\;\; \forall n \in \mathbb{Z}$.

Try to rush less and put the limits in again so you get the correct expression.

Edit:I'll give you how the integral looks after simplification so that you can check if you've done it correctly,$$\frac{2(1+(-1)^n)}{\pi(1-n^2)}$$.

Last edited:
This isn't right, you ignored all cosines for some reason. For example $\cos((1+n)\pi) \neq 1 \;\;\; \forall n \in \mathbb{Z}$.

Try to rush less and put the limits in again so you get the correct expression.

Edit:I'll give you how the integral looks after simplification so that you can check if you've done it correctly,$$\frac{2(1+(-1)^n)}{\pi(1-n^2)}$$.

Ok I'll show you my working out:

When inputting the limits I get:

1/pi [-1/(1+n) cos(pi + npi) - 1/(1 - n) cos(pi - npi)] - 1/pi [ -1/(1 + n)cos(0) - 1/(1 -n) cos(0)]

=

This simplies to:

2/ (1 + n)pi + 2/ (1 - n)pi

hence:

2(1 - n) / (1 - n²) + 2(1 + n)/ (1 - n²)pi

How do I get what you've just posted? and how does the sum of all n=even give me 1/2.
I just can't see it.

Cyosis
Homework Helper
You have inserted the limits correctly, however what happens to $\cos(\pi + n \pi)?$ after that?

2/ (1 + n)pi + 2/ (1 - n)pi

I really can't see what you did there. It seems that you claim $\cos(\pi + n \pi)=1\;\;\forall n \in \mathbb{Z}$. I have already told you that this is not true.

Please list all of your steps.

How do I get what you've just posted? and how does the sum of all n=even give me 1/2.
I just can't see it.

What sum are you talking about, because the Fourier series itself won't go to 1/2?

Last edited:
You have inserted the limits correctly, however what happens to $\cos(\pi + n \pi)?$ after that?

I really can't see what you did there. It seems that you claim $\cos(\pi + n \pi)=1\;\;\forall n \in \mathbb{Z}$. I have already told you that this is not true.

Please list all of your steps.

What sum are you talking about, because the Fourier series itself won't go to 1/2?

I thought when n= even cos(pi + npi) = 1 to be honest but you just said it wasn't the case.

I can't see how I can narrow down the equation to show that : sigma 1/(n² -1) =1/2 when n =even

Cyosis
Homework Helper
Ah you already assumed n is even. You should not do that in general, luckily in this case when n is odd the expression reduces to zero so there won't be a difference. Still it's a very bad method unless you consciously make the decision that since n is odd the expression goes to zero so I may as well start with n is even right away.

The point however is that for n an integer $\cos(\pi+n\pi)=(-1)^{n+1}$. Yes when n is even the expression reduces to $\frac{4}{\pi(1-n^2)}$. The big question is why are you interested in that sum you just listed? It has nothing to do with the exercise you wrote down in your first post. Perhaps tell us exactly what the question is, because it seems very different from what you asked in post 1.

Edit: After some thinking I guess you are asked to calculate that sum with the help of the Fourier series of |sin(t)|? If so could you please stop jumping to this magical 1/2 question and continue to finish the Fourier series step by step. Once this is done you will understand how you can calculate the sum.

Last edited:
Ah you already assumed n is even. You should not do that in general, luckily in this case when n is odd the expression reduces to zero so there won't be a difference. Still it's a very bad method unless you consciously make the decision that since n is odd the expression goes to zero so I may as well start with n is even right away.

The point however is that for n an integer $\cos(\pi+n\pi)=(-1)^{n+1}$. Yes when n is even the expression reduces to $\frac{4}{\pi(1-n^2)}$. The big question is why are you interested in that sum you just listed? It has nothing to do with the exercise you wrote down in your first post. Perhaps tell us exactly what the question is, because it seems very different from what you asked in post 1.

Edit: After some thinking I guess you are asked to calculate that sum with the help of the Fourier series of |sin(t)|? If so could you please stop jumping to this magical 1/2 question and continue to finish the Fourier series step by step. Once this is done you will understand how you can calculate the sum.

Sorry for the delayed reply I've been busy with exams this week...

The question asked me to find out the sum of the terms when n = even thats why I didnt use (-1)^n+1

Ok, I put 4/(pi)(1 - n²) into the cosine series formula and I get:

Sigma 4/(pi)(1 - n²) cos (nt)dt = [-1/3 cos (2t) - 1/15 cos(4t) .....] = 1/(1 -n²)

I dont understand how I can get 1/2 from this though? what am I missing out from here?

Cyosis
Homework Helper
Okay. The 1/2 value will flow naturally out the Fourier series. However the Fourier series itself does not converge to 1/2, it should of course converge to the original function.

What we have so far is $a_0=\frac{2}{\pi}$ and $a_n=\frac{4}{\pi(1-n^2)}$.

Therefore the Fourier series is:
$$f(t)=\frac{2}{\pi}+\sum_{n=even} \frac{4 \cos n t}{\pi(1-n^2)}$$

Now you have an equation you can solve for the sum. Can you see how to find the value of the sum you're interested in now?

Okay. The 1/2 value will flow naturally out the Fourier series. However the Fourier series itself does not converge to 1/2, it should of course converge to the original function.

What we have so far is $a_0=\frac{2}{\pi}$ and $a_n=\frac{4}{\pi(1-n^2)}$.

Therefore the Fourier series is:
$$f(t)=\frac{2}{\pi}+\sum_{n=even} \frac{4 \cos n t}{\pi(1-n^2)}$$

Now you have an equation you can solve for the sum. Can you see how to find the value of the sum you're interested in now?

Well doesnt this mean:

$$Modulus Sine =\frac{2}{\pi}+\sum_{n=even} \frac{4 \cos n t}{\pi(1-n^2)}$$

I know this may sound stupid but I dont really know how to go on from here..

Cyosis
Homework Helper
Yep that is correct. The only question that sounds stupid is the one you don't ask when you don't understand something.

What you want to do now is to compare the sum to the sum you're interested in. For example put the constants in front, turn some signs around, take a value for t etc. Play a bit with it and see if you can get it into the required form.

Last edited:
Yep that is correct. The only question that sounds stupid is the one you don't ask when you don't understand something.

What you want to do now is to compare the sum to the sum you're interested in. For example put the constants in front, turn some signs around, take a value for t etc. Play a bit with it and see if you can get it into the required form.

Aha! Well I put t=0 into the equation and after some rearranging I actually got:

1/2 = Sigma 1/(n² -1)

Which is what they were asking! Well I'm happy that I was able to solve it after a lengthy thread lol. Thanks very much for the help! Really appreciated!

One more question before this thread disappears lol, Im trying to see if I got it right:

If in the range -pi < x < pi , a function f(x) is defined by:

f(x) = x if 0 < x < pi AND -x otherwise

(a) Calculate the Fourier Series representation of f(x) :

Since it is an even function I expanded using the cosine series

And I got :

f(x)= x = pi/2 + Sum [((-1)^n) -1 / n²] (cosnx) *Not sure if i got the whole thing correctly*

But part (b) says:

By choosing an appropiate value of x deduce that :

pi² = 8(1 + 1/9 + 1/25 ...)

How do I go around with this part of the question? Do I replace x by pi² but If I do I still cant seem to rearrange it and get what is needed.

Thanks!

Cyosis
Homework Helper
You're welcome. This question is much like the first, however the reason you're probably stuck is that you made an error calculating a_n, a_0 is correct. Once you have calculated a_n correctly finding an expression for pi^2 will be much like finding the value 1/2 of the previous exercise.

$$a_n=\frac{2((-1)^n-1)}{\pi n^2}$$

Look how close you were. Try to find where you lost 2/pi in your calculations.

You're welcome. This question is much like the first, however the reason you're probably stuck is that you made an error calculating a_n, a_0 is correct. Once you have calculated a_n correctly finding an expression for pi^2 will be much like finding the value 1/2 of the previous exercise.

$$a_n=\frac{2((-1)^n-1)}{\pi n^2}$$

Look how close you were. Try to find where you lost 2/pi in your calculations.

Brilliant! manage to complete it. I have a general question though:

If for a range of -1 to 1 for the integral of cos using cosine series is it always zero? and how about if f(x) is sine will using the cosine series give me zero too? Is there any general argument that can be used to avoid lots of working out?

Thanks!

Cyosis
Homework Helper
If an odd function is integrated over a symmetrical interval and the integral converges then the integral is always zero. So let f(x) be an odd function then $\int_{-a}^a f(x) =0$. In your example f(x)=cos(x), cos(x) is even and cos(x)cos(nx) is even so $\int_{-a}^a \cos x \cos nx dx \neq 0$ in general. Of course if a=0 in this case the integral is zero, and if f(x)=0 which is even then the integral is zero as well. Now if we take a look at the sine series, we have cos(x)sin(n x), which is odd therefore $\int_{-a}^{a} \cos x \sin nx =0$. Of course the integrals needs to exist, for example 1/x is odd but $\int_{-1}^{1} \frac{1}{x}$ does not converge.

So to summarize:

If $f(x)$ is an odd function and $\int_{-a}^a f(x) dx$ exists, then $\int_{-a}^a f(x) dx=0$.

Last edited:
Okay. The 1/2 value will flow naturally out the Fourier series. However the Fourier series itself does not converge to 1/2, it should of course converge to the original function.

What we have so far is $a_0=\frac{2}{\pi}$ and $a_n=\frac{4}{\pi(1-n^2)}$.

Therefore the Fourier series is:
$$f(t)=\frac{2}{\pi}+\sum_{n=even} \frac{4 \cos n t}{\pi(1-n^2)}$$

Now you have an equation you can solve for the sum. Can you see how to find the value of the sum you're interested in now?

Brilliant! had the exam the other day and a similar question came up so thanks for the help again! I will be sticking around these forums for quite some while, I have a lot of improvement to make..lol