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

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.
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
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...
I'm interested to know whether the equation $$1 = 2 - \frac{1}{2 - \frac{1}{2 - \cdots}}$$ is true or not. It can be shown easily that if the continued fraction converges, it cannot converge to anything else than 1. It seems that if the continued fraction converges, the convergence is very slow. The apparent slowness of the convergence makes it difficult to estimate the presence of true convergence numerically. At the moment I don't know whether this converges or not.
Back
Top