Fourier Series help please

Thread Starter

Saviour Muscat

Joined Sep 19, 2014
187
I am encountering difficulty in question 3 to get the proper waveform especially the flat part between minus pi and minus pi on two and between pi on two and pi. Kindly can you point out mistakes which can I correct to get the correct waveform please refer to my attached calculations and waveform diagram.

Thanks
Saviour Muscat
 

Attachments

Thread Starter

Saviour Muscat

Joined Sep 19, 2014
187
Hello All
Sorry but no one attempt to guide me what did wrong in my question, If I did something wrong how I wrote thread don't mind I will improve it!
Thankyou to all for your attention
 

MrAl

Joined Jun 17, 2014
11,464
Hello there,

Your waveform looks like a full wave rectified cosine wave.

It looks like your integration range should be -pi to +pi.

Other than that, it is very hard or impossible to follow your work because the drawings are so faint they are too hard to read. Try posting some drawings that are more legible and i think you'll get more help.

It was very good that you tried to solve this yourself, as that is what is usually required, but if we cant read your drawings it's too hard to figure out what you did wrong if anything. I tried to enhance them but they still dont come out very good. Maybe try using bigger letters so they can be read more easily, and dark ink for writing everything.

Alternately you can just type it out like this:
integrate(f(x),x,0,pi)

which means integrate the function f(x) for x from zero to pi.
Integrate from -pi to pi like so:
integrate(f(x),x,-pi,pi)



Here are two 'enhanced' drawings but you can see they still dont come out too good.
 

Attachments

Last edited:

Thread Starter

Saviour Muscat

Joined Sep 19, 2014
187
Many thanks for your reply, now my working should be more clear now I think. Please see attached pdf to see my calculation.
Hope we understand each others.
Thanks very much.
Saviour Muscat
 

Attachments

MrAl

Joined Jun 17, 2014
11,464
Many thanks for your reply, now my working should be more clear now I think. Please see attached pdf to see my calculation.
Hope we understand each others.
Thanks very much.
Saviour Muscat
Hello again,

I have a feeling you may be looking at the wave you have to do incorrectly, but let's start with the DC component and go from there.

You have for a0:
a0=(1/pi)*integrate(cos(x),x,-pi/2,pi/2)

which means you are integrating a cosine wave between those two limits then multiplying by 1/pi.
Doing it that way means you are trying to calculate the DC component more directly then using the full integral formula, but that in itself should be ok.

What is not looking OK though is that you are not accounting for the time that the wave is zero. In your first post i noticed that your waveform drawn looks like a full wave rectified sine (somewhat) but the wave they are asking for seems to be a half wave rectified sine. This is because we have the following data:
cos(x) from =pi/2 to pi/2
0 from -pi to -pi/2
0 from pi/2 to pi

which means when we make this a periodic wave with period 2*pi, we get a half wave rectified wave not a full wave rectified wave. This results in a DC component of 1/pi not 2/pi. If it was a full wave rectified wave then it would be 2/pi but because for 50 percent of the time it is zero, it makes sense that the DC component is 1/2 of the full wave rectified wave, and that brings it to 1/pi.

So take another look at this and see if you can find out what you may have done wrong. The only thing wrong i think is you assumed it was a full wave rectified wave when it is really a half wave rectified wave. Once you do that i think you'll get the right results for everything.
 

Thread Starter

Saviour Muscat

Joined Sep 19, 2014
187
Many thanks for your reply
Yes, I need the wave to be half rectified, when I did the calculations attached in the pdf the result waveform was full wave rectified that was wrong.
Later on when I read your post you suggested that the DC component should be 1/pi not 2/pi. Then I plotted the waveform and the result was also not correct.(see attached).
Thankyou for your support
 

Attachments

MrAl

Joined Jun 17, 2014
11,464
Many thanks for your reply
Yes, I need the wave to be half rectified, when I did the calculations attached in the pdf the result waveform was full wave rectified that was wrong.
Later on when I read your post you suggested that the DC component should be 1/pi not 2/pi. Then I plotted the waveform and the result was also not correct.(see attached).
Thankyou for your support
Hi,

Well did you apply the now known correct waveform idea to the other harmonics too?
It's not just going to be the DC component that is different when we have half wave instead of full wave, it will also affect the other components too. That's why i thought you would just do them all over, not just the DC one.
Try doing them all over again.

If you do that and/or you have already done that, consider the fact that the first 4 harmonics may not be enough to show a very nearly equal half wave rectified wave. To find out if you did it right, calculate more harmonics and see if the wave gets better and better. If it does then you are doing it right, if not then you are still doing something wrong. I'll try it myself a little later today and we can compare notes.
 

Thread Starter

Saviour Muscat

Joined Sep 19, 2014
187
"It's not just going to be the DC component that is different when we have half wave instead of full wave, it will also affect the other components too. That's why i thought you would just do them all over, not just the DC one."

please suggest the new limits, then I will redo the new calculations.
 

Thread Starter

Saviour Muscat

Joined Sep 19, 2014
187
Thankyou for your support
I checked my working that look ok, and then I added 4 more harmonics, still the wave is incorrect( please see attached waveform3)
Many thanks
Saviour Muscat
 

Attachments

MrAl

Joined Jun 17, 2014
11,464
Hi,


Edit: looks like you are missing the fundamental?
Be sure to check for a term when n=1. YOU DONT HAVE THAT TERM.

I say this because when i plot your very waveform terms (previous post before your last one), i get something that looks much more like a half wave rectified cosine, it's just offset wrong. [note i was using my own generated terms that have the 1st harmonic included so you need that too]


Divide all your terms by 2, but keep the DC component equal to 1/pi.
Be sure to include the term with n=1.
Plot again.
 
