User:LucasVB/Sine from square waves
We know a square wave can be synthesized using sine waves via an infinite series, as seen at the right. But what if we try to do the opposite, that is, synthesize a sine function out of square waves? Well, I decided to give it a shot, and the result is what you see at right. This time, subtractice synthesis was necessary, using only odd harmonics.
I defined my square function using the sign function, as such:
And my approach to the square sine was evaluting the following:
Which is what you see in the second animation. The jump discontinuities of the square waves add up in the zero crossings, and they are unbounded, so it wasn't really too successful. If this was a signal, a simple lowpass filter would pretty much solve all these issues, and the result would be quite close to a sine wave.
The problem is that in theory, you cannot get a smooth, continuous function out of a discontinuous function, as explained by User:Rainwarrior, since you need to approximate any given continuous segment with this function. This cannot be done with the square wave.
He did, however, present an improved method to achieve my original goal, which worked nicely and didn't grew indefinitely in the discontinuities:
As you can see, his results were very nice.
( There is some more discussion that was archived at Wikipedia:Reference_desk_archive/Science/December_2005#Synthesis_of_a_sine_wave_from_square_waves ).