How does one derive the equation for the speed of sound? In my acoustics books I see
$$c^2 = \frac{\mathrm{d}P}{\mathrm{d}\rho}$$
where $c$ is the speed of sound, $P$ is the pressure and $\rho$ is the density. Where does this equation come from? In my books it appears almost as a definition. Could you explain this, or at least point me to an article or a book that addresses this question? Thanks.
 A: The other answer follows https://www.feynmanlectures.caltech.edu/I_47.html but it is a little lengthy and is still missing a few steps, such as how to find the relative phase between a speaker's position (or whatever thing is producing a sound) and pressure.  The other answer claims that, similar to a hand-waving argument, “This can be used to match any initial conditions of ϕ and ∂tϕ…”  It actually ignores and sort of belittles what these conditions would be.  Entire course sections, such much of electromagnetism, are based on solving boundary conditions and phasor relationships, so it’s also worth deriving for a more complete understanding of sound propagation, and not just stop when we get a somewhat vague speed of sound relation.
Consider a piston capable of pushing a long column of compressible gas, fluid, etc.  Assume at time $t\leq0$ the piston is at rest and is at a distance of $0$ from a support serving mostly as a point of reference.  Then at $t=0$ the piston is quickly accelerated to the right at a speed of $v_p$ (where the $p$ is for piston).  Gas very far to the right will be uncompressed and still at rest, while gas near the piston will be moving at a speed of $v_p.$  By definition the boundary of the pressure discontinuity will be at a distance $tc$ from the piston, where $c$ is the speed of sound.  Here, shown by the green line/circle below, there will be a pressure discontinuity of $\Delta P$:

