Longitudinal Waves - how velocity varies with density The formula for finding the velocity of a longitudinal wave, such as a sound wave, is:
$$v = \sqrt{\frac{E}{\rho}}$$
Where $v$ represents the velocity, $E$ represents the elasticity of the medium, and $\rho$ represents the density of the medium.
From this formula, it is obvious that velocity is inversely proportional to the square root of the density of the medium. It means that if the density increases, the velocity decreases.
However, isn't the opposite true for sound waves? As the density of the medium increases, the velocity of sound actually increases. For example, sound travels faster in water than in air. Please explain why this is so.
 A: Your parameter $E$ is the bulk modulus, and this is a measure of how compressible the medium is. Easily compressible media like gases have a low value of $E$ while almost incompressible fluids like water have a very high value for $E$. Actually we should really use the symbol $K$ rather than $E$, because $E$ is normally used for the Young's modulus.
And there is the answer to your question. Water does indeed have a higher density than air (by a factor of about 800) but it is much, much less compressible than air so the value of $E$ is around 20,000 times higher. The end result is that the value of $E/\rho$ is higher in water than air so the speed of sound is greater.
Strictly speaking your equation applies only to gases and liquids. In solids you also need to take account of the shear modulus, and the expression becomes:
$$ v = \sqrt{\frac{K + \tfrac{4}{3}G}{\rho}} $$
where K and G are the bulk modulus and shear modulus respectively. See Why does sound travel faster in iron than mercury even though mercury has a higher density? for more details.
