Fourier Series Coefficients of an Even Square Wave

In summary: I have to say that I find the statement that you have accepted that you know next to nothing about this problem a bit concerning. I do not know your background, but I would certainly hope that you have been exposed to Fourier series and how to compute them, especially in the simpler case of sine and cosine series. In any event, I do not mind helping you with this problem, but it might be more helpful to you in the long run if you could spend some time studying the background material first.
  • #1
Captain1024
45
2

Homework Statement


klFmtTH.png

Link: http://i.imgur.com/klFmtTH.png

Homework Equations


[itex]a_0=\frac{1}{T_0}\int ^{T_0}_{0}x(t)dt[/itex]
[itex]a_n=\frac{2}{T_0}\int ^{\frac{T_0}{2}}_{\frac{-T_0}{2}}x(t)cos(n\omega t)dt[/itex]
[itex]\omega =2\pi f=\frac{2\pi}{T_0}[/itex]

The Attempt at a Solution


Firstly, x(t) is an even function because x=1/2 when [itex]t=-t_0[/itex] and [itex]t=t_0[/itex]. Therefore, all bn coefficients of the Fourier series will be zero.

[itex]T_0=4, \omega =\frac{2\pi}{4}=\frac{\pi}{2}, t_0=1[/itex]

a0 is basicly the average value of x(t) over the period. By inspection a0 = 2/4 = 1/2

It makes sense to me to split up x(t) into regions:
x(t) = 0 when [itex]\frac{-T_0}{2}<t<-t_0, t_0<t<\frac{T_0}{2}[/itex]
x(t) = 1/2 when [itex]t=^+_-t_0[/itex]
x(t) = 1 when [itex]-t_0<t<t_0[/itex]

[itex]a_n=\frac{2}{T_0}[\frac{1}{2}\int ^{-t_0}_{-t_0}cos(n\omega t)dt+\int ^{t_0}_{-t_0}cos(n\omega t)dt+\frac{1}{2}\int ^{t_0}_{t_0}cos(n\omega t)][/itex]

[itex]=\frac{2}{n\omega T_0}(1+[sin(\frac{\pi}{2}nt)]^{t_0}_{-t_0})[/itex]

