Reflection of sound wave My Textbook says that:

Reflection of sound waves for displacement from a rigid boundary (e.g. closed end of an organ pipe) is
analogous to reflection of a string wave from rigid boundary; reflection accompanied by an inversion i.e.
an abrupt phase change of
$\pi$. This is consistent with the requirement of displacement amplitude to
remain zero at the rigid end, since a medium particle at the rigid end can not vibrate. As the excess pressure and displacement corresponding to the same sound wave vary by $\pi/2$ in term of phase, a displacement minima at the rigid end will be a point of pressure maxima. This implies that the reflected pressure wave from the rigid boundary will have same phase as the incident wave, i.e., a compression pulse is reflected as a compression pulse and a rarefaction pulse is reflected as a rarefaction pulse.

I did not understand the last statement. If the phase change after reflection from a rigid boundary is $\pi$, then shouldn't a rarefaction pulse be reflected as a compression pulse and a compression pulse as a rarefaction pulse, afterall the phase difference between a particle at rarefaction and compression is $\pi$. Where am I wrong? I think I have trouble understand the $\pi$ phase change in the case of sound wave. The same thing was easy to understand in the case of wave on a string. Please clear this confusion!
 A: The answer you seek is actually in the passage.
There are two ways of describing a sound wave: as a variation in pressure wave and as a mean displacement of particles wave as illustrated below.

. . . the excess pressure and displacement corresponding to the same sound wave vary by π/2 in term of phase . . .
. . . a displacement minima at the rigid end will be a point of pressure maxima. . .
So at a rigid boundary there is zero mean displacement whereas the variation in pressure is a maximum.
Which leads on to the statement,
This implies that the reflected pressure wave from the rigid boundary will have same phase as the incident wave, i.e., a compression pulse is reflected as a compression pulse and a rarefaction pulse is reflected as a rarefaction pulse.
If the phase change after reflection from a rigid boundary is π, . . .
This is for the displacement wave not the pressure wave.
Whereas for the pressure wave which is $\pi/2$ out of phase with the displacement wave there is no phase change at a rigid boundary.
A: Considering a wave equation:
$$
y=A\cos(kx-\omega t+\phi_0) \\ \phi=(kx-\omega t+\phi_0)
$$
An abrupt change of $\pi$ in the phase $\phi$ is like putting $A\cos(\phi+\pi)$ instead of  $Acos(\phi)$ which, comes out to be $-Acos(\phi)$
Now, when you look at the graph of one of these sinusoidal functions, you see that the maximas become minimas and those with the value zero stay zero
A: Text book explanations often do tend to be as clear as mud. I think he is referring to π/2, which is the 1/4 wave in which the displacement goes from maximum to zero and the pressure goes from zero to maximum. In a longitudinal pressure wave hitting a barrier, that increase in pressure will send the wave back non inverted as a pressure wave. A wave in a string is normally transverse, which behaves the opposite, sending back an inverted wave as the string swings across like a guitar string at the barrier.
Incidentally, a longitudinal wave that comes to a free end in the medium, (or open end of a pipe) suddenly has no load on it, so the end of the medium overshoots, causing a decompression, which sends back an inverted wave. Hope that's a bit clearer. Also, check out my explanation of whistle physics, here:"https://physics.stackexchange.com/questions/54950/whistle-physics/476504#476504". An organ pipe is just a BIG whistle. He may have also mentioned standing waves. Where the reflected wave is in phase with the incident wave, they add to each other, and produce maximum displacement. Go forward π/2 radians, and they are opposite phase, producing minimum displacement & maximum pressure. The end of a closed pipe (or solid barrier) is like just another pressure point. The wave in an organ pipe is a standing wave, like in the end of a pipe, but in this case open (or normally open).
