Fourier Series - Square Wave

In summary: This result pops out very easily when performing the integral that defines a_n.I was trying to find an algebraic expression to model that, mainly because it's what I saw on an example in class. Am I just making things harder on myself, or is there any benefit to showing it like...In summary, the author of this message attempted to find a Fourier series for a function that is periodic over the interval (−π, π) with f(x) = 1 for −\frac{π}{2} < x < \frac{π}{2} and f(x) = 0 otherwise, but made a mistake. After debugging and verifying the results, he found that a_{n
  • #1
BOAS
552
19
Hello,

I think that I have done this correctly, but this is the first problem I have done on my own and would appreciate confirmation.

1. Homework Statement


Find the Fourier series corresponding to the following functions that are periodic over the interval [itex](−π, π)[/itex] with: (a) [itex]f(x) = 1[/itex] for [itex]−\frac{π}{2} < x < \frac{π}{2}[/itex] and [itex]f(x) = 0[/itex] otherwise.

Homework Equations

The Attempt at a Solution


[/B]
The first coefficient [itex]a_{0} = \frac{1}{\pi} \int^{0.5\pi}_{-0.5\pi} f(x) dx = 1[/itex]

[itex]a_{n} = \frac{1}{\pi} \int^{0.5\pi}_{-0.5\pi} \cos(nx) dx[/itex]

which leads to the following;

[itex]a_{n} = - \frac{1}{n \pi} ((-1^{n}) - 1)[/itex]

[itex]b_{n} = \frac{1}{\pi} \int^{0.5 \pi}_{-0.5 \pi} \sin(nx) dx = 0[/itex]

so my Fourier series is;

[itex]f(x) = 1/2 + \frac{2}{\pi}(\cos(x) - \frac{1}{3}\cos(3x) + \frac{1}{5}\cos(5x) - ... + ) [/itex]

or [itex]f(x) = \frac{1}{2} + \Sigma^{\infty}_{n = 1} (- \frac{1}{n \pi}( (-1)^{n} - 1)) \cos(nx)[/itex]

Does this look ok?

Thanks
 
Last edited:
Physics news on Phys.org
  • #2
all sins looks good. seems to add up to 1 at origin.
 
  • #3
cellurl said:
all sins looks good. seems to add up to 1 at origin.

I think I have made a mistake somewhere, based on some plots I made in mathematica.

It does not appear to be creating a square wave.

I will go through it again.
 
  • #4
BOAS said:
Hello,

I think that I have done this correctly, but this is the first problem I have done on my own and would appreciate confirmation.

1. Homework Statement


Find the Fourier series corresponding to the following functions that are periodic over the interval [itex](−π, π)[/itex] with: (a) [itex]f(x) = 1[/itex] for [itex]−\frac{π}{2} < x < \frac{π}{2}[/itex] and [itex]f(x) = 0[/itex] otherwise.

Homework Equations

The Attempt at a Solution


[/B]
The first coefficient [itex]a_{0} = \frac{1}{\pi} \int^{0.5\pi}_{-0.5\pi} f(x) dx = 1[/itex]

[itex]a_{n} = \frac{1}{\pi} \int^{0.5\pi}_{-0.5\pi} \cos(nx) dx[/itex]

which leads to the following;

[itex]a_{n} = - \frac{1}{n \pi} ((-1^{n}) - 1)[/itex]

[itex]b_{n} = \frac{1}{\pi} \int^{0.5 \pi}_{-0.5 \pi} \sin(nx) dx = 0[/itex]

so my Fourier series is;

[itex]f(x) = 1 + \frac{2}{\pi}(\sin(x) - \frac{1}{3}\sin(3x) + \frac{1}{5}\sin(5x) - ... + ) [/itex]

or [itex]f(x) = \frac{1}{2} + \Sigma^{\infty}_{n = 1} (- \frac{1}{n \pi}( (-1)^{n} - 1)) \sin(nx)[/itex]

Does this look ok?

Thanks

Aha! I have found the mistake.

The [itex]a_{n}[/itex] coefficients are related to [itex]\cos(nx)[/itex] not [itex]\sin(nx)[/itex]
 
  • #5
BOAS said:
Hello,

I think that I have done this correctly, but this is the first problem I have done on my own and would appreciate confirmation.

1. Homework Statement


Find the Fourier series corresponding to the following functions that are periodic over the interval [itex](−π, π)[/itex] with: (a) [itex]f(x) = 1[/itex] for [itex]−\frac{π}{2} < x < \frac{π}{2}[/itex] and [itex]f(x) = 0[/itex] otherwise.

Homework Equations

The Attempt at a Solution


[/B]
The first coefficient [itex]a_{0} = \frac{1}{\pi} \int^{0.5\pi}_{-0.5\pi} f(x) dx = 1[/itex]

[itex]a_{n} = \frac{1}{\pi} \int^{0.5\pi}_{-0.5\pi} \cos(nx) dx[/itex]

which leads to the following;

[itex]a_{n} = - \frac{1}{n \pi} ((-1^{n}) - 1)[/itex]