[itex]=\frac{2}{n\omega T_0}[1+(sin(\frac{\pi}{2}nt_0)-sin(\frac{-\pi}{2}nt_0)][/itex]

[itex]=\frac{2}{n\omega T_0}[1+2sin(\frac{\pi n}{2})][/itex]

[itex]a_0=\frac{1}{2}, a_1=\frac{3}{\pi}, a_2=\frac{1}{2\pi}, a_3=\frac{-1}{3\pi}, a_4=\frac{1}{4\pi}, a_5=\frac{3}{5\pi}, a_6=\frac{1}{6\pi}[/itex]

(1) asks for coefficients in exponential and trigonometric forms. Are the coefficients I calculated above correct for either of those forms? How do I get the coefficients in the other form?

(2) & (3) ask for a MatLab plots. We haven't gone over any MatLab in class. If someone could point me in the right direction I think I can figure it out. I've worked with MatLab in the past.

Thanks for your time.
-Captain1024
 
Physics news on Phys.org
  • #2
Captain1024 said:
(1) asks for coefficients in exponential and trigonometric forms. Are the coefficients I calculated above correct for either of those forms? How do I get the coefficients in the other form?

You should be able to answer the first question yourself, or are you really just blindly using formulas with no idea why? You really should know what "exponential form" and "trigonometric form" mean.
 
  • #3
vela said:
You should be able to answer the first question yourself, or are you really just blindly using formulas with no idea why? You really should know what "exponential form" and "trigonometric form" mean.
I probably knew the difference at some point in the past, but I could use a refresher.

I believe the answers i have calculated are in the trig form. To get the exponential form, I'm thinking I will need to use Euler's formula. Is this correct?
 
  • #4
Complex coefficients [itex]c_n[/itex] (exponential form?)

[itex]c_0[/itex] will remain the same value of 1/2

[itex]c_n=\frac{1}{T_0}\int ^{\frac{T_0}{2}}_{\frac{-T_0}{2}}x(t)\mathrm{exp}(-j\omega nt)dt[/itex]
[itex]=\frac{1}{T_0}(1+\int ^{t_0}_{-t_0}e^{-j\omega nt}dt)[/itex]
[itex]=\frac{1}{T_0}(1+[\frac{-1}{j\omega n}e^{-j\omega nt}]^{t_0}_{-t_0})[/itex]
[itex]=\frac{1}{T_0}(1+(\frac{-1}{j\omega n})[e^{-j\omega nt_0}-e^{j\omega nt_0}])[/itex]

When [itex]\omega=\frac{\pi}{2}, T_0=4, t_0=1[/itex];
[itex]c_1=\frac{\frac{\pi}{4}+1}{\pi}, c_2=\frac{1}{4}, c_3=\frac{\frac{3\pi}{4}-1}{3\pi}, c_4=\frac{1}{4}, c_5=\frac{\frac{5\pi}{4}+1}{5\pi}, c_6=\frac{1}{4}[/itex]

Am I on the right track here?
 
  • #5
Captain1024 said:
Complex coefficients [itex]c_n[/itex] (exponential form?)

[itex]c_0[/itex] will remain the same value of 1/2

[itex]c_n=\frac{1}{T_0}\int ^{\frac{T_0}{2}}_{\frac{-T_0}{2}}x(t)\mathrm{exp}(-j\omega nt)dt[/itex]
[itex]=\frac{1}{T_0}(1+\int ^{t_0}_{-t_0}e^{-j\omega nt}dt)[/itex]
[itex]=\frac{1}{T_0}(1+[\frac{-1}{j\omega n}e^{-j\omega nt}]^{t_0}_{-t_0})[/itex]
[itex]=\frac{1}{T_0}(1+(\frac{-1}{j\omega n})[e^{-j\omega nt_0}-e^{j\omega nt_0}])[/itex]

When [itex]\omega=\frac{\pi}{2}, T_0=4, t_0=1[/itex];
[itex]c_1=\frac{\frac{\pi}{4}+1}{\pi}, c_2=\frac{1}{4}, c_3=\frac{\frac{3\pi}{4}-1}{3\pi}, c_4=\frac{1}{4}, c_5=\frac{\frac{5\pi}{4}+1}{5\pi}, c_6=\frac{1}{4}[/itex]

Am I on the right track here?

No, your computed ##c_n## are incorrect; I don't know where on Earth you got the formulas you are using.

Besides, the Fourier series in exponential form is ##f(t) = \sum_{n=-\infty}^{\infty} c_n e^{j \omega n t}##, so you need to consider terms with ##n < 0## also.
 
Last edited:
  • #6
Fine. Based on the reply's to this thread thus far, I know next to nothing about how to solve this problem. I accept this.

So, if you are willing, I would like to solve this problem together step by step.

Based on what I read at this link: Any periodic function may be expressed as an infinite series of the form [itex]x(t)=\sum ^{\infty}_{m=0}a_mcos(\frac{2\pi mt}{T})+\sum ^{\infty}_{n=1}b_nsin(\frac{2\pi nt}{T})[/itex], where [itex]a_m[/itex] and [itex]b_n[/itex] are real constants. This series is called a Fourier series.

Now, after reading the same website, I believe I need to use the following equations in order to find the real coefficients up to the 7th harmonic:
[itex]a_0=\frac{1}{2}\int ^{T}_{0}x(t)dt[/itex]
[itex]a_m=\frac{2}{T}\int ^{T}_{0}x(t)cos(\frac{2\pi mt}{T})dt[/itex]
[itex]b_n=\frac{2}{T}\int ^{T}_{0}x(t)sin(\frac{2\pi nt}{T})dt[/itex]

Am I right so far?
 
  • #7
Captain1024 said:
Fine. Based on the reply's to this thread thus far, I know next to nothing about how to solve this problem. I accept this.

So, if you are willing, I would like to solve this problem together step by step.

Based on what I read at this link: Any periodic function may be expressed as an infinite series of the form [itex]x(t)=\sum ^{\infty}_{m=0}a_mcos(\frac{2\pi mt}{T})+\sum ^{\infty}_{n=1}b_nsin(\frac{2\pi nt}{T})[/itex], where [itex]a_m[/itex] and [itex]b_n[/itex] are real constants. This series is called a Fourier series.

Now, after reading the same website, I believe I need to use the following equations in order to find the real coefficients up to the 7th harmonic:
[itex]a_0=\frac{1}{2}\int ^{T}_{0}x(t)dt[/itex]
[itex]a_m=\frac{2}{T}\int ^{T}_{0}x(t)cos(\frac{2\pi mt}{T})dt[/itex]
[itex]b_n=\frac{2}{T}\int ^{T}_{0}x(t)sin(\frac{2\pi nt}{T})dt[/itex]

Am I right so far?

No, not really, unless you re-define your function as
$$ x(t) = \begin{cases}
1 & 0 < t < t_0\\
0 & t_0 < t < T-0-t_0\\
1 & T_0-t_0 < t < T_0
\end{cases}
$$
That would be your original function, but built on a base ##[0,T_0]##. It would be much easier to use the original definition of ##x(t)## based on ##[-T_0/2,T_0/2]## , but to use the Fourier series formulas that are appropriate to that case.

Note: you had done it correctly in your first post, when you computed the ##a_n## and ##b_n## for the Fourier series with sines and cosines. Where you went all wrong is where you tried to do the ##\exp(j n \omega t)## form, and your current posting still does not deal with that problem!
 
  • #8
Ray Vickson said:
That would be your original function, but built on a base ##[0,T_0]##. It would be much easier to use the original definition of ##x(t)## based on ##[-T_0/2,T_0/2]## , but to use the Fourier series formulas that are appropriate to that case.
I guess what I am getting at is, does there exist a set of equations that works for every periodic function to find the Fourier coefficients? Or, do you have to modify your approach every time?

Ray Vickson said:
Note: you had done it correctly in your first post, when you computed the ##a_n## and ##b_n## for the Fourier series with sines and cosines. Where you went all wrong is where you tried to do the ##\exp(j n \omega t)## form, and your current posting still does not deal with that problem!
I hadn't been receiving much positive feedback, so I just wanted to take a step back first.

So, just to clarify, is the ##a_0## I calculated the DC component or is it the coefficient of the 1st harmonic? Looking at it again, I think it's the DC component. If ##a_0## is the dc component, I think I need to keep calculating coefficients until n=7. In other words, do I need to calculate ##a_n## up to n=6 or n=7 to obtain the coefficient of the 7th harmonic?

For determining the complex coefficients, is the following formula correct: ##c_n=\frac{1}{T_0}\int ^{\frac{T_0}{2}}_{\frac{-T_0}{2}}x(t)\mathrm{exp}(-j\omega nt)dt##
If so, do I need to find ##c_n## when n=1, -1, 3, -3, 5, -5, & 7 (assuming the even subscripts yield 0's) in order to find the coefficients up to the 7th harmonic?

Thank you for your time. I know it probably isn't easy being a helper on this forum.
 
  • #9
Captain1024 said:
I guess what I am getting at is, does there exist a set of equations that works for every periodic function to find the Fourier coefficients? Or, do you have to modify your approach every time?I hadn't been receiving much positive feedback, so I just wanted to take a step back first.

So, just to clarify, is the ##a_0## I calculated the DC component or is it the coefficient of the 1st harmonic? Looking at it again, I think it's the DC component. If ##a_0## is the dc component, I think I need to keep calculating coefficients until n=7. In other words, do I need to calculate ##a_n## up to n=6 or n=7 to obtain the coefficient of the 7th harmonic?

For determining the complex coefficients, is the following formula correct: ##c_n=\frac{1}{T_0}\int ^{\frac{T_0}{2}}_{\frac{-T_0}{2}}x(t)\mathrm{exp}(-j\omega nt)dt##
If so, do I need to find ##c_n## when n=1, -1, 3, -3, 5, -5, & 7 (assuming the even subscripts yield 0's) in order to find the coefficients up to the 7th harmonic?

Thank you for your time. I know it probably isn't easy being a helper on this forum.

Basically, you need to start with some standard formula for Fourier coefficients, either based on ##[-\pi, \pi]## or ##[0, 2 \pi]##, then do a change-of-variable to translate those into formulas for ##[A,B]##. So, if we start with
$$f(t) = \frac{1}{2} a_0 + \sum_{n=1}^{\infty} [ a_n \cos(n t) + b_n \sin(n t)],\\
a_n = \frac{1}{\pi} \int_0^{2 \pi} \cos(n t) f(t) \, dt, \; b_n = \frac{1}{\pi} \int_0^{2 \pi} \sin(n t) f(t) \, dt,
$$
based on ##[0, 2 \pi]##, we are looking at trigonometric functions whose arguments go from ##0## to ##2 \pi n## for integer ##n##. On ##[A,B]## we want the arguments of our trigonometric functions to go from ##0## when ##t = A## to ##2 \pi n## when ##t = B##, so the argument is of the form ##2\pi n (t-A)/(B-A)## in the series and in the integrals that give the coefficients. This is just a straight change-of-variable problem.

I recommend that you do it once and file the results for future reference.

I now take back my statement that you calculated the trigonometric form coefficients correctly; looking at what you did, you made some puzzling blunders. I suggest you start again, carefully. Hint: you should get ##a_0 = 1## (so that the series starts off as ##(1/2)1 + \cdots = 1/2 + \cdots##), ##a_1 = 2/\pi##, ##a_2 = 0##, ##a_3 = -2/(3 \pi)##, etc.

Below, I show a plot of my series (up to n = 6) and of yours (up to n=6); mine is in blue and yours is in red. As you can see, the blue graph looks much closer to the function than does the red graph.

upload_2016-10-27_7-31-49.png
 
Last edited:
  • #10
I'm finally making some progress on this:

Trig form:
##x(t)=a_0+\sum ^{\infty} _{n=1}a_ncos(2\pi ftn)+\sum ^{\infty}_{n=1}b_nsin(2\pi ftn)##, where n is the harmonic number.
Where ##a_0=\frac{1}{T}\int ^{\frac{t}{2}}_{\frac{-T}{2}}x(t)dt##. Simplifying, ##a_0=\frac{1}{T}\int ^{\frac{T}{4}}_{\frac{-T}{4}}x(t)dt=\frac{1}{4}[t]^1_{-1}=\frac{1}{4}*2,\ \therefore a_0=\frac{1}{2}##.

Where ##a_n=\frac{2}{T}\int ^{\frac{T}{2}}_{\frac{-T}{2}}cos(\frac{2\pi tn}{T})dt=\frac{2}{T}\int ^{\frac{T}{4}}_{\frac{-T}{4}}cos(\frac{2\pi tn}{T})dt=\frac{2}{T}[\frac{T}{2\pi n}sin(\frac{2\pi tn}{T})]^{\frac{T}{4}}_{\frac{-T}{4}}##
##=\frac{1}{\pi n}[sin(\frac{2\pi n\frac{T}{4}}{T})-sin(\frac{2\pi n\frac{-T}{4}}{T})]=\frac{1}{\pi n}[sin(\frac{\pi n}{2})-sin(\frac{-\pi n}{2})]=\frac{2}{\pi n}sin(\frac{\pi n}{2})##.

Then, ##a_1=\frac{2}{\pi}, a_2=0, a_3=\frac{-2}{3\pi}, a_4=0, a_5=\frac{2}{5\pi}, a_6=0, a_7=\frac{-2}{7\pi}##.

Graph:
sTPtTlP.png

Link: http://i.imgur.com/sTPtTlP.png

Exp form:
##x(t)=\sum ^{\infty}_{n=-\infty}c_nexp(j\omega _0tn)##

Where, ##c_0=\frac{1}{T}\int ^{\frac{t}{2}}_{\frac{-T}{2}}x(t)dt=a_0\ \therefore \ c_0=\frac{1}{2}##

##\mathrm{Where,}\ c_n=\frac{1}{T}\int ^{\frac{T}{2}}_{\frac{-T}{2}}x(t)exp(-j\omega _0tn)=\frac{1}{T}\int ^{\frac{T}{4}}_{\frac{-T}{4}}x(t)exp(-j\omega _0tn)=\frac{1}{T}[\frac{-1}{j\omega _0n}exp(-j\omega _0tn)]^{\frac{T}{4}}_{\frac{-T}{4}}=\frac{-1}{j\omega _0nT}[exp(-j\omega _0n\frac{T}{4})-exp(j\omega _0n\frac{T}{4})]=\frac{-1}{j\omega _0nT}(-2cos(\omega _0n\frac{T}{4}))=\frac{2cos(\frac{\pi n}{2})}{j2\pi n}##

Then, ##c_1=0, c_2=\frac{-1}{j2\pi}, c_3=0, c_4=\frac{1}{j4\pi}, c_5=0, c_6=\frac{-1}{j6\pi}, c_7=0##

Am I correct up to this point?

It was nice to check my trig form answer with the MATLAB graph. I believe the graph I have above is part of what he is looking for in part (2). The other part being a plot of the original rectangular pulse function, which is proving a little more difficult to accomplish in matlab. How do I plot the given function?

Next, I don't think I can check the exp form the same way. Part (3) asks for the magnitude spectrum plots up to n=7. I think he wants 3 plots; One for each non-zero ##c_n## coefficient. I poked around MATLAB help and couldn't find a straightforward way to accomplish this. How do I plot the magnitude spectrum plots?

Thanks.
 
  • #11
Captain1024 said:
I'm finally making some progress on this:

Trig form:
##x(t)=a_0+\sum ^{\infty} _{n=1}a_ncos(2\pi ftn)+\sum ^{\infty}_{n=1}b_nsin(2\pi ftn)##, where n is the harmonic number.
Where ##a_0=\frac{1}{T}\int ^{\frac{t}{2}}_{\frac{-T}{2}}x(t)dt##. Simplifying, ##a_0=\frac{1}{T}\int ^{\frac{T}{4}}_{\frac{-T}{4}}x(t)dt=\frac{1}{4}[t]^1_{-1}=\frac{1}{4}*2,\ \therefore a_0=\frac{1}{2}##.

Where ##a_n=\frac{2}{T}\int ^{\frac{T}{2}}_{\frac{-T}{2}}cos(\frac{2\pi tn}{T})dt=\frac{2}{T}\int ^{\frac{T}{4}}_{\frac{-T}{4}}cos(\frac{2\pi tn}{T})dt=\frac{2}{T}[\frac{T}{2\pi n}sin(\frac{2\pi tn}{T})]^{\frac{T}{4}}_{\frac{-T}{4}}##
##=\frac{1}{\pi n}[sin(\frac{2\pi n\frac{T}{4}}{T})-sin(\frac{2\pi n\frac{-T}{4}}{T})]=\frac{1}{\pi n}[sin(\frac{\pi n}{2})-sin(\frac{-\pi n}{2})]=\frac{2}{\pi n}sin(\frac{\pi n}{2})##.

Then, ##a_1=\frac{2}{\pi}, a_2=0, a_3=\frac{-2}{3\pi}, a_4=0, a_5=\frac{2}{5\pi}, a_6=0, a_7=\frac{-2}{7\pi}##.

Graph:
sTPtTlP.png

Link: http://i.imgur.com/sTPtTlP.png

Exp form:
##x(t)=\sum ^{\infty}_{n=-\infty}c_nexp(j\omega _0tn)##

Where, ##c_0=\frac{1}{T}\int ^{\frac{t}{2}}_{\frac{-T}{2}}x(t)dt=a_0\ \therefore \ c_0=\frac{1}{2}##

##\mathrm{Where,}\ c_n=\frac{1}{T}\int ^{\frac{T}{2}}_{\frac{-T}{2}}x(t)exp(-j\omega _0tn)=\frac{1}{T}\int ^{\frac{T}{4}}_{\frac{-T}{4}}x(t)exp(-j\omega _0tn)=\frac{1}{T}[\frac{-1}{j\omega _0n}exp(-j\omega _0tn)]^{\frac{T}{4}}_{\frac{-T}{4}}=\frac{-1}{j\omega _0nT}[exp(-j\omega _0n\frac{T}{4})-exp(j\omega _0n\frac{T}{4})]=\frac{-1}{j\omega _0nT}(-2cos(\omega _0n\frac{T}{4}))=\frac{2cos(\frac{\pi n}{2})}{j2\pi n}##

Then, ##c_1=0, c_2=\frac{-1}{j2\pi}, c_3=0, c_4=\frac{1}{j4\pi}, c_5=0, c_6=\frac{-1}{j6\pi}, c_7=0##

Am I correct up to this point?

It was nice to check my trig form answer with the MATLAB graph. I believe the graph I have above is part of what he is looking for in part (2). The other part being a plot of the original rectangular pulse function, which is proving a little more difficult to accomplish in matlab. How do I plot the given function?

Next, I don't think I can check the exp form the same way. Part (3) asks for the magnitude spectrum plots up to n=7. I think he wants 3 plots; One for each non-zero ##c_n## coefficient. I poked around MATLAB help and couldn't find a straightforward way to accomplish this. How do I plot the magnitude spectrum plots?

Thanks.
I do not have access to Matlab, so I use Maple instead. In Maple, if I want to plot two graphs ##y = f_1(x)## and ##y = f_2(x)## together on a common interval ##x \in [a,b]## I would just say "plot([f1(x),f2(x)], x=a..b, color = [red,blue])" to get ##f_1(x)## in red and ##f_2(x)## in blue; or I could leave out the "color" option and let Maple choose the two colors. Is there a Matlab-equivalent method?

I don't know about how Matlab would deal with your other questions.

BTW: for future reference, the USUAL way of writing the Fourier series, say on ##[0, 2\pi]##, is exactly as I wrote it in post #9. That means that the series has ##\frac{1}{2}a_0## as the constant term, with the formula for ##a_0## being the same as the formula for ##a_n## by putting ##n = 0##. I recommend that you stick with the standard convention, because if you use one that is different from everybody else's it is more difficult to check your work for errors.
 

1. What is a Fourier series?

A Fourier series is a mathematical representation of a periodic function as a sum of sine and cosine functions with different frequencies and amplitudes. It is used to break down a complex periodic function into simpler components, making it easier to analyze and understand.

2. What is an even square wave?

An even square wave is a type of periodic function that has a constant value for half of its period, and then switches to a different constant value for the other half of its period. The graph of an even square wave resembles a square with flat, straight edges.

3. How are Fourier series coefficients of an even square wave calculated?

The Fourier series coefficients of an even square wave can be calculated by using the formula:

an = (4/π) * (∫0T/2 f(x)cos(nω0x)dx)

where T is the period of the square wave, ω0 is the fundamental frequency, and f(x) is the even square wave function.

4. Why are the Fourier series coefficients of an even square wave important?

The Fourier series coefficients of an even square wave are important because they allow us to represent a complex periodic function in a simpler form. This can be useful in various applications, such as signal processing and image compression, where it is necessary to break down a complex signal into simpler components.

5. Can the Fourier series coefficients of an even square wave be used to accurately reconstruct the original function?

Yes, the Fourier series coefficients of an even square wave can be used to accurately reconstruct the original function. As the number of terms in the series increases, the approximation becomes more and more accurate. In theory, an infinite number of terms would result in an exact representation of the original function.

Similar threads

  • Calculus and Beyond Homework Help
Replies
1
Views
996
  • Calculus and Beyond Homework Help
Replies
1
Views
708
  • Calculus and Beyond Homework Help
Replies
1
Views
222
  • Calculus and Beyond Homework Help
Replies
16
Views
568
  • Calculus and Beyond Homework Help
Replies
1
Views
349
  • Calculus and Beyond Homework Help
Replies
1
Views
540
  • Calculus and Beyond Homework Help
Replies
3
Views
420
  • Calculus and Beyond Homework Help
Replies
6
Views
244
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
291
Back
Top