A square wave is a nonsinusoidal periodic waveform (which can be represented as an infinite summation of sinusoidal waves), in which the amplitude alternates at a steady frequency between fixed minimum and maximum values, with the same duration at minimum and maximum. The transition between minimum to maximum is instantaneous for an ideal square wave; this is not realizable in physical systems. Square waves are often encountered in electronics and signal processing. Its stochastic counterpart is a twostate trajectory. A similar but not necessarily symmetrical wave, with arbitrary durations at minimum and maximum, is called a pulse wave (of which the square wave is a special case).
Contents

Origin and uses 1

Examining the square wave 2

Characteristics of imperfect square waves 3

Other definitions 4

See also 5

External links 6
Origin and uses
Square waves are universally encountered in digital switching circuits and are naturally generated by binary (twolevel) logic devices. They are used as timing references or "clock signals", because their fast transitions are suitable for triggering synchronous logic circuits at precisely determined intervals. However, as the frequencydomain graph shows, square waves contain a wide range of harmonics; these can generate electromagnetic radiation or pulses of current that interfere with other nearby circuits, causing noise or errors. To avoid this problem in very sensitive circuits such as precision analogtodigital converters, sine waves are used instead of square waves as timing references.
In musical terms, they are often described as sounding hollow, and are therefore used as the basis for wind instrument sounds created using subtractive synthesis. Additionally, the distortion effect used on electric guitars clips the outermost regions of the waveform, causing it to increasingly resemble a square wave as more distortion is applied.
Simple twolevel Rademacher functions are square waves.
Examining the square wave
The six arrows represent the first six terms of the Fourier series of a square wave. The two circles at the bottom represent the exact square wave (blue) and its Fourierseries approximation (purple).
(odd) harmonics of a square wave with 1000 Hz
Using Fourier expansion with cycle frequency f over time t, we can represent an ideal square wave with an amplitude of 1 as an infinite series of the form

\begin{align} x_{\mathrm{square}}(t) & {} = \frac{4}{\pi} \sum_{k=1}^\infty {\sin{\left (2\pi (2k1) ft \right )}\over(2k1)} \\ & {} = \frac{4}{\pi}\left (\sin(2\pi ft) + {1\over3}\sin(6\pi ft) + {1\over5}\sin(10\pi ft) + \cdots\right ) \end{align}

220Hz square wave created by harmonics added every second over sine wave.

Problems playing this file? See .

The ideal square wave contains only components of oddinteger harmonic frequencies (of the form 2π(2k1)f). Sawtooth waves and realworld signals contain all integer harmonics.
A curiosity of the convergence of the Fourier series representation of the square wave is the Gibbs phenomenon. Ringing artifacts in nonideal square waves can be shown to be related to this phenomenon. The Gibbs phenomenon can be prevented by the use of σapproximation, which uses the Lanczos sigma factors to help the sequence converge more smoothly.
An ideal mathematical square wave changes between the high and the low state instantaneously, and without under or overshooting. This is impossible to achieve in physical systems, as it would require infinite bandwidth.
Animation of the additive synthesis of a square wave with an increasing number of harmonics
Squarewaves in physical systems have only finite bandwidth, and often exhibit ringing effects similar to those of the Gibbs phenomenon, or ripple effects similar to those of the σapproximation.
For a reasonable approximation to the squarewave shape, at least the fundamental and third harmonic need to be present, with the fifth harmonic being desirable. These bandwidth requirements are important in digital electronics, where finitebandwidth analog approximations to squarewavelike waveforms are used. (The ringing transients are an important electronic consideration here, as they may go beyond the electrical rating limits of a circuit or cause a badly positioned threshold to be crossed multiple times.)
The ratio of the high period to the total period of any rectangular wave is called the duty cycle. A true square wave has a 50% duty cycle  equal high and low periods. The average level of a rectangular wave is also given by the duty cycle, so by varying the on and off periods and then averaging it is possible to represent any value between the two limiting levels. This is the basis of pulse width modulation.

5 seconds of square wave at 1 kHz

Problems playing this file? See .

Characteristics of imperfect square waves
As already mentioned, an ideal square wave has instantaneous transitions between the high and low levels. In practice, this is never achieved because of physical limitations of the system that generates the waveform. The times taken for the signal to rise from the low level to the high level and back again are called the rise time and the fall time respectively.
If the system is overdamped, then the waveform may never actually reach the theoretical high and low levels, and if the system is underdamped, it will oscillate about the high and low levels before settling down. In these cases, the rise and fall times are measured between specified intermediate levels, such as 5% and 95%, or 10% and 90%. The bandwidth of a system is related to the transition times of the waveform; there are formulas allowing one to be determined approximately from the other.
Other definitions
The square wave in mathematics has many definitions, which are equivalent except at the discontinuities:
It can be defined as simply the sign function of a periodic function, an example being a sinusoid:

\ x(t) = \sgn(\sin[t])

\ v(t) = \sgn(\cos[t])
which will be 1 when the sinusoid is positive, −1 when the sinusoid is negative, and 0 at the discontinuities. Any periodic function can substitute the sinusoid in this definition.
A square wave can also be defined with respect to the Heaviside step function u(t) or the rectangular function ⊓(t):

\ x(t) = \sum_{n=\infty}^{+\infty} \sqcap(t  nT) = \sum_{n=\infty}^{+\infty} \left( u \left[t  nT + {1 \over 2} \right]  u \left[t  nT  {1 \over 2} \right] \right)
T is 2 for a 50% duty cycle. It can also be defined in a piecewise way:

\ x(t) = \begin{cases} 1, & t < T_1 \\ 0, & T_1 < t \leq {1 \over 2}T \end{cases}
when

\ x(t + T) = x(t)
In terms of sine and cosecant with period p and amplitude a:

y(x) = a\times\csc\left(\frac{2\pi}{p}x\right)\left\vert\sin\left(\frac{2\pi}{p}x\right)\right\vert
A square wave can also be generated using the floor function in the following two ways:
Directly:

y(x) = m \left(2\lfloor \nu x\rfloor  \lfloor 2 \nu x\rfloor + 1\right)
And indirectly:

y(x) = m \left(1\right)^{\lfloor \nu x \rfloor},
where m is the magnitude and ν is the frequency.
See also
External links

Flash applets Square wave.
This article was sourced from Creative Commons AttributionShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, EGovernment Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a nonprofit organization.