[itex]b_{n} = \frac{1}{\pi} \int^{0.5 \pi}_{-0.5 \pi} \sin(nx) dx = 0[/itex]

so my Fourier series is;

[itex]f(x) = 1 + \frac{2}{\pi}(\cos(x) - \frac{1}{3}\cos(3x) + \frac{1}{5}\cos(5x) - ... + ) [/itex]

or [itex]f(x) = \frac{1}{2} + \Sigma^{\infty}_{n = 1} (- \frac{1}{n \pi}( (-1)^{n} - 1)) \cos(nx)[/itex]

Does this look ok?

Thanks

No, it is not OK. Your formula for the coefficients give results that are either 0 or positive, because ##-[(-1)^n - 1] = 1 - (-1)^n## is 0 for even n and 2 for odd n. In fact, the ##a_n## for successive odd n should alternate in sign. (However, when you subsequently wrote out the first few terms of the series, you did have alternating signs. How did that happen?)
 
  • #6
Ray Vickson said:
No, it is not OK. Your formula for the coefficients give results that are either 0 or positive, because ##-[(-1)^n - 1] = 1 - (-1)^n## is 0 for even n and 2 for odd n. In fact, the ##a_n## for successive odd n should alternate in sign. (However, when you subsequently wrote out the first few terms of the series, you did have alternating signs. How did that happen?)

I computed several coefficients for a, which lead me to observe the alternating sign pattern. My mistaken formula was not used there, I evaluated the expression for each.

I don't know if this is the prettiest formula, but it does the trick.

[itex]a_{n} = \frac{2}{\pi + 2(n-1) \pi} (-1)^{n-1}[/itex]
 
  • #7
BOAS said:
I computed several coefficients for a, which lead me to observe the alternating sign pattern. My mistaken formula was not used there, I evaluated the expression for each.

I don't know if this is the prettiest formula, but it does the trick.

[itex]a_{n} = \frac{2}{\pi + 2(n-1) \pi} (-1)^{n-1}[/itex]

Another one is
[tex] a_n = \frac{2}{\pi} \frac{\sin(n \pi/2)}{n}. [/tex]
 
  • #8
Ray Vickson said:
Another one is
[tex] a_n = \frac{2}{\pi} \frac{\sin(n \pi/2)}{n}. [/tex]

This result pops out very easily when performing the integral that defines a_n.

I was trying to find an algebraic expression to model that, mainly because it's what I saw on an example in class. Am I just making things harder on myself, or is there any benefit to showing it like this?
 
  • #9
BOAS said:
This result pops out very easily when performing the integral that defines a_n.

I was trying to find an algebraic expression to model that, mainly because it's what I saw on an example in class. Am I just making things harder on myself, or is there any benefit to showing it like this?

Well, the numerator of the second fraction is 0 for even n, is +1 for n = 1, 5, 9, ... and is -1 for n = 3, 7, 11, ... .All you need to do is find a nifty way of describing that in a formula that does not involve trig functions, etc. It might be easier to write the relevant n in the form n = 2m+1, m = 0, 1, 2, ... . Now we need +1 for even m and -1 for odd m, so ##(-1)^m## will do it. That is,
[tex] a_{2m+1} = \frac{2 (-1)^m}{\pi (2m+1)} [/tex]
 
  • Like
Likes BOAS

1. What is a Fourier Series?

A Fourier Series is a mathematical representation of a periodic function as a sum of sinusoidal functions. It is used to break down a complex function into simpler components, making it easier to analyze and understand.

2. How is a Fourier Series calculated?

A Fourier Series is calculated by finding the coefficients for each sinusoidal function that make up the periodic function. These coefficients can be determined using the Fourier Series formula and integral calculus.

3. What is a Square Wave?

A Square Wave is a type of periodic function that alternates between two constant values at regular intervals. It is often used to represent digital signals in electronics and communication systems.

4. How is a Square Wave represented in a Fourier Series?

A Square Wave can be represented in a Fourier Series by adding together sinusoidal functions with specific coefficients that create a waveform that closely approximates the square wave. This is known as a harmonic series.

5. What is the significance of Fourier Series - Square Wave in science?

Fourier Series - Square Wave has a wide range of applications in science, especially in fields such as signal processing, image and sound compression, and data analysis. It has also played a crucial role in the development of quantum mechanics and quantum computing.

Similar threads

  • Calculus and Beyond Homework Help
Replies
1
Views
224
  • Calculus and Beyond Homework Help
Replies
16
Views
568
  • Calculus and Beyond Homework Help
Replies
1
Views
351
  • Calculus and Beyond Homework Help
Replies
3
Views
422
  • Calculus and Beyond Homework Help
Replies
3
Views
292
  • Calculus and Beyond Homework Help
Replies
1
Views
540
  • Calculus and Beyond Homework Help
Replies
3
Views
349
  • Calculus and Beyond Homework Help
Replies
9
Views
195
  • Calculus and Beyond Homework Help
Replies
1
Views
290
  • Calculus and Beyond Homework Help
Replies
6
Views
245
Back
Top