Solution (source code)

= Solution

In smooth regions the characteristic equations are $\dot x=q'(\rho)=\rho^3$ and $\dot\rho=0$. If $\xi$ labels the initial point, their parametrization is
$$
x=\xi+\rho_0(\xi)^3t,\qquad\rho=\rho_0(\xi).
$$
For the two constant states, characteristics from the left have speed one and those from the right speed zero; they would overlap. The <entropy solution> replaces the overlap by a compressive <shock>. Its speed is
$$
c=\frac{q(1)-q(0)}{1-0}=\frac14.
$$
Thus
$$
\boxed{\rho(x,t)=\begin{cases}1,&x<t/4,\\0,&x>t/4,\end{cases}\qquad S(t)=t/4.}
$$
The left parametrization $x=\xi+t$ is retained only for $x<t/4$, and the right parametrization $x=\xi$ only for $x>t/4$. The <characteristic speeds> obey $0<c<1$, so characteristics enter the <shock> from both sides.