The speed of sound depends on the elasticity and density of the medium through which it is traveling. In general, sound travels faster in liquids than in gases and faster in solids than in liquids. The greater the elasticity and the lower the density, the faster sound travels in a medium. The mathematical relationship is speed = (elasticity/density).
The effect of elasticity and density on the speed of sound can be seen by comparing the speed of sound in air, hydrogen, and iron. Air and hydrogen have nearly the same elastic properties, but the density of hydrogen is less than that of air. Sound thus travels faster (about 4 times as fast) in hydrogen than in air. Although the density of air is much less than that of iron, the elasticity of iron is very much greater than that of air. Sound thus travels faster (about 14 times as fast) in iron than in air.