How Do You Calculate the Fourier Series for a Piecewise Function?

In summary, the homework statement is asking for the Fourier series of f(t), which is a function that is even and has two integrals. TheAttempt at a Solution found that 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?
  • #1
hhhmortal
176
0

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 piIm 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.
 
Physics news on Phys.org
  • #2
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?
 
  • #3
Dick said:
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 that's what's 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 ?
 
  • #4
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.
 
  • #5
Dick said:
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, I am sorry I am 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?
 
  • #6
Something went wrong with the integration.

[tex]
\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*}
[/tex]
 
Last edited:
  • #7
Cyosis said:
Something went wrong with the integration.

[tex]
\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*}
[/tex]

Thanks very much. How would I be able to deduce that when n = even , it equals to 1/2?
 
  • #8
Try to take it from this calculation on. If you get stuck we'll help you get unstuck.
 
  • #9
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.
 
  • #10
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 [itex]\cos((1+n)\pi) \neq 1 \;\;\; \forall n \in \mathbb{Z}[/itex].

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,[tex]\frac{2(1+(-1)^n)}{\pi(1-n^2)}[/tex].
 
Last edited:
  • #11
Cyosis said:
This isn't right, you ignored all cosines for some reason. For example [itex]\cos((1+n)\pi) \neq 1 \;\;\; \forall n \in \mathbb{Z}[/itex].

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,[tex]\frac{2(1+(-1)^n)}{\pi(1-n^2)}[/tex].

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.
 
  • #12
You have inserted the limits correctly, however what happens to [itex]\cos(\pi + n \pi)?[/itex] after that?

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

I really can't see what you did there. It seems that you claim [itex]\cos(\pi + n \pi)=1\;\;\forall n \in \mathbb{Z}[/itex]. 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:
  • #13
Cyosis said:
You have inserted the limits correctly, however what happens to [itex]\cos(\pi + n \pi)?[/itex] after that?



I really can't see what you did there. It seems that you claim [itex]\cos(\pi + n \pi)=1\;\;\forall n \in \mathbb{Z}[/itex]. 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
 
  • #14
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 [itex]\cos(\pi+n\pi)=(-1)^{n+1}[/itex]. Yes when n is even the expression reduces to [itex]\frac{4}{\pi(1-n^2)}[/itex]. 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:
  • #15
Cyosis said:
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 [itex]\cos(\pi+n\pi)=(-1)^{n+1}[/itex]. Yes when n is even the expression reduces to [itex]\frac{4}{\pi(1-n^2)}[/itex]. 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 that's 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 don't understand how I can get 1/2 from this though? what am I missing out from here?
 
  • #16
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 [itex]a_0=\frac{2}{\pi}[/itex] and [itex]a_n=\frac{4}{\pi(1-n^2)}[/itex].

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

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?
 
  • #17
Cyosis said:
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 [itex]a_0=\frac{2}{\pi}[/itex] and [itex]a_n=\frac{4}{\pi(1-n^2)}[/itex].

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

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 doesn't this mean:

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

I know this may sound stupid but I don't really know how to go on from here..
 
  • #18
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:
  • #19
Cyosis said:
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, I am 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 can't seem to rearrange it and get what is needed.


Thanks!
 
  • #20
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.

[tex]
a_n=\frac{2((-1)^n-1)}{\pi n^2}
[/tex]

Look how close you were. Try to find where you lost 2/pi in your calculations.
 
  • #21
Cyosis said:
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.

[tex]
a_n=\frac{2((-1)^n-1)}{\pi n^2}
[/tex]

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!
 
  • #22
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 [itex]\int_{-a}^a f(x) =0[/itex]. In your example f(x)=cos(x), cos(x) is even and cos(x)cos(nx) is even so [itex]\int_{-a}^a \cos x \cos nx dx \neq 0[/itex] 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 [itex]\int_{-a}^{a} \cos x \sin nx =0[/itex]. Of course the integrals needs to exist, for example 1/x is odd but [itex]\int_{-1}^{1} \frac{1}{x}[/itex] does not converge.

So to summarize:

If [itex]f(x)[/itex] is an odd function and [itex]\int_{-a}^a f(x) dx[/itex] exists, then [itex]\int_{-a}^a f(x) dx=0[/itex].
 
Last edited:
  • #23
Cyosis said:
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 [itex]a_0=\frac{2}{\pi}[/itex] and [itex]a_n=\frac{4}{\pi(1-n^2)}[/itex].

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

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
 

FAQ: How Do You Calculate the Fourier Series for a Piecewise Function?

What is a Fourier series?

A Fourier series is a mathematical representation of a periodic function as a sum of sine and cosine functions. It is a useful tool in analyzing and understanding the behavior of periodic signals and functions.

How is a Fourier series calculated?

A Fourier series is calculated using a process called Fourier analysis, which involves breaking down a periodic function into its individual sine and cosine components. This is typically done using integration and complex numbers.

What are some applications of Fourier series?

Fourier series have many applications in mathematics, physics, engineering, and other fields. Some examples include audio and image compression, signal processing, solving differential equations, and studying the behavior of physical systems.

What is the difference between a Fourier series and a Fourier transform?

A Fourier series is used to represent a periodic function, while a Fourier transform is used to represent a non-periodic function. Additionally, a Fourier series uses discrete frequencies, while a Fourier transform uses continuous frequencies.

Are there any limitations to using Fourier series?

While Fourier series are a powerful tool, they do have some limitations. They can only be used for functions that are periodic, and they may not accurately represent functions with discontinuities or sharp corners. In addition, they may not converge for all functions, so caution must be taken when applying them to real-world problems.

Similar threads

Back
Top