The deserts of New Mexico can get blazingly hot and bone-chillingly cold, extremes of temperature familiar to the outdoorsman in that kind of terrain. A few hundred feet below the ground in Carlsbad Caverns, the temperature is essentially stable in the mid-50s no matter how scorching or frigid the air a few feet above happens to be.

You can think of the earth’s surface in New Mexico as subject to two superimposed sinusoidal periodic heat pulses. One has a period of 24 hours and corresponds to the heat rising and falling over the day/night cycle. The other has a period of 1 year and corresponds to the average heat changing through the seasons. Clearly this approximation is quite rough, but we can take it as a starting point for some mathematical spelunking of our own. There’s some math, but you can skim over it if you wish without missing the result.

We’ll need the heat conduction equation as our first piece of caving equipment. It says that the rate of change of temperature at a given point is proportional to how different it is from the average temperature of its surroundings. We also have the proportionality constant k to measure the ease with which temperature flows:

To get the temperature below ground level we also need to give the boundary condition – ie, the temperature at ground level. We assume it’s just the temperature T0 multiplied by an oscillating function. (T0 is the size of the oscillation.) We’re going to take the real part of an oscillating exponential for mathematical convenience:

Now this is a differential equation and boundary condition, and we’d like to solve it as painlessly as possible. One of the best ways is to start with an educated guess – try it out, and if it works you’re done. If it doesn’t, try something else. Let’s assume that the solution giving the temperature as a function of time and depth is an oscillating function of time multiplied by some function of depth z.

Jam that into our original differential equation and see what happens:

This is what we in the business call an “ordinary” differential equation, and they’re easy to solve if you’ve done it a few times. Teaching it from scratch would take us too far afield, so let’s just say we did a few more lines of work and arrived at the solution:

Where for convenience we’ve defined delta as:

This has to match the boundary condition given at the start, so we end up seeing that A = T0. which leads to a final answer:

Ok, let’s interpret this. We have an oscillating term, which indicates that the subsurface temperature goes up and down as the temperature outside cycles. But it’s damped by an exponential factor – so the further down you go, the smaller the variations about the average are. There’s a “typical depth” given by delta which says how far the variations reach. At that point the variations are only about 37% of their surface magnitude. At twice that depth the variations are only 14%, and very quickly falling off from there.

Further, this depth is dependent on the frequency of the oscillations. The depth increases with decreasing frequency. In other words, the daily changes will not penetrate as far as the seasonal changes. Even more weirdly, there’s a phase factor in the cosine term – there will be a lag between the maximum temperature at the surface and the maximum temperature at depth. But let’s plug in some numbers to get a feel for what actually might be happening under the ground at Carlsbad. The thermal diffusivity of limestone is about 1e-6 m^2/s. Plugging in for the daily variation, delta is about… 16 centimeters. Below even that small amount of rock, the temperature is pretty constant all other things being equal. It’s one of the reasons burrowing animals can survive in the inhospitable desert.

The yearly variation has a much smaller frequency and thus penetrates deeper. I calculate the penetration depth is about 3.16 meters. Below that however, as many caves are, neither the daily nor seasonal variation makes a dent in that otherwise constant average temperature. Incidentally, the phase delay at 3.16 meters is about 2 months for the yearly variation – the warmest time of the year at that depth is actually about 2 months later than the warmest time of year above ground.

(Note: This fascinating example taken mostly from the excellent textbook by Fetter and Walecka)