The closer the two frequencies are, the more distinguishable the beat characteristics. Polly's sound file is a pretty good display of this phenomenon. For two sine waves with frequencies f1 and f2, you will get a wave with frequency (f1+f2)/2, so the average of the frequencies. The amplitude of this wave will be modulated with frequency (f1-f2)/s, so half the difference in frequency. For 40 and 41Hz you'd get a tone of 40.5Hz modulated in amplitude with a frequency of 0.5Hz in the case of sine waves. Rectangular waves are a different story as the waves themselves are a big series of sine waves summed together to create a rectangular wave (see the
Fourier Series for more information on this - it's actually pretty cool.