It is a sad but inevitable fact that music does not add up. Most of the time, we can ignore this and just tune up and play. Our guitars (and keyboards) are mostly—mostly!—adapted to compensate for how music doesn't add up. But still, guitar players have to make compromises with intonation and tuning.
One very common issue is when you tune the guitar so that it sounds okay in E major. When you play a C, and it sounds terrible— the G string is way out of whack, but when you try to retune, it no longer sounds all right in E major.
Another thing you might have encountered is all-knowing guitar players who say that you shouldn't tune your instrument using the 5th-fret/7th-fret method—without necessarily elaborating on why.
This article is an attempt to explain why tuning is difficult. I have prepared two versions of it: people with short attention spans can stop after the next section, whereas I go into a bit more detail on the history of out-of-tune guitars and pianos in the following section.
Long Story, Short
The harmonics method of guitar tuning is practical, but it's not correct.
The intervals found in the harmonic overtone series and the intervals as determined by the equally spaced frets on the guitar do not match up.
The perfect fifth between the second and third harmonic (or the 12th and 7th fret harmonics) is about 2% of a semitone bigger than the perfect fifth found between two notes separated by seven frets.
Not all might be able to perceive the difference in pitch, but if you tune with this method starting on the low E, the 2% difference will be compounded on subsequent string pairs. By the time you reach the top E string, the pitch can be noticeably sharper than the bottom E string.
The History of Consonance
The history of how our tuning system has evolved goes hand in hand with how Western music itself has evolved in harmonic complexity and how our approach to consonance and dissonance has been modified throughout the years.
What I call the "history of consonance" is how intervals that have previously been regarded as dissonances to be resolved (or avoided) have slowly become accepted as consonances.
In the beginning, only the unison and its octave inversion were accepted. The music of antiquity was monophonic and was performed without accompaniment.
The first development into polyphony was the organum, which was a harmonization of the single melodic line at the fourth or fifth. For centuries, the Church ruled that only perfect unisons and fourths/fifths were consonant intervals; pieces could not be ended on a resounding major chord, since the third was ugly.
Starting with the Renaissance, the third (and sixth) gained acceptance as a consonant interval, which added another level of harmonic complexity. And ever since then, composers have experimented with progressively smaller intervals until the jarring semitone clusters of 20th century music.
Temperament and Tuning
As I stated in the beginning of this article, music doesn't add up. What I mean by that is that the intervals as given by the naturally occuring harmonic series state one fact. The 24 major and minor keys that need to be reasonably in tune state another. Never the twain shall meet, and therein lies the problem.
Instruments such as the voice or the violin have no frets or fixed pitches, and therefore singers and violinists can always adjust their intonation on the fly, to suit whatever interval, chord or key. The guitar and the piano have restraints placed on them since they have fixed pitches. The guitar has frets, the piano fixed strings that are struck by hammers.
In interval theory, the math is pretty simple. If you stack three major thirds on top of each other, you have 12 semitones, or an octave. By the same reasoning, you should be able to start on C and stack 11 perfect fifths on top of each other to get to a (very high) C.
This is what doesn't add up. When you take the frequency ratios as stated by the harmonic series—2:3 for a perfect fifth and 4:5 for a major third—you do not wind up on the original note. You wind up slightly sharper. This is what is known as a comma. The difference between three major thirds and an octave is called a diesis (41.06% of a semitone) and the difference between seven octaves and 12 perfect fifths is called a Pythagorean comma, which is roughtly 23.46% of a semitone.
Exactly how off a tone can be until it's perceived as out of tune depends on a person's sense of pitch, but it's generally around 2 cents (2% of a semitone). 23 cents, let alone 41 cents is deep down in Sour Valley.
Therefore, the tuning of fixed-pitch musical instruments requires compromises in order to enable playing in more than one key at a time, and more complex harmonies than unisons and fifths. Such compromises are collectively known as temperament.
The severity of such compromises has varied depending on musical tastes and practices during a given time. Since the third was gradually accepted as a consonant interval during the Renaissance, a temperament was needed that gave reasonable thirds in the most common keys. One common method was meantone temperament. This temperament sacrifices fifths in order to bring the thirds closer to their natural ratio. It sounds good enough when in or close to C major, but it falls apart and leads to jarring dissonances in keys with four or more accidentals.
Well and Equal Temperament
Since the Baroque period, theorists have edged closer and closer to a completely even-tempered system. In Bach's time and throughout the 19th century, the so-called "well-tempered" system was common, even if it isn't known exactly which system Bach wrote his two sets of preludes and fugues for. What we do know is that well temperament is a compromise that allows reasonable consonance in all 24 keys. The catch is that the dissonances are spread out in such a way that no key is the other alike, and from that stems the many 19th-century theories on key connotations. Beethoven is well known to have preferred E flat and C minor, describing B minor as a "black key".
The increasing chromaticism of 19th-century music meant that something even more radical than well temperament was needed. Thus equal temperament came to be. Equal temperament divides the octave into 12 exactly identical semitones, with the consequence that all keys are equally out of tune compared to the natural intervals found in the overtone series. The upside is that they are still close enough to be acceptable, and the circle of fifths repeats after 12 steps without the Pythagorean comma and you can play in all 24 keys equally well. Or badly, depending upon how you look at it.
Equal temperament has been part and parcel of our harmonic language for more than 100 years. Our ears are attuned to it, and indeed it is difficult to obtain instruments that are not tempered this way. But the subtle pitch differences still bother people with acute sense of pitch, and we guitar players have to keep the limitations of the system in mind when we tune up.
It is actually possible to get closer to the natural ratios, but this involves forfeiting enharmonic equivalence and traditional instrument construction. By dividing the octave into more than 12 parts, you get consonant intervals in more keys. This was already attempted during the Middle Ages, where some solutions involved a few split black keys on the harpsichord and organ manuals. D sharp and E flat were different keys, so were G sharp and A flat.
But these proposed systems are considerably more radical than that. One system that has been proposed has 19 notes per octave, and there are also 31-tone and 53-tone systems. The reason why neither has caught on is that, well, how would you play a 360-key keyboard? How closely wouldn't the frets be spaced on the necks of my guitars? (And I struggle on the top frets as it is...)