Mathwords logoMathwords

Square Wave — Definition, Formula & Example

A square wave is a repeating signal that holds one constant value for half of each cycle, then jumps instantly to the opposite value for the other half. On a graph it looks like a row of flat-topped blocks that alternate above and below the axis.

For amplitude A>0A>0 and period T>0T>0, the square wave is the TT-periodic function with f(t)=Af(t)=A for 0<t<T20<t<\tfrac{T}{2} and f(t)=−Af(t)=-A for T2<t<T\tfrac{T}{2}<t<T. Equivalently, f(t)=A sgn⁡ ⁣(sin⁡2πtT)f(t)=A\,\operatorname{sgn}\!\left(\sin\tfrac{2\pi t}{T}\right). It is odd and satisfies the half-wave symmetry f(t+T2)=−f(t)f(t+\tfrac{T}{2})=-f(t). It has jump discontinuities at integer multiples of T2\tfrac{T}{2}, where its Fourier series converges to the midpoint value 00.

Key Formula

f(t)=4Aπ∑k=1∞sin⁡((2k−1) ωt)2k−1,ω=2πTf(t)=\frac{4A}{\pi}\sum_{k=1}^{\infty}\frac{\sin\big((2k-1)\,\omega t\big)}{2k-1},\qquad \omega=\frac{2\pi}{T}
Where:
  • AA = Amplitude: the wave's constant height above or below the axis
  • TT = Period: the length of one full cycle
  • ω\omega = Angular frequency of the fundamental, in radians per unit time
  • kk = Summation index; 2k − 1 runs through the odd harmonics 1, 3, 5, ...

Worked Example

Problem: A signal generator outputs a square wave that switches between +5 V and −5 V. What fraction of the signal's average power is carried by its fundamental sine component alone?
Step 1: Find the mean square of the whole wave. Because f(t)2=25f(t)^2=25 at every point except the jumps, the average of f2f^2 over one period is 25, so the RMS value is 5 V.
f2‾=52=25,fRMS=5 V\overline{f^2}=5^2=25,\qquad f_{\text{RMS}}=5\ \text{V}
Step 2: Read the fundamental's amplitude from the formula with k=1k=1 and A=5A=5. It is larger than the wave's own height of 5 V.
b1=4Aπ=20π≈6.37 Vb_1=\frac{4A}{\pi}=\frac{20}{\pi}\approx 6.37\ \text{V}
Step 3: A sine of amplitude b1b_1 has mean square b12/2b_1^2/2. Divide this by the total mean square from Step 1.
b12/225=400/(2π2)25=8π2≈0.811\frac{b_1^2/2}{25}=\frac{400/(2\pi^2)}{25}=\frac{8}{\pi^2}\approx 0.811
Answer: The fundamental carries 8/π2≈0.8118/\pi^2\approx 0.811, or about 81.1%, of the average power. The odd harmonics 3, 5, 7, ... carry the remaining 18.9%.

Why It Matters

Square waves serve as clock signals in digital circuits and as the drive signal of PWM motor controllers. Engineers use the result above to filter a square wave into a nearly pure sine wave. Removing the 3rd, 5th, and higher harmonics leaves a signal that keeps about 81% of the original power.

Common Mistakes

Mistake: Including even harmonics such as sin⁡2ωt\sin 2\omega t or sin⁡4ωt\sin 4\omega t in the series, or assuming the fundamental's amplitude equals AA.
Correction: The half-wave symmetry f(t+T2)=−f(t)f(t+\tfrac{T}{2})=-f(t) forces every even-harmonic coefficient to equal zero, so only odd harmonics appear. The fundamental's amplitude is 4A/π≈1.27A4A/\pi\approx 1.27A, which is larger than AA. The higher harmonics partly cancel it to produce the flat tops.

Related Terms