# Why can I still hear sound when the frequency of the periodic function inside Play is higher than the range of human ear?

We know that usually sound that is perceptible by humans has frequencies from about 20 Hz to 20,000 Hz, but as the title said, I can still hear the sound of the outputs of the following code:

(* The following sound won't cause discomfort… I think. *)
Play[Sin[1000000 2 Pi t], {t, 0, 1}, SampleRate -> 10000000]


After asking some of my friends to hear them, I'm sure I don't have clairaudience. I think it's probably not the fault of Mathematica, it might be an issue for loudspeaker, but I failed to find an answer by myself and I think it's worth posting a question for this.

• I was similarly disappointed when GrayLevel[10^50] failed to produce a gigawatt laser cannon. Nov 6, 2013 at 10:09
• @SimonWoods Tell me about it. I have been trying to heat my food with Plot[Sin[2 π 2.45 10^9 t], {t, 0, 60}]. Food still cold.
– gpap
Nov 6, 2013 at 10:24
• @gpap Probably an experimental setup problem. You've to stuff the processor inside the poultry, not the other way around Nov 6, 2013 at 11:30
• @gpap On the other hand, you could easily do it with Inverse[RandomInteger[1000, {1000, 1000}]] :P
– rm -rf
Nov 6, 2013 at 13:18
• Funny, my son's dog asked me this very question the other day. Jan 30, 2021 at 16:06

Just saying SampleRate -> 10000000 does not mean that the hardware is capable of playing samples at that rate. (Most modern devices can do 192 kHz; but it's likely you're running at 48 kHz.)

Mathematica or the OS or the sound driver or the hardware will resample the data to something that is supported. Depending on how well the resampling is implemented, the 1 MHz signal will either vanish or be folded back to a lower frequency.

To avoid resampling, you should use SampleRate -> 48000 (or any other rate supported by your hardware).

• how do i determine a rate supported by my hardware? Aug 30, 2021 at 0:29
• @Michael AFAICS this is not possible from within Mathematica. All built-in sound devices support 48 kHz.
– CL.
Aug 30, 2021 at 7:15
• Hmm, ok. The reason I ask is I can hear a steadily increasing frequency sound from Play[Sin[100*2^(t/1.9)*2 Pi*t], {t, 0, 10}, SampleRate -> 48000] all the way to the end which if I understand the formula should be impossible as it should peak at around 40kHz. Aug 30, 2021 at 14:41

Along with the fact that the hardware is incapable of very high sampling rates (as described by CL), this is an example of a generic effect called aliasing that happens whenever the sampling frequency is less than half the frequency of the signal (this is called the Nyquist frequency). Here is a Wolfram Demonstration about this effect, and Wikipedia has a good article called aliasing. Here also is a previous Stack Exchange question that addresses the issue.

When I tried this once, I used:

Play[Sin[12000*2 Pi*t], {t, 0, 1}, SampleRate -> 44000]


which is near the top end for most adults. To annoy any teenagers in the same room, I tried:

Play[Sin[15000*2 Pi*t], {t, 0, 1}, SampleRate -> 44000]


and I know that worked, if only because I could hear the speaker starting and stopping.

• I can hear these two, but these are not that kind of sound I mentioned in the question, the sound of the high-frequency code in my question is much lower than these two. Nov 6, 2013 at 10:02
• It's funny that you mention teenagers… Dec 12, 2015 at 14:21
• Ouch! That second one hurts my ears and I'm much older than a teenager... Aug 30, 2021 at 0:18

The membrane may resonate on a lower frequency than what is actually played, fooling you with an audible pitch.