Square Wave Fourier Harmonics Calculator

Split a square wave into its harmonics and see how much of the signal sits in each one.

Physics and EnergyUpdated 2026-10-214 min read
Square Wave Fourier Harmonics Calculator
Fundamental amplitude
...
Third harmonic amplitude...
Total harmonic distortion...
RMS value...
Gibbs overshoot...
Fourier series...

What it does

A square wave is the simplest signal that cannot be described by one sine wave, and the way it is built out of sines is the most useful result in signal processing. The MIT notes for computational science and engineering give the result straight away: the odd numbered coefficients of a square wave are 4 over pi times k, and the even numbered ones are all zero.

The reason the even harmonics vanish is symmetry. A square wave spends exactly half its period above zero and half below, and it does that about its midpoint, so any sine term that is not odd in the time variable cannot survive the averaging. What is left is an infinite set of sine terms, each a third, a fifth, a seventh of the size of the one before it.

The coefficients fall as one over n, and that slow decay is why the series is awkward to sum. MIT's differential equations notes make the point with the Gibbs phenomenon: for any periodic function with a jump discontinuity, summing any number of terms always overshoots the jump by about 9 % of the size of the jump. For a square wave with a jump of 2, that is an overshoot of about 0.18, and it never gets smaller however many terms you add.

This page takes the peak amplitude, the fundamental frequency and the number of harmonics you want, and returns the harmonic amplitudes, the series written out, the root mean square value of the wave, the total harmonic distortion and the size of the Gibbs overshoot.

The total harmonic distortion figure is the one that matters in practice, because it is the share of the signal power that sits outside the fundamental. For a square wave it is 48.34 %, which is why a square wave sounds so harsh on a loudspeaker compared with a sine, and why a switching power supply running in square wave mode needs a filter to keep the harmonics out of the output.

How to use

  1. Enter the peak amplitude of the square wave.
  2. Enter the fundamental frequency, which is the frequency of the square wave itself and of its first harmonic.
  3. Choose how many harmonics you want listed. The even ones are always zero, so only the odd ones appear.
  4. Read the fundamental and third harmonic amplitudes, and note how each one is a third of the one before it.
  5. Read the root mean square value, which is the peak divided by the square root of 2 for a square wave.
  6. Read the total harmonic distortion and the Gibbs overshoot, which stay the same however many terms you sum.

Formula

Harmonic amplitudes: b n = 4 A / (pi n) for odd n and 0 for even n, with A the peak amplitude. Root mean square value: A / square root of 2. Total harmonic distortion: the square root of the sum of one over n squared over the odd harmonics beyond the first, which is the square root of pi squared over 8 minus 1. Gibbs overshoot: 0.09 x 2 A, since the jump of a symmetric square wave is 2 A.
A
Peak amplitude of the square wave.
b n
Amplitude of the nth harmonic.
n
Harmonic number, counting the fundamental as 1.
THD
Total harmonic distortion, the share of the power above the fundamental.
w
Angular frequency of the fundamental, 2 pi times the fundamental frequency.

The total harmonic distortion of a square wave does not depend on the amplitude, because every harmonic scales with it. The figure of 48.34 % comes from the closed form, the square root of pi squared over 8 minus 1, and it is a property of the waveform rather than of any particular circuit. The Gibbs overshoot is also fixed at about 9 % of the jump, which is why adding terms makes the ripple narrower but never lower.

Worked example

Example: a 5 V square wave at 50 Hz

Defaults: a peak amplitude of 5 V, a fundamental of 50 Hz and five harmonics listed.

  1. The fundamental is 4 x 5 / pi = 6.3662 V peak.
  2. The third harmonic is 6.3662 / 3 = 2.1221 V peak and the fifth is 6.3662 / 5 = 1.2732 V peak.
  3. The even harmonics are zero, so the series is x(t) = 6.3662 sin(wt) + 2.1221 sin(3wt) + 1.2732 sin(5wt) V with more terms following.
  4. The root mean square value is 5 / square root of 2 = 3.5355 V.
  5. Total harmonic distortion: the square root of pi squared over 8 minus 1 = 0.4834, so 48.34 %.
  6. The Gibbs overshoot is 0.09 x 2 x 5 = 0.9 V, and it does not shrink as more terms are added.
  7. The tool shows 6.3662 V peak, 2.1221 V peak, 48.34 %, 3.5355 V, 0.9000 V overshoot and the series.

Reference table

Harmonic amplitudes of a 5 V square wave and the share of the power each one carries
HarmonicAmplitudeRelative to the fundamentalShare of the power
1st6.3662 V181.06 %
3rd2.1221 V1 in 39.01 %
5th1.2732 V1 in 53.24 %
7th0.9095 V1 in 71.65 %
9th0.7074 V1 in 91.00 %

Limits

  • The page covers a symmetric square wave with equal positive and negative halves, and not a unipolar pulse train with a duty cycle other than half.
  • Only the ideal square wave is modelled, so there is no rounding, no finite rise time and no overshoot in the real signal.
  • The harmonic amplitudes are the ideal Fourier coefficients, and a real circuit with a filter in it will not match them.
  • No frequency dependence is included, so a square wave through a lossy line is not represented.

Common mistakes

  • Expecting the even harmonics to appear. Symmetry kills them, and a series with a second harmonic describes a different waveform.
  • Expecting the partial sum to settle on the square wave. The Gibbs overshoot stays at about 9 % of the jump however many terms you add.
  • Confusing the amplitude of a harmonic with its power. The amplitude falls as 1 over n but the power falls as 1 over n squared.
  • Applying the square wave coefficients to a triangle wave, where the coefficients fall as 1 over n squared instead.
  • Using the peak amplitude where the root mean square value is needed, which overstates the power of the signal by the square root of 2.

Try it yourself

Quick checks. Answers sit tucked under each question.

What is the amplitude of the third harmonic of a 5 V square wave?

2.1221 V. The fundamental is 4A over pi = 6.3662 V and the third harmonic is a third of that, 2.1221 V.

What is the total harmonic distortion of a square wave?

48.34 %. It comes from the square root of pi squared over 8 minus 1, and it does not depend on the amplitude.

What is the root mean square value of a 5 V square wave?

3.5355 V, which is the peak amplitude divided by the square root of 2.

Questions

Why does a square wave have no even harmonics?

Because of its symmetry. The wave is the same above and below its midpoint, so any term that is not odd in time averages away, and the even numbered sine and cosine terms drop out.

What is the Gibbs phenomenon?

The overshoot that appears near a jump in a partial Fourier series. It stays at about 9 % of the jump no matter how many terms you sum, it just gets narrower.

Why does a square wave sound harsh?

Because almost half its power sits above the fundamental. A loudspeaker that reproduces a 50 Hz square wave has to push the third, fifth and seventh harmonics as hard as the fundamental, and that is what makes the sound harsh.

What is total harmonic distortion?

The share of the signal power that sits above the fundamental frequency. For a square wave it is 48.34 %.

How is a square wave used in electronics?

Switching power supplies and digital circuits run on square waves, and a filter after the switch removes the harmonics so the output is smooth. This page gives the amplitudes that filter has to deal with.

Does the series ever reach the square wave exactly?

No. Away from the jumps it converges, but at the jumps it always overshoots by about 9 % of the step, and the partial sums keep a ripple that never disappears.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.