the orthogonality of the trigonometric functions
Two arrows are perpendicular when their dot product is zero — they point in genuinely independent directions, so knowing one tells you nothing about the other. Functions can be perpendicular too, in a precise sense: their 'dot product' is the integral of their product over an interval, and when that integral is zero we call them orthogonal. The remarkable fact at the heart of Fourier analysis is that the family of sines and cosines is mutually orthogonal — each one is perpendicular to every other.
Concretely, over an interval of length 2L, the integral of cos(m pi x / L) times cos(n pi x / L) is zero whenever m and n differ, and likewise the integral of sin times sin for different frequencies, and the integral of any sine times any cosine is always zero. Only when a wave is paired with ITSELF does the integral come out nonzero (equal to L). You can prove these with product-to-sum identities, but the picture is that two waves of different frequency spend as much time multiplying to positive as to negative, so their product averages to nothing.
This orthogonality is the entire reason the Fourier coefficient formulas work. To find the amount of one particular wave in f, multiply f's series by that wave and integrate: orthogonality wipes out every other term, leaving just the coefficient you wanted. Without orthogonality the coefficients would be hopelessly entangled. The same principle, generalized to orthogonality with respect to a weight function, underlies Bessel, Legendre, and all Sturm–Liouville eigenfunction expansions — it is the universal mechanism for reading off coefficients.
Check directly: integral from -pi to pi of sin(2x) cos(5x) dx. Using a product-to-sum identity this becomes a sum of integrals of sin(7x) and sin(3x) over a full period, both of which integrate to zero. So sin(2x) and cos(5x) are orthogonal — perpendicular as functions — even though as curves they obviously overlap on the page.
Different-frequency waves average to nothing when multiplied — that 'cancellation' is what orthogonality means.
Orthogonality holds over a FULL period (or a half-period for sine/cosine on 0 to L with matching boundary conditions). Integrate over the wrong interval and the cross-terms no longer vanish, and the clean coefficient formulas break down.