During compression and rarefaction of sound waves, the air molecules in the medium experience changes in pressure and density.
During compression, the particles in the sound wave are forced closer together, leading to an increase in air pressure. This compression results in an increase in the density of the air molecules in that region. Conversely, during rarefaction, the particles in the sound wave spread apart, causing a decrease in air pressure and a decrease in the density of the air molecules in that region.
When air molecules are compressed, their kinetic energy increases as they collide more frequently and with greater force. This increase in kinetic energy corresponds to an increase in temperature. Therefore, during compression, the air molecules heat up.
Conversely, during rarefaction, the air molecules move farther apart, and their collisions become less frequent and less forceful. This results in a decrease in the kinetic energy of the molecules, which corresponds to a decrease in temperature. Therefore, during rarefaction, the air molecules cool down.
In summary, during compression of sound waves, the air is heated up due to the increase in kinetic energy of the air molecules. During rarefaction, the air cools down as the kinetic energy of the air molecules decreases. These temperature changes, however, are relatively small and usually not noticeable in everyday situations unless the sound waves involve extremely high pressures or frequencies.