You can think of any kind of waveform as being made of a set of sine waves, each of which contributes to the overall wave shape. A mathematical tool called Fourier analysis describes exactly how these sine waves add together to produce waves of different shapes.
Every wave begins with a sine wave called the fundamental. The fundamental serves as the backbone for the wave shape and determines its frequency. The fundamental has greater energy, or amplitude, than the harmonics.
Sine waves called harmonics determine a complex wave’s final shape. Harmonics always have frequencies which are exact multiples of the fundamental’s frequency. While a wave always has a fundamental, the number and amount of harmonics varies. Sharp-edged waves, such as square and sawtooth, have stronger harmonics than waves with few sharp transitions, such as the triangle.
Mathematically ideal waveforms may have an infinite number of harmonics. For example, the sawtooth waveform has all harmonics. The strength of each one is the reciprocal of its harmonic number. Its third harmonic has one-third the energy of the fundamental, the fourth, has one-fourth, and so on. You add the odd harmonics to the fundamental and subtract the even ones.