Main content

## Electrical engineering

### Course: Electrical engineering > Unit 6

Lesson 1: Fourier series- Fourier Series introduction
- Integral of sin(mt) and cos(mt)
- Integral of sine times cosine
- Integral of product of sines
- Integral of product of cosines
- First term in a Fourier series
- Fourier coefficients for cosine terms
- Fourier coefficients for sine terms
- Finding Fourier coefficients for square wave
- Visualizing the Fourier expansion of a square wave

© 2023 Khan AcademyTerms of usePrivacy PolicyCookie Notice

# Visualizing the Fourier expansion of a square wave

Visualize the Fourier expansion of a square wave. A square wave can be approximated by adding odd harmonics of a sine wave. Created by Sal Khan.

## Want to join the conversation?

- Sal, are you going to make videos about how to solve differential equations with help of Fourier transform?(40 votes)
- Gleb - The best place to make a request like this is in the KA help center. The link is down at the bottom of the page, under Support. There's a section called Community Discussion/Content Requests where you can put this suggestion. It will be reviewed by the Content team.(25 votes)

- can we see the general form for a function that doesn't have 2pi as its period?(25 votes)
- You could derive it for any interval, but you have to go back to the beginning and compute the definite integral of sin(mt) cos(nt) and their products, etc. just like Sal did in the first few videos, and then use those results.(9 votes)

- What is the Fourier Series used for?

Is it used to convert signals into data which can then be edited and transported digitally and then converted back to a signal at the destination?(8 votes)- Hello Alasdair,

The Fourier series is a description of a waveform such as a square or triangle wave. It helps us think about electric circuits.

The Fourier transform is a mathematical construct (algorithm ) that allows us to convert a signal such as a square or triangle waveform to constituent sinusoids.

The actual conversion (real circuits) use Analog to Digital Converters (ADC) and Digital to Analog Converters (DAC) to convert real world signal to digital and then back again.

Regards,

APD(18 votes)

- Do we have Fourier series for only 2π periodic functions?(6 votes)
- Not really. For any functions of the period T = 2π/ω, you can replace the cos(nt) and sin(nt) with cos(nωt) and sin(nωt). The limits of integration will range between -π/ω and π/ω. Now instead of 1/π in front of the integral at the final step, you will have ω/π. For the examples in the videos, T = 2π gives us ω = 2π/2π = 1, hence why at the final step we have 1/π.(7 votes)

- How come there are no more videos on solving problems(7 votes)
- Sal, can we have some videos on solving partial differentiation equation by fourier transform? That would be very helpful.(5 votes)
- So how is this all related to the fourier transform of integral of e^(-i*2*pi*t*v) * s(t), where s is some function?(3 votes)
- As you know from Eulers formula e^ix=i*sin(x)+cos(x). So in that exponent-thing you have and a sine wave and a cosine wave, separated by the imaginary unit i. By taking the integral of that, you can simultaneously compute and the amplitudes for the sine, and that for the cosine. As answer you will get a complex number where the real part in for the cosine and the imaginary part for the sine.(3 votes)

- At2:13Sal says, "You can type these things into Google..." and then he showed a bunch of graphs getting closer and closer to f(t). I tried typing the function (the first few terms anyway) into Google, and was just directed to a bunch of sites. Can you be more specific? I would love to try it!(1 vote)
- Type one of these lines into Google.

f(t) = 3/2 + 6/pi sin t

f(t) = 3/2 + 6/pi sin t + 6/3 pi sin 3t

f(t) = 3/2 + 6/pi sin t + 6/3 pi sin 3t + 6/5 pi sin 5t(4 votes)

- These were really tremendous sessions. Thanks for your valuable approach.. Could you please let us know that Is it the same fourier transform which is being used in the PID controllers for calculating errors and adding it up to the assigned values in order to have the desired process values...

Thanks!

Regards,

Muhammad Adil(2 votes)- Hello Muhammad,

In controls such as the PID application we often encounter a relative known as the Laplace transform. If you have a digital control system you will likely be using the Z-transform.

Regards,

APD(2 votes)

- Hallo,thanks for Fourier,I think its as powerfull as Eulers exponent function,integration of difficult integrals with algorithms of numerical analysis,are much,and probably codes of math might solve terarively,Runge Kutta,Newton Raphson or just Simpsons rule,this is so powerfull,let me try to change RC exponential into sines and cosines to trigonometrical function I never did, then I will jump into CRC theoretical reversed CAPS and Rload, to check if resonance is possible under controlled polarituy of bat or of CAPs 1 and 2.Is just a feeling,beyond the reason is mathematics, without mathematics and Physics no engineers, without FEA nothing at all.Regards JOhann Wegmann.(1 vote)

## Video transcript

- [Voiceover] So we started with a square wave that had a period of two pi, then we said, hmm, can we represent it as an infinite series of weighted sines and cosines, and then working from that idea, we were actually able to find expressions for the coefficients, for a sub zero and a sub n when n does not equal zero, and the b sub ns. And evaluating it for this particular square wave, we were able to get that a sub n is going to be equal, or a sub zero is going to be 3/2, that a sub n is going to be equal to zero for any n other than zero, and that b sub n is going to be equal to zero if n is even and six over n pi if n is odd. So one way to think about it, you're gonna get your a sub zero, you're not gonna have any of the cosine terms, and you're only going to have the odd sine terms. And if you think about it just visually, if you look at the square wave, it makes sense that you're gonna have the sines and not the cosines because a sine function is gonna look something like this. So a sine function is gonna look something like this, while a cosine function looks something like, let me make it a little bit neater, a cosine function would look something like that. And so a cosine and multiples of cosine of two x, cosine of three x, is gonna be out of phase, while the sine of x, or I should say cosine of ts and the sines of ts, sine two t, sine three t, is gonna be more in phase with the way this function just happened to be. So it made sense that our a sub ns were all zero for n not equaling zero. And so based on what we found for our a sub zero, and our a sub ns, and our b sub ns, we could expand out this actual, we did in the previous video, what is this Fourier series actually look like? So 3/2 plus six over pi sine of t plus six over three pi sine of three t plus six over five pi sine of five t, and so on and so forth. And so a lot of you might be curious what does this actually look like. And so I actually just, you can type these things into Google and it will just graph it for you. And so this right over here is just the first two terms. This is 3/2 plus six over pi sine of t. And notice it's starting to look right because our square wave looks something like, it goes, it looks something like this. So it's gonna go like that and then it's gonna go down to zero and then it's gonna go up, looks something like that. It doesn't have the pis and the two pis marked off between these because it's gonna look something like that. So even just the two terms, it's kind of a decent approximation for even two terms, but then as soon as you get to three terms, if you add the six over three pi sine of three t to the first two terms. So if you look at these first three terms, now it's looking a lot more like a square wave. And then if you add the next term, well, it looks like even more like a square wave, and then if you add to that what we already wrote down here, if you were to add to that six over seven pi times sine of seven t, it looks even more like a square wave. So this is pretty neat. You can visually see that we were actually able to do it. And it all kind of just fell out from the mathematics.