Q. What determines whether one should use heat or ice to treat muscle and joint pain, especially after exercise?

A. Cold therapy, or cryotherapy, is usually recommended in the immediate aftermath of an acute injury, like a severe bruise or sprain, not mere soreness. The familiar RICE sequence — rest, ice, compression and elevation — helps reduce the pain and inflammation of such an injury. It loses efficacy after a day or so, however, and then gentle warming can help.

For the lingering muscle pain that emerges some time after vigorous exercise, called delayed onset muscle soreness, heat and cold have been used with success in individual cases, but scientific studies comparing the efficacy of treatments have been sparse and inconclusive.

A new comparison, published this year in The Journal of Strength and Conditioning Research, looked at muscle damage and pain in 100 people of comparable fitness. Half received either cold or heat treatment after 15 minutes of leg squats and half received no treatment. The researchers concluded that both heat and cold appeared to be effective in reducing muscle damage, but cold used immediately after exercise or 24 hours later was superior in reducing pain. question@nytimes.com