If we have a fundamental sine wave (1^{st} harmonic) of the following form
(for time-domain waves, x may be replaced by ft, where f is the fundamental frequency and t is the time point):

and add n^{th} harmonics of the form:

(where A_{1} = 1 and B_{1} = 0 for the fundamental) then the waveform resulting from summing the
first N harmonics (including the fundamental) can be expressed as:

We define w_{∞} to be the limiting case when an infinite number of harmonics are added:

Examples

Harmonics (N):

Figure 1: Harmonic sum w_{N}(x) compared to limiting case w_{∞}(x).

Figure 2: Individual harmonics h_{n}(x) which form w_{N}(x) in figure 1.

Notes

The modulo operator used here binds tighter than plus and minus, and is defined as:
(x and y don't need to be integers).

X(x) is a helper function used to achieve periodicity in the definitions of w_{∞}(x). X(x) is identical to x in the range -0.5 ≤ x < 0.5 and repeats itself periodically:

J_{1}(x) is the first-order Bessel function of the first kind.