Why Doesn't My Fourier Series Expansion Look Like a Square Wave?

AI Thread Summary
The discussion centers on the confusion surrounding the Fourier series expansion of a square wave function. The original function was incorrectly defined over an infinite domain, leading to the conclusion that a Fourier series could not be applied. To achieve a proper square wave representation, the function should be defined on a finite interval, such as from -π to π. The user resolved their plotting issues by correcting the order of operations in their equation, resulting in a satisfactory square wave graph. Proper formatting techniques for mathematical expressions were also shared to enhance clarity in future discussions.
back2square1
Messages
13
Reaction score
0
for a square wave function,

f(x)= { -1, -∞ ≤ x ≤ 0; +1, 0 ≤ x ≤ ∞

Expanding it in Fourier series gives a function like,

f(x) = (4/π) * Ʃn=0( (sin ((2n+1)x) / (2n+) )

Plotting a graph of the equation gives something like this, http://goo.gl/vFJhL
which obviously doesn't look like a square wave. Can anyone tell me where have I gone wrong? What am I missing?

P.S
Fourier co-efficients
an=0
a0=0
 
Mathematics news on Phys.org
back2square1 said:
for a square wave function,

f(x)= { -1, -∞ ≤ x ≤ 0; +1, 0 ≤ x ≤ ∞

The way you have written this, f(x) is not a square wave. It's a signum function.

A Fourier series is a series representation of a periodic function. If you take the Fourier series of a non-periodic function on a finite interval [a,b], then the Fourier series matches your function on that domain, but repeats the function shape with period b-a.

What you have written, however, has an infinite domain, so a Fourier series cannot be used - you would have to use a Fourier transform instead. However, because you mention a square wave, what you probably want to do is define your function on a finite domain, such as

$$f(x) = \left\{\begin{array}{c}{-1,~-1 \leq x < 0 \\ +1,~0 < x \leq 1}\end{array}\right.$$

Then, calculate the Fourier series for that function on the domain [-1,1]. The resulting Fourier series should be a square wave. Note also that it is odd about x = 0, so I would expect only sine terms in the series, and in fact you should get the series you quoted.

As for why your plots aren't working, it looks to me like an order of operations issue. When you write the sum you are writing terms like "4sin(5x)/5pi". The plotter is interpreting this as "(4*sin(5x)/5)*pi". Write it like "4sin(5x)/5/pi" or "4sin(5x)/(5pi)" and you will get the result you want.
 
Last edited:
Thank you very much, Mute. It worked really nice. You're a wonderful guy. As you said, I added some extra parenthesis to my function and I can see a nice square wave, like this: http://goo.gl/9nu8V
Thank you once again. And yeah, I meant to write it like this,
f(x)= { -1, -π ≤ x ≤ 0; +1, 0 ≤ x ≤ π
I wrongly clicked on ∞ instead of π on the side bar.
And hey, please tell me how did you write that function in such a nice layout?
 
back2square1 said:
Thank you very much, Mute. It worked really nice. You're a wonderful guy. As you said, I added some extra parenthesis to my function and I can see a nice square wave, like this: http://goo.gl/9nu8V
Thank you once again. And yeah, I meant to write it like this,
f(x)= { -1, -π ≤ x ≤ 0; +1, 0 ≤ x ≤ π
I wrongly clicked on ∞ instead of π on the side bar.
And hey, please tell me how did you write that function in such a nice layout?


Use the 'Quote' button on Mute's post, and it will show you the formatting used.
 
Seemingly by some mathematical coincidence, a hexagon of sides 2,2,7,7, 11, and 11 can be inscribed in a circle of radius 7. The other day I saw a math problem on line, which they said came from a Polish Olympiad, where you compute the length x of the 3rd side which is the same as the radius, so that the sides of length 2,x, and 11 are inscribed on the arc of a semi-circle. The law of cosines applied twice gives the answer for x of exactly 7, but the arithmetic is so complex that the...
Thread 'Unit Circle Double Angle Derivations'
Here I made a terrible mistake of assuming this to be an equilateral triangle and set 2sinx=1 => x=pi/6. Although this did derive the double angle formulas it also led into a terrible mess trying to find all the combinations of sides. I must have been tired and just assumed 6x=180 and 2sinx=1. By that time, I was so mindset that I nearly scolded a person for even saying 90-x. I wonder if this is a case of biased observation that seeks to dis credit me like Jesus of Nazareth since in reality...
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
Back
Top