Last edited:

RBR1317

Joined Nov 13, 2010
714
I was interested in how closely a half-rectified wave could be approximated by just the first harmonic, so I googled for "table of Fourier Series, half wave" and found the result you are looking for. Attached image is for a half-rectified sine wave, not the cosine wave of your homework problem.
Fourier-Half-Sine.png
 

MrAl

Joined Jun 17, 2014
11,464
Dear Mral
I did the calculation for n=1 but this term=0 please see attached pdf file

Hi,

You may have done something wrong in the integration step. Also, if you look at your solution in that last pdf you can see you have (1-1) in the denominator which is not allowed. To get the right result you have to take the limit as n goes to 1. That gives you the proper solution. That's only when you get the integration right though which i dont think you have right yet. If you take the limit and get anything other than 1/2 then something is still wrong with the integration step.

Here is what i got for the an:
((n-1)*sin((pi*n+pi)/2)+(n+1)*sin((pi*n-pi)/2))/(pi*n^2-pi)

and note that factors into something like you got but not exactly. More importantly though, when you take the limit as n goes to 1 you get:
a1=1/2

and so the term for the series is (1/2)*cos(x). That's the first harmonic.
Once you add the first harmonic like that you get the waveform shown in the attachment which is an approximation of a half wave rectified cosine wave. Using more terms like up to n=20 we get a really nice waveform that looks very much cleaner too. That is shown in the second attachment.

So maybe go over your integration and then take the limit as n goes to 1 to get the value for a1.

Also if you are interested, there is a simpler form for the 'an' because the result with the two sines simplifies into a simpler trig function.
 

Attachments

Last edited:

Thread Starter

Saviour Muscat

Joined Sep 19, 2014
187
Dear MrAL
Million thanks

"Here is what i got for the an:
((n-1)*sin((pi*n+pi)/2)+(n+1)*sin((pi*n-pi)/2))/(pi*n^2-pi)"
Can you be so kind to show the steps how you got the above expression please and the result A1=1/2cosx.

I plotted the your expression and seems very good see attached half wave.png and expression.png
Thankyou very much
SM
 

Attachments

MrAl

Joined Jun 17, 2014
11,464
Dear MrAL
Million thanks

"Here is what i got for the an:
((n-1)*sin((pi*n+pi)/2)+(n+1)*sin((pi*n-pi)/2))/(pi*n^2-pi)"
Can you be so kind to show the steps how you got the above expression please and the result A1=1/2cosx.

I plotted the your expression and seems very good see attached half wave.png and expression.png
Thankyou very much
SM

Hello again,

The Fourier 'an' is given as:
an=(1/pi)*integrate(f(x)*cos(n*x),x,a,b)

and for our problem we have f(x)=cos(x) and a=-pi/2 and b=pi/2, so let's first look at the integrand and simplify it a little.

We have this:
f(x)*cos(n*x)

and with f(x)=cos(x) this leads to:
cos(x)*cos(n*x)

and using trig identity:
cos(A)*cos(B)=cos(B+A)/2+cos(B-A)/2

and we set A=x and B=n*x and get:
cos(n*x+x)/2+cos(n*x-x)/2

and if we integrate this for x we get:
sin(n*x+x)/(2*(n+1))+sin(n*x-x)/(2*(n-1))

and then we just have to evaluate that from x=-pi/2 to x=pi/2, then multiply by 1/pi.

So the main idea is we just find an identity that makes the integrand simple, then integrate.
After we get the expression and simplify it we get:
-(2*cos((pi*n)/2))/(n^2-1)

and so we get 'an':
an=(-1/pi)*(2*cos((pi*n)/2))/(n^2-1)

Either way we then find values for 1 up to the highest harmonic we want to use. Some of them may turn out to be zero and some not.

It looks like you found the right answer now though :)
 
Last edited:

Thread Starter

Saviour Muscat

Joined Sep 19, 2014
187
Last thing, can you have look on my working for as n=1. Kindly confirm whether my working below is it correct or otherwise kindly show me the calculation please set by step.


"and if we integrate this for x we get:
sin(n*x+x)/(2*(n+1))+sin(n*x-x)/(2*(n-1))


and then we just have to evaluate that from x=-pi/2 to x=pi/2, then multiply by 1/pi."


upload_2017-9-4_14-43-21.png
thanks for your help
SM
 

MrAl

Joined Jun 17, 2014
11,464
Last thing, can you have look on my working for as n=1. Kindly confirm whether my working below is it correct or otherwise kindly show me the calculation please set by step.


"and if we integrate this for x we get:
sin(n*x+x)/(2*(n+1))+sin(n*x-x)/(2*(n-1))


and then we just have to evaluate that from x=-pi/2 to x=pi/2, then multiply by 1/pi."


View attachment 134285
thanks for your help
SM
Hi,

Well if you want to do this using ideas from the calculus then we would recognize the limit of our function as an indeterminate form 0/0 and so we would take the derivative of the numerator and denominator and then take the limit and that might give us the limit, and in this case it does. This procedure is known as L'Hospital's Rule.

If you want to try it numerically, then you should try different values for n such as
0.9, 0.99, 0.999

and that should give values that are progressively approaching a certain value such as 0.5 and may appear similar to:
0.49, 0.499, 0.4999

or similar, and then try values of:
1.1, 1.01, 1.001

and that should give values that approach the limit from the other side such as:
0.51, 0.501, 0.5001

or similar. This gives you some idea that the limit is 0.5 as the result is getting closer and closer to that value.

Once you try this value in your reconstruction you can tell if it works or not, and it's always a good idea to graph the reconstruction to be sure nothing went wrong because there are a lot of things that can go wrong in the calculation of the 'an' or the 'bn'.
 
Top