The distance between the red lines is $v_p t$, so this pictures assumes $c\sim 15v_p.$
It is important to realize that the green line moving at speed $c$ does not correspond to the speed of movement of any bulk gas.  Rather, it is only an imaginary/virtual boundary indicating where the pressure discontinuity occurs, and also where the gas suddenly goes from being stationary to having a speed of $v_p$.
The force the piston has to exert on the gas is just upon the disturbed gas.  It is $F={d\over dt}(p=mv_p),$ where $m$ is the mass of the disturbed gas and $p$ is its momentum.  $=F=\dot{m}v_p+m\dot{v_p}=\rho A c v_p+0$ where $A$ is the cross sectional area of the tube and $\rho$ is the undisturbed density since we can use the gas mass to the left of the green line for gas back in time at $t=0$ to measure it instead of using the pressurized density and current time. But, we don't need to do this since the strain or compression factor is easy to compute.  It's just $${\Delta V\over V}={A(ct-v_p t)-Act\over Act}=-v_p/c,$$ where $V$ denotes volumes.  This strain corresponds to a pressure enhancement of $\Delta P$ only on the disturbed gas' left side.  This gives the disturbed gas a force of
$$F=\Delta P A=\rho A c v_p$$
all of which goes into accelerating just the newly disturbed gas.
The purpose of the above scenario is to see things slowed down, but in real applications we are more likely to be dealing with high frequency (~1 kHz) oscillations. In this situation, we can assume adiabatic compression, where $PV^\gamma=$ constant. Taylor expanding this relationship gives $\Delta P/P=-\gamma \Delta V/V.$  Using this to eliminate $\Delta P$ from the force equation gives
$$F= -\gamma {\Delta V\over V} P A = \gamma {v_p\over c} P A = 
\rho A c v_p$$
$$c^2={\gamma P\over \rho}$$
$$c=\sqrt{\gamma R_s T}=\sqrt{\gamma kT/\bar m},$$
where I've used a gas law popular in chemistry to eliminate the density. As a check, for air we have $\gamma=1.4,$ $R_s=\rm 8.314463 J·K^{−1}·mol^{−1} / (0.02896 \ kg \ mol^{-1})$, $T=270 \rm K$, so $c$=737 miles per hour vs. 767 mph from the Google snippet.
Thus far we assumed $v_p(t)\propto u(t),$ where $u$ is the step function.  If, instead, $v_p(t)=v_{p0}\sin(wt=2\pi t/T),$ as in a traditional source of sound like a speaker or a tuning fork, what would then happen?  From the above analysis, we know that the pressure wave intensity scales with the speed of movement compared to the speed of sound.  Thus, instead of the pressure being in phase with, e.g., position, it would instead be in phase with its derivative, the speed; when a speaker is closest to you, it's producing the least sound.  Moreover, the pressure wave would could not follow the prior analysis far from the piston.  Rather, it would have to be capped in right-most physical extent, size, and vibrating air mass at a distance or wavelength of $\lambda=cT$ from the piston; the smooth pressure shape (no longer a sharp discontinuity) would, in the linear regime, still retain the same rightward propagation speed, but as one moves further away it would obtain a time retardation of $x/c=xk/w$ with $\Delta P=\Delta P_0\sin(wt-kx)=-\Delta P_0\sin(kx-wt),$ where $-kx$ reveals that the distant listener hears old vibrations.
Of course, any arbitrary repeating function can be expanded in a Fourier series (https://en.wikipedia.org/wiki/Fourier_series), and this is the only required component for it. Thus, via superposition we can remove the piston and replace it with any sound source instead and get the same result assuming linearity. By contrast, non-linear effects from, e.g., $v_p\simeq c$, $\omega\simeq 0$ (non-adiabatic), etc. might also be possible in which case this isn’t necessarily true and there could be, e.g., frequency-dependent propagation speed.
If you use this derivation of the speed of sound please be kind enough to give me credit although my contributions to the core idea were not that significant.
A: This derivation is often neglected, because it is slightly involved (for an ungergraduate presentation) in Newton's way of thinking, with explicit forces, although this is how Newton did it, and it is a little too trivial if you use stress tensor concepts. I will use the stress tensor concept.
Momentum is a conserved quantity, and you should be familiar with the conservation law in differential form:
$$ \partial_t \rho + \partial_i J^i = 0 $$
Where the repeated i index is summed (Einstein convention). This is clearest in space-time, where the density $\rho$ becomes the time component of a 4-vector, but it is just as true in Galilean Newtonian mechanics.
For momentum, you have three separate conserved momentum densities $p^i$ which obey a conservation law:
$$ \partial_t p^j + \partial_i T^{ij} = 0 $$
Where the interpretation of $T^{ij}$ is that it is the flow of the i'th component of p in the j direction. There are three equations, since there are three separate conserved quantities--- the x,y,z momentum.
If you compress a region of air, you get a little bit more pressure. The form of pressure is a diagonal stress density, by rotational symmetry (it is also intuitive--- pressure pushed out--- so x-momentum goes in the x direction, y-momentum goes in the y-direction and so on).
The stress T for a pressure is therefore
$$ T^{ij} = P(\rho) \delta^{ij} $$
If the material starts out at position x (at each x there is a different infinitesimal volume of material) and the material which would be at x when everything is still is moved at time t to x+\delta X(x,t), then the momentum density is
$$ p^{i} = \rho {\partial_t X(x,t)}$$
Assuming $\rho = \rho_0(1 - \delta v)$ where the infinitesimal volume compression, which gives the change in the density, is given by the divergence of X (this is geometrically clear if you draw a picture, or just from the definition of divergence)
$$\delta v = \partial_j X^j $$ 
To first infinitesimal order, then the pressure is
$$ P (\rho) = P(\rho_0) - C\delta v = P(\rho_0) - C \partial_i X^i $$
Where $ C= {dP\over d\rho}$
Now, for mathematical convenience (I do not want to deal with transverse sound), consider reducing to one dimension. In this case X(x) is just a one-dimensional function that tells you the displacement, and the stress is just $T^{11} = \rho_0 \partial_x X$ (the flow of x-momentum in the x-direction).
The continuity equation in 1d gives you
$$ \rho_0 \partial^2_t X - \rho_0 C \partial^2_x X = 0 $$
And this is the wave equation with the speed of sound squared equal to C. You can repeat the 1d analysis with detailed forces, not using the slightly more abstract continuity equation, and this is what Newton did to find the speed of sound way back when.
To see that the one dimensional equation above describes waves moving with a speed $\pm \sqrt{C}$, consider the functional form of such a wave moving with velocity c:
$$ \phi(x,t) = f(x-ct) $$
where f is a function of one dependent variable. Differentiate twice in time
$$ \partial^2_t \phi = c^2 f'' $$
and twice in space:
$$ \partial^2_x \phi = f'' $$
and you see that it satisfies the wave equation:
$$ \partial^2_t \phi - c^2 \partial^2_x \phi = 0 $$
The general solution to the 1d equation can be expressesed as the sum of a left-moving and a right-moving wave. This can be used to match any initial conditions of $\phi$ and $\partial_t\phi$, and is therefore the general form. You can derive the general solution from a systematic general theory using Fourier transforms, by considering plane waves.
