Why the piano is out of tune on purpose
Stack up twelve perfect fifths and you should land exactly seven octaves higher. You don't quite. That small gap is why pianos are tuned the way they are.
A perfect fifth is the ratio 3:2: one string vibrating half again as fast as the other. An octave is 2:1. Nobody chose these. They're what you get when two string lengths line up in simple whole numbers, and that's why they sound settled.
So twelve fifths up and seven octaves down should land you back where you began. The arithmetic disagrees. (3/2)12 over27 comes to 531441 / 524288, which isn't 1. The leftover is 23.46 cents, about a quarter of a semitone. It's called the Pythagorean comma. Too small to bother you in one chord, too big to hide across 88 keys.
What equal temperament does about it
Equal temperament shares the error out evenly. Every semitone becomes exactly 21/12, so twelve of them close the octave with nothing left over. The trade is that now only the octave is properly in tune. Everything else is slightly off, deliberately, and off by the same amount in every key. That last part is what makes it worth doing: you can play in any key and it sounds equally fine.
| interval | ratio | just | equal | error | hear it |
|---|---|---|---|---|---|
| unison | 1:1 | 0.0 | 0 | 0.0 | |
| minor second | 16:15 | 111.7 | 100 | -11.7 | |
| major second | 9:8 | 203.9 | 200 | -3.9 | |
| minor third | 6:5 | 315.6 | 300 | -15.6 | |
| major third | 5:4 | 386.3 | 400 | +13.7 | |
| perfect fourth | 4:3 | 498.0 | 500 | +2.0 | |
| tritone | 45:32 | 590.2 | 600 | +9.8 | |
| perfect fifth | 3:2 | 702.0 | 700 | -2.0 | |
| minor sixth | 8:5 | 813.7 | 800 | -13.7 | |
| major sixth | 5:3 | 884.4 | 900 | +15.6 | |
| minor seventh | 16:9 | 996.1 | 1000 | +3.9 | |
| major seventh | 15:8 | 1088.3 | 1100 | +11.7 | |
| octave | 2:1 | 1200.0 | 1200 | 0.0 |
Hear it for yourself
Press both on any row and you'll hear the just interval and the equal-tempered one at the same time, over a shared root. On the fourth and the fifth they're so close you just hear one steady note. On the major third they aren't, and you get beating instead: a slow throb as the two waves slide in and out of step. The throb happens once per hertz of difference between them. You're listening to the tuning error directly.