Formula: Fourier Series Harmonics Formula
- squareWavePeakAmplitudeA: Square Wave Peak Amplitude A (V / units)
- FundamentalFrequencyHz: Fundamental Frequency (Hz)
- maxHarmonicOrderN: Max Harmonic Order N (harmonic N)
Compute Fourier harmonic coefficients, Parseval energy %, and Total Harmonic Distortion (THD).
The best-fitting sine must match the average height of the square wave across each half cycle. A sine spends much of its time below its peak, so its peak has to rise above A to compensate. The ratio is 4/pi, about 1.273, which turns a 5 volt square wave into a 6.366 volt fundamental.
Both the total power and the power in each harmonic scale with A squared, so the ratio cancels it. The calculator returns 94.96% for A = 3, 5 and 8 with N = 7. Only the number of harmonics changes the percentage. Frequency has no effect on it either.
The highest harmonic line reads 0 and is marked as zero for a square wave, because half-wave symmetry removes every even term. The power fraction does not change either: N = 8 gives the same 94.96% as N = 7. The result sentence still quotes the even harmonic's frequency, which is simply where that missing term would sit.
No. The overshoot narrows and moves toward the jump, but its height settles at about 8.95% of the jump, or roughly 1.179 times A. The calculator shows this limit, 5.895 at the default, for every N. A finite sum actually peaks a little higher, around 1.184A for N = 7.
Both, measured against different bases. The jump from -A to +A is 2A, and the overshoot is about 8.95% of that, which the label rounds to 9%. Against A alone the same overshoot is 17.9%, so the peak sits at about 1.179A. For the default 5 volt wave that is the 5.895 shown on the page.
No. The engine only computes square wave terms. For a sawtooth from -A to +A use 2A/(n pi) for every n, with alternating signs. For a triangle use 8A/(pi squared n squared) for odd n only. Both are worked by hand in the guide above, with figures for A = 5.
Only the hertz values in the result sentence. The 7th harmonic is described at 420 Hz for a 60 Hz input, seven times the fundamental, and that label moves whenever you change the frequency. All amplitudes, the power share and the Gibbs peak are independent of frequency, because the Fourier coefficients depend only on the waveform shape.
About 48.3%. Square wave THD is the square root of (pi squared over 8, minus 1), comparing the RMS of all harmonics above the fundamental with the RMS of the fundamental. The page summary mentions THD, but the engine does not output it, so calculate it by hand. It does not depend on amplitude or frequency.
Peak values. Each harmonic is a sine of amplitude b_n. To get the RMS reading of a single harmonic, divide by the square root of 2. The default fundamental of 6.366 is about 4.50 RMS, and the 7th harmonic at 0.91 peak is about 0.64 RMS.
It depends on what good means. Four odd terms already hold 94.96% of the power but look visibly wavy. Eleven odd terms, N = 21, hold 98.16% and look much squarer, though they still ring at the edges. Sharp corners always need many terms because the corner energy sits in high harmonics.
Its coefficients fall as 1 over n squared instead of 1 over n, because a triangle is the integral of a square wave. The 7th harmonic of a 5 volt triangle is about 0.08, against 0.909 for the square wave, and the fundamental alone carries about 98.6% of the power. With no jumps, there is no Gibbs ringing either.
Any whole number from 1 up to just under a thousand. Fractions, zero and larger values return an error, as do a zero or negative amplitude or frequency. Odd N gives the amplitude of that harmonic; even N gives zero. The power fraction approaches 100% very slowly, so orders in the hundreds add only a fraction of a percent.
Out of the box the calculator describes a symmetric square wave that switches between +5 and -5 at 60 Hz, rebuilt from its odd harmonics up to the 7th. In other words the partial sum uses the 1st, 3rd, 5th and 7th sine terms and nothing above them.
The headline answer is the amplitude of the fundamental sine, 6.366. That is 4A/pi with A = 5. The supporting lines give the 7th harmonic amplitude, 0.91 (0.909 before rounding), the share of the square wave's power captured by those four terms, 94.96%, and a Gibbs overshoot peak of 5.895. The sentence under the result adds that the 7th harmonic sits at 420 Hz, seven times the fundamental.
The surprising number is the first one. A sine wave that best fits a square wave of height 5 has a peak of 6.366, about 27% taller than the square wave itself. The fundamental overshoots the flat top so that, on average across the half cycle, it matches the area under the square. The higher harmonics then pull the peaks down and fill in the corners.
The engine handles one waveform: the odd symmetric square wave. For that wave it computes four things. The fundamental coefficient b1 = 4A/pi. The coefficient of the highest order you entered, 4A/(N pi) when N is odd and zero when N is even. The cumulative power fraction, which sums 8/(pi squared times k squared) over odd k up to N. And the Gibbs limit peak, A times about 1.179, a fixed constant. It accepts whole N from 1 up to just under a thousand and positive amplitude and frequency; anything else returns an error.
It does not draw or evaluate the partial sum, it does not compute sawtooth or triangle coefficients even though they appear in the page address, and it does not output total harmonic distortion even though the summary line mentions it. The fundamental frequency box changes only the hertz figures quoted in the sentence; none of the amplitudes or percentages depend on it.
Everything else in this guide, including the sawtooth and triangle series, the true peak of a finite partial sum and the THD figure, is worked by hand from the standard formulas. Where I give a number the calculator did not print, I say so.
A square wave of amplitude A with odd symmetry has the series (4A/pi) times the sum of sin((2k - 1)x)/(2k - 1) for k = 1, 2, 3 and upward. Only odd multiples of the fundamental appear, each with amplitude 4A/(n pi), so the coefficients fall off as 1/n.
With A = 5 the amplitudes are 6.366 for the 1st harmonic, 2.122 for the 3rd, 1.273 for the 5th and 0.909 for the 7th. You can confirm the 3rd by entering N = 3; the calculator returns 2.122 as the highest harmonic. Each coefficient is simply the fundamental divided by its order, which is a quick way to check any harmonic without a calculator.
Even harmonics are exactly zero for this wave because the square wave has half-wave symmetry: the second half of each cycle is the first half turned upside down. The calculator reflects that. If you type an even N such as 8, the 8th harmonic line reads 0 and is marked as zero for a square wave, and the power fraction stays at the same 94.96% as for N = 7, because no new energy has been added.
The amplitude input scales every coefficient linearly. At A = 3 the fundamental is 3.82 and the 7th harmonic 0.546; at A = 8 they are 10.186 and 1.455. Doubling the square wave doubles every harmonic.
A square wave of height A has a mean square value of A squared, because its value squared is A squared everywhere. Each sine term of amplitude b contributes b squared over 2 to the mean square. For the nth odd harmonic that is 8A squared over (pi squared n squared). Divide by A squared and the amplitude cancels, which is why the percentage line reads 94.96% at A = 3, 5 and 8 alike.
The fundamental alone carries 8 over pi squared, about 81.06%. I checked this by setting N to 1. Adding the 3rd harmonic brings it to 90.06%, and the 5th and 7th together lift it to 94.96%. At N = 21, with eleven odd terms, the figure is 98.16%.
Each extra harmonic adds less than the last, because its share falls with the square of its order. The last few percent of power sit in the sharp edges and take many terms to capture. That is the reason a square wave sent through a low-pass filter, a long cable or a slow amplifier comes out with rounded corners: the energy that makes the corners sharp lives in harmonics the system removes.
Total harmonic distortion follows from the same sums, but the engine does not print it. THD is the RMS of all harmonics above the fundamental divided by the RMS of the fundamental. For an ideal square wave it is the square root of (pi squared over 8, minus 1), about 0.483 or 48.3%, and it does not depend on amplitude or frequency.
Near each jump, a partial Fourier sum overshoots the flat top, and the overshoot never disappears as you add terms. It just gets narrower and moves closer to the jump. In the limit the peak reaches about 1.179 times A. For A = 5 that is the 5.895 the page shows.
The line is labelled as the Gibbs limit peak, about 1.179 times A, or roughly 9% of the 2A jump. Both descriptions are the same overshoot. The jump in a square wave from -A to +A is 2A, and the classic overshoot is about 8.95% of that, the figure quoted in the page description. Measured against A alone, the same overshoot is 17.9%, which is why the peak sits at 1.179A rather than 1.09A.
As the label says, this is the value as N goes to infinity, so it is the same for every N you enter. The peak of a finite sum is higher than the limit and falls toward it. Working the sums numerically: with only the fundamental the peak is the full 6.366, about 1.273A. With N = 3 it is about 1.200A, with N = 7 about 1.184A, which is roughly 5.92 at the default amplitude, and by N = 21 about 1.180A. So the 5.895 line is the ceiling you approach with many terms, not the exact peak of the 7 harmonic sum you specified.
The location of the peak moves too. For N = 3 the maximum sits at a quarter of pi, and in general it lands close to pi/(N + 1) from the jump. More harmonics squeeze the ripple toward the edge without shrinking its height.
A sawtooth that ramps from -A up to +A and then drops back has a different series, which you have to work yourself. Its coefficients are 2A/(n pi) with alternating signs, and unlike the square wave it contains every harmonic, even and odd: (2A/pi) times the sum of (-1) to the power n+1 times sin(nx)/n.
For A = 5 the fundamental is 2A/pi, about 3.18, half of the square wave's 6.366. The 2nd harmonic is about 1.59 and the 3rd about 1.06. The coefficients fall as 1/n like the square wave's, so the spectrum is just as rich in high frequencies, but they are spread across twice as many terms.
Parseval gives a much weaker first term. The sawtooth's mean square is A squared over 3, and the fundamental's share is 6 over pi squared, about 60.8%. You need many more harmonics to reach the 94.96% that four odd terms give for the square wave.
The sawtooth still has a jump, once per cycle, so it shows the same Gibbs overshoot of about 8.95% of the jump at that edge. The ramp section converges smoothly.
The triangle wave is the integral of a square wave, and integration divides each harmonic by its order. So the triangle keeps only odd harmonics, like the square wave, but its coefficients fall as 1 over n squared: (8A/pi squared) times the sum of (-1) to the power k times sin((2k+1)x)/(2k+1) squared.
With A = 5 the fundamental is 8A/pi squared, about 4.05. The 3rd harmonic is that divided by 9, about 0.45, and the 7th is divided by 49, about 0.08. Compare that with the square wave's 0.909 at the 7th harmonic and you can see why a triangle looks almost like a sine.
The fundamental carries 96 over pi to the fourth of the power, about 98.6%. A single sine term holds more of a triangle wave's energy than four odd terms hold of a square wave's.
Because a triangle wave is continuous, it has no Gibbs overshoot at all. The partial sums converge uniformly, and the error at the corners shrinks steadily as you add terms. Gibbs ringing belongs to waveforms with jumps, which is why it shows up on the square wave and sawtooth but not here.
The most practical use of these numbers is judging what a system will do to a square wave. Suppose an amplifier or filter passes up to about 420 Hz cleanly and cuts above. With a 60 Hz input, that keeps the 1st, 3rd, 5th and 7th harmonics, exactly the default case. The output will carry 94.96% of the original power, have visibly rounded edges, and ring near each transition.
If you need a cleaner edge, the percentage line tells you how much bandwidth to buy. Going from N = 7 to N = 21 lifts the captured power from 94.96% to 98.16%, but it means passing three times the bandwidth.
For measurement work, remember that the amplitudes here are peak values of each sine. Divide by the square root of 2 for RMS. The 6.366 fundamental at the default is about 4.50 RMS, which is the RMS of the 60 Hz component on its own, the part a spectrum analyser would show at the fundamental.