Fourier Series of Square Wave (Calculating Coefficients | Simulation)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi how are you it's been some time since I last uploaded a video so I guess we'll come back to you and to myself as well so just a couple of days back I was working on a problem of food a series for a square wave and I thought it's an interesting problem so let me make a video on it so this is what I'm going to do today in this video I'm going to talk about whatever Fourier series is I'm just going to briefly just explain what it is I'm going to obtain the Fourier coefficients for a square wave and then I'm going to generate a square wave using that particular series I'm going to show you a visualization in which I use different kinds of sine waves and then add them to create a sum which looks like or approximates to a square wave for that I have created a program in my laptop which I'm going to show you a visualization of at the end of the video so it's going to be quite interesting so stick with me so what is a Fourier series so to explain quite briefly Fourier series is a mathematical tool or a technique to generate any kind of a waveform a periodic waveform using a combinations of sines and cosines so for example let's suppose that you have some kind of a sine wave form like this alright so if you have some kind of a sine wave form like this and you add this to another wave form alright let's suppose another wave form which has a different amplitude and a different frequency alright so mathematically you can say that the first wave form is represented by some kind of function y1 which is equal to C 1 sine Omega 1t so C 1 basically gives you an idea about the amplitude of this function and Omega 1 gives you an idea what the frequency of this function similarly let's suppose the second wave has a mathematical function which is given by Y 2 is equal to C 2 sine Omega 2t now what is going to happen if you combine these two wave you are going to get a resultant sum right now what is this I'm going to look like it may look like some kind of a periodic waveform I'm just drawing a random figure here okay we're mathematically at any given point in time the amplitude is simply given by Y is equal to y1 plus y2 that's it if I add another waveform to this whole combination if I say that there is let's suppose another sine wave which has a different amplitude and a different frequency and that sine wave is represented by some y3 is equal to c3 sine Omega 3t in that case the final ultimate wave form whatever it is or whatever the nature of the wave form it is is going to be equal to y1 plus y2 plus y3 this way we can combine a large number of wave forms which are sinusoidal in nature and then end up creating some kind of a resultant wave form now where does furiousiy is coming to this picture Fourier series basically gives us a technique so that we can generate a desirable wave form something that we are interested in by a suitable combination of sines and cosines having suitable amplitudes and frequencies so for example if I am interested in let's suppose a square wave in this video I can theoretically generate a square wave of this form by sufficiently adding suitable sines and cosines of suitable frequencies and amplitudes so this is kind of a square wave which is very different from a sine wave but we can generate it by a sum of sine waves all right similarly if you are also interested in some other periodic function let's suppose if you are interested in a triangular wave form you can generate a triangular wave form also using a combination of sines and cosines if you are interested in let's suppose a sawtooth wave function you can generate a sawtooth wave function also using a combination of sines and cosines if you are interested in some other wave form let's suppose a kind of a full wave or a kind of a wave consisting of periodic spikes which look like exponential increases we can do that you can basically generate any kind of a desirable periodic waveform by a suitable combination of sines and cosines but what do I mean by a periodic waveform so a periodic waveform is a kind of a wave or a function which basically repeats itself after regular intervals of time so if I have a function f and at the funk volume of the function f at any given point in time if I added by the period capital P then I am going to get back F T so here T is known as the period of this waveform alright so for our case we are basically interested in what in this video I am simply interested in creating this kind of a square wave let's suppose or a pulse wave so I am interested in this so let's suppose this kind of a square wave has a some sort of a function which is mathematically defined I will define what that function is so let's suppose the square wave has a maximum value of +1 and a minimum value of minus 1 and I can say that over a period of some kind of a time period in that case this square wave can be mathematically represented as F T is equal to it can have only two values it can have a value of +1 or it can have a value of minus 1 if I say that the period of this wave is T is equal to 2 pi then it can have values of +1 from 0 to pi so for all values between 0 and T by 2 that is between 0 and pi it can have value the plus 1 and for all values between T and T by 2 it can have values of minus 1 so basically for values between PI and twice pi right so this is the mathematical function that I want to generate using a Fourier series now so let me show you what the Fourier series is quite it's a combination of sines and cosines all right the Furious series is mathematically represented quite simply in this particular manner so furious series so f the desired waveform is the sum of some kind of a DC component a knot and a summation from let's suppose small n going from 1 to capital n a n cos twice pi and small t upon capital T plus summation of small N 1 to capital M VM sine twice by small and small t upon capital T so here we have some kind of a offset or a DC component a knot these are the coefficients a and corresponding to the cosines and these are the coefficients B n corresponding to the sines coefficients for the signs all right this more line goes from 1 to capital n it can have values of 1 2 3 and so on and so forth however number of times terms that is required so let's suppose I simplify this it can be simplified to a naught plus I can say a 1 alright cause now what is T I'm saying I'm considering for my case T is twice pi so I can simplify my calculations if I use T is equal to twice PI so twice by twice PI gets cancelled so cos NT right so the if this is M I suppose then the summation from n is equal to 1 to capital n similarly summation from n is equal to 1 to capital n BM sine and T which will basically give us term score involved in this series so NR plus let's suppose a 1 cos T this is the 1 term a 2 cos twice T this is another term a 3 cos thrice T this is another term on and on and for the signs I have B 1 sine T plus B 2 sine twice T plus P 3 sine thrice T and on and on to end up giving us a final function capital F so this basically is the Fourier series which says that if I am interested in generating a function f then I can do that by a combination of or a sum of sines and cosines alright so what is the F that I'm interested in the f that I'm interested in is this particular function right this is the function that I want to generate using this kind of a particular Fourier series okay so FD can have values of plus 1 to minus 1 between these and this region respectively so how do I do that so if you look at the series then you will find that I can find out the coefficients so these are known as the coefficients okay so a naught a N and the N these are known as the Fourier coefficients and I can obtain the Fourier coefficients by doing some simple calculations so you can show easily that if you take an integration of the desired waveform F T between 0 and T with respect to DT and divided by capital T and this will give you the coefficient a not all right you can show it it requires an integration of F with respect to T over a period of 0 to P in that case you end up getting the coefficient N or similarly if you do an integration from 0 to T of a product of F T and cos twice PI and T upon capital T DT then this is this into twice upon T is going to give you the coefficients corresponding to a.m. and if you do an integration from 0 to T of a product of F T a sign twice pi n small t upon capital T DT this is going to multiply this by twice upon capital T this is going to give you the coefficients B M now this to show that these expressions are true it's not very difficult you just take the series and you do the integrations with the required integrations you end up getting these coefficients okay I'm not going to do that that's going to then increase the length of the video I'm just going to use the this to obtain the values for the square wave so for the case of square if as I just now told you our required function is this yes ft is plus 1 between 0 to P by 2 and it's minus 1 between T by 2 to capital T where T is the capital T is the period which is twice pi so I just need to obtain the coefficients now because once I obtain the coefficients I can easily solve the problem for the square wave all right so let's obtain the coefficients so let's first try to obtain a knot ok so a knot is what 1 upon T so what is T 1 upon 2 I spy so 0 to capital T so 0 to capital T is ft now how do you solve this integral you can simply separate the integral regions from 0 to T by 2 and T by 2 to T so I can say that 1 by twice PI from 0 to T by 2 ft right what is ft between 0 to D by 2 it is plus 1 right DT and then from 1 by twice PI from T by 2 to capital D what is the value of ft between T by 2 and capital T it is minus 1 right DT so this is simply nothing but 1 by twice pi this is nothing but T all right from 0 to capital T by 2 then minus 1 by twice pi this is nothing but T from T by 2 to capital T so this is going to give us 1 by twice pi this is going to give us capital T by 2 this is going to give us 1 by twice PI so capital t minus u by 2 also ends up giving you t by 2 so this is this gets cancelled right as you can see an ends up giving us 0 so the first coefficient a naught is equal to 0 right and similarly that we have obtained a naught we can also obtain the values of en and bien so let's obtain the value of a n so a n is equal to twice upon capital T integration from 0 to capital T ft cos twice by small and small T upon capital T DT right so what is TT is twice pi all right again I can cancel out twice pi and capital T here because they have the same values and I can write so 2 2 gets cancelled from 0 to I can say T by 2 T by 2 is nothing but pi and in this region F T has a value of plus 1 so this becomes cos and T DT right and minus 1 upon PI from PI by PI to twice PI so that means from T by 2 to capital T cos and T DT there's a minus sign it comes because FD has a value of minus 1 in this region so this is nothing but 1 by PI so what is integration of cost the integration of course is 1 upon n sine NT in the region from 0 to PI minus 1 upon PI into 1 upon n sine NT in the region from PI to twice pi so this basically gives us 1 upon n pi so sine n pi minus sine 0 right if I take 1 upon n pi common I can write this as minus sign twice n pi write minus minus plus sign and PI right so this is our expression now if you look at the behavior of the sine wave all right if you look at the behavior of the sine wave then you will see that the sine wave varies in this particular fashion where it has a value of 0 at 0 it has a value of 0 at PI and it has a value of 0 it has a value of 0 at PI and it has a value of 0 at twice pi right so that means sine 0 is of course 0 right now sine values of n R is equal to 1 to 3 like this right so the value sine n pi will also end up becoming zero so sine 1 pi is 0 sine 2 pi is 0 similarly sine 3 pi sine for pies are also 0 so sine n pi is 0 right similarly sign twice and pi is also 0 because sighs twice pi is 0 sine 4 pi is 0 sine 6 pi is 0 so this is also 0 as you can see from the behavior the sine function so this comes out to be 1 upon n pi x 0 so comes out to be 0 so a n is equal to 0 again we have obtained the value of the coefficient a n now next we want to find out the value of the coefficient BN right so what is V n as I just not only win an integration of F T sine twice and pi t upon capital T DT between 0 to capital T multiplied by 2 upon T again tears iSpy right from 0 to capital T ft sign off so 2 pi and capital T gets cancelled you're left with and T DT right again I can separate the integrals so 2 2 gets cancelled 1 upon PI so between 0 to T by 2 which is PI this comes out to be F T's plus 1 so I end up getting sine NT DT and then again - from PI to twice PI so T by 2 to capital T so this is f T has minus 1 value and then sine of NT DT right so this comes out to be basically equal to 1 upon n pi similarly here a minus cos and T between 0 to PI minus - plus you end up getting 1 by n pi cos and T it gives you from PI to twice pi so this basically gives you 1 by n pi if I take it as common then this is nothing but minus cos n pi minus - plus cos 0 plus cos twice n PI minus cos and PI write it this is the expression that we have now if you look at the cosine function if you look at the cosine function the cosine function is a sine function which is shifted by a phase of Pi by 2 so cosine function looks something like this all right so if you look at its values at 0 it has a value of plus 1 right at pi it has a van at PI it has a value of minus 1 right and at twice pi it has a value of plus 1 again it only has a value of 0 at PI by 2 so if you look here so sine cos 0 what is cos 0 cos 0 is nothing but plus 1 right cos 0 is plus 1 similarly if you look at cost twice n pi so n has a values of 1 2 3 like that right so course twice n PI means cos twice PI cos 4 pi cos 6 pi like that it has a value of +1 all right so this can be simplified as 1 by n pi so 1 plus 1/2 minus twice cos small n pi so this comes out to be 2 upon and pi 1 minus cos and pi right now here this can have different values with based on whether or not n is even or odd so n can have values of 1 2 3 4 5 like that so if in some cases there's a values of 1 3 5 and in some cases it has values of 2 4 6 like that so what is the value of the cosine function for odd integers of n so cos 1 pi is minus 1 right cos 3 pi is again minus 1 right so for odd values you end up getting cost cosine of minus 1 similarly what about cos twice PI you end up getting so for even values you end up getting values of plus 1 all right so this will basically lead to or even or n or even n right so for odd n like cos 1 by cos 3 PI cos 5 pi this will have a value of minus 1 & 4 even n like cos twice M PI cos 4x so it costs twice PI cos for Pike or six PI this will have a value of +1 right so if it is a value of plus 1 then this will come out to be 0 if it is a value of minus 1 then this will come out to be twice okay so this simplifies to the situation so depending upon even-odd you can have different values so for or n you end up getting 1 plus 1 4 upon and pi all right and for even n you end up getting 0 so as you can see here we found out the first Fourier coefficient a not so a naught came out to be 0 okay fine next we found out en a and also came out to be 0 very good but then we found out B and right now BN can have two values it can have a value of 0 for all the event of n terms and it can have a value of 4 upon n pi for all the an odd n terms right so if you now write the Fourier series because this was our original food is series right so if you write the Fourier series then automatically a knot came out to be 0 so this is the 0 term en came out to be 0 so this is also going not going to contribute only the BN has a 0 and nonzero term so it is 0 if n is even it is 4 upon n pi if n is odd okay so these are the terms which are going to contribute towards the Fourier series for the case of a square wave so if we finally write down the square wave then I can just plug in the values of the Fourier coefficients that I have obtained and just put it back in the series to see what the series actually look like and what are the terms that I need to add to care this square wave alright so this the first Fourier coefficient is 0 the second n is also 0 only the BN will have nonzero values for odd values of n so if I plug in the values this is simply going to be equal to so f is nothing but so or a VN is what be n is nothing but 4 upon and PI sine of twice by small an T upon capital T again capital T and twice PI gets cancelled summation from n is equal to 1 to capital n but these are the terms only for odd n so what do I finally get the Fourier series f is simply so ordinance for n is equal to 1 I will end up getting 4 upon 1 pi so for pies the first term sign off what sine of 1 T so sine of T basically this is the first term the second is for n is equal to 3 so I will get 4 upon 3 pi right and then sine of 3t right the second this is the second term and then the next term is going to be equal to 4 upon n is equal to 5 so 5 5 all right then I'll get sine of 5 T right then what is the next term the next term is simply plus 4 upon 7 pi and then sign upon 70 and on and on and on right so this corresponds to n is equal to 1 this corresponds to n is equal to 3 this corresponds to n is equal to 5 and this corresponds to n is equal to 7 and goes on and on up to infinity right so this is basically in the final series that I need to add to create the R is required square wave that I am interested in so this is a sine wave this is a scientist a scientist a sine having different amplitudes right and different frequencies and that I need to produce and then add to generate the necessary square wave so to do that what we can do is we can use some sort of a computational help alright so if you know any kind of a programming then you can use programming languages like C++ or Java or Fortran to visualize the sum of these functions or you can use some kind of computation software like mathematica matlab i have scilab in my laptop where I have created a program so let me show you what this basically looks like alright so what I have done is I have created these individual assign waves and I have added them to see how the final result looks like already so let's look at the program please don't get confused by the program it's not important what the program is if you are in if you are capable of doing this performing this some in some other software or a programming language you are welcome to try it so what I am trying to do is I have just created this sum for upon n pi you can see here right this is the the sum for upon n pi N and by adding it for increasing values of n is equal to 1 3 5 7 on and on and on right so if I add let's suppose I am only interested in adding the first term right if I'm interested in adding the first term then what's going to happen alright let's see what's going to happen so this is what it is this is what do you get the first term is this is the first term all right the first term is which one the first term is simply this one all right this is the the first term and the first term simply gives us a sine wave right and this is the resultant wave I'm not adding this with anything else this is the first sine wave and this is a resultant wave what if I add the first two terms for n is equal to 1 and 3 in that case I'll just increase the number of terms in my series sum so use it from 1 to 2 and then if I run it again I end up getting well here it is so this is the first sine term this is the second sine term and this is the sum all right so this is the first sine term is this one all right and this is the second sine term and this is basically gives you the sum here which looks something like this all right it looks a little bit different now what if I add another term if I add another term here if I had the first three terms then I end up getting just look at the change in the final sum all right the final some changes so here is the first sine wave the second one the third one and this is the sum similarly if I add three terms then I will end up getting so sorry if I had four terms then I end up getting something else again the sign again this whole thing changes so this is the first sine wave the second sine wave the third and the fourth and this is the complete sum so basically this is what I am doing here I have taken the series and I'm adding the first to the second and a second to the third and a third to the fourth and on and on and as you keep on adding terms as you see the Sun changes shape so now it looks somewhat I mean it's kind of oscillating in between in the plus 1 values for 0 to PI and it is kind of oscillating in-between the minus 1 values from PI to twice pi what if I add then increase the number of terms okay so I have again I have a program here where I've increased the number of terms to really high values so let me show you what you will actually get is that if you increase the number of terms so this is what you get so this is for n is equal to 1 only the first term is involved so you end up getting sinusoidal wave here you have added up to n is equal to 11 alright so n is equal to 1 3 5 7 up to n is equal to 11 you end up getting something like this so as you can see it's kind of approximating towards the square wave if you add keep on adding up to n is equal to 101 you end up getting this if you add even more terms up to N is equal to thousand won you end up getting this square wave so this is in this is quite interesting isn't it we started with the sum of lots of sines and cosines and then we end up getting this completely different looking function which is a square wave so this is it this is how you can use the Fourier series to basically generate any kind of a desirable periodic wave function in our case we have three this kind of square wave so that's it for today I hope you learned how to solve the problem for the Fourier series of a square wave and you have got a little bit of an idea what Fourier series means and the whole visualization helped you in getting a little bit of a better grasp of the subject so that's it for today thank you very much [Music]
Info
Channel: For the Love of Physics
Views: 5,152
Rating: 4.9354839 out of 5
Keywords: fourier analysis of square wave form, fourier series of square wave, fourier coefficients of square wave, fourier series of square waveform, square wave, fourier series calculation, fourier series animation, fourier analysis in urdu, fourier series, fourier analysis in electrical engineering, fourier coefficient calculation, fourier analysis of signals, fourier series examples and solutions, fourier series engineering mathematics, fourier transform
Id: trzF6chZd-g
Channel Id: undefined
Length: 29min 13sec (1753 seconds)
Published: Sat Feb 01 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.