How can I find the solution of the Hopf equation $u_t + u u_x = 0$ with the initial condition $u(0,x) = \rho(x)$? Here, $\rho$ is equal to:
\begin{align}{\rho(x) = }
\begin{cases} 
a & x<0 \\ 
\frac{a}{L} (L-x) & 0 \le x \le L \\
\frac{a}{L} (x-L) & L < x < 2L \\
a & x \ge 2L 
\end{cases}
\end{align}
So, basically, we have something like this in the very beginning for $u(t,x)$ at $t=0$:

And as it's a Hopf Equation, this should "collapse" rightwards.
But how are we supposed to find the solution for this PDE?
Our Prof gave us various methods, and I'm a little bit confused because of it.
Method 1
As the solution for this Cauchy problem looks like this $$u(t,x) = \rho (x - t  u)$$ we shall simply replace $x$ with $x-tu$ in our $\rho$, so we get:
\begin{align}{u(t,x) = \rho(x-tu)=}
\begin{cases} 
a & (x-ut)<0 \\ 
\frac{a}{L} (L-(x-ut)) & 0 \le (x-ut) \le L \\
\frac{a}{L} ((x-ut)-L) & L < (x-ut) < 2L \\
a & (x-ut) \ge 2L 
\end{cases}
\end{align}
And then we should, for each line, replace what we have for u (in the first and last line, we just use $u=a$, in the second, we have to solve $u = \frac{a}{L} (L-(x-ut))$ for u, analogically for the third line) and then we use this to find out the conditions for $x$ (so in the first line, it's $x - at < 0$ thus $x < at$).
I get:
\begin{align}{u(t,x) = \rho(x-tu)=}
\begin{cases} 
a & x<at \\ 
\frac{a(L-x)}{L-ta} & \frac{aL}{L-ta+a} \le x \le \frac{L(L-ta)+aL}{L-ta+a} \\
\frac{a(x-L)}{L+ta} & \frac{L(L+a)-aL}{L+ta-a} < x < \frac{2L(L+ta)-aL}{L+ta-a}\\
a & x \ge 2L + at
\end{cases}
\end{align}
The only problem here is that the animation in Mathematica doesn't seem to get it right, so either I've made a mistake in my calculations or it's the wrong method to find the solution of that Cauchy problem.
Method 2
I don't even know why my Profesor was doing this, but what he did was to predict when the left edge of this "triangle" will because a vertical line. But for this, we need to know the velocity of each of the "vertices" of that triangle. Let's say the left vertex is $A$, the one on the x axis is $B$ and the right one is $C$.
So what we want is this:
$$v_A \cdot t_1 = x_0 (B) + v_B \cdot t_1$$
We know that $x_0 (B) = L$, so this means that:
$$t_1 = \frac{L}{v_A - v_B}$$
That's the time where our $u$ will change to this kind of function (for $t_2 > t_1$):
\begin{align}{\bar{u}(t,x) = }
\begin{cases} 
a & x<v_A \cdot t_2 \\ 
\frac{x}{t_2} & v_A \cdot t_2 \le x \le x_f \\
a & x \ge x_f
\end{cases}
\end{align}
where $x_f = \sqrt{2Qt_2}$, where $Q$ is the area of that triangle in the beginning ($Q = \frac{1}{2} \cdot 2L \cdot a = L \cdot a$).
But we also know that $x_f = v_C \cdot t_2$ here, which means that we can find our $t_2$ (but I don't know what kind of an interpretation this $t_2$ has).
So the problem I have with this method is that:

*

*I don't know the velocities of $v_A, v_B, v_C$


*It's just like a partial solution for those $t$ after that triangle changed its structure


*I don't know why we were calculating that $t_2$ in the lecture, and why we always immediately took $\frac{x}{t_2}$ as the function here

So in short, I don't know what I should do here. The Professor method's are kind of confusing for me.
I hope you can help me here.
 A: These are not 2 different methods, but two steps in a solution.
The first tells that the solution is constant along the characteristic lines $x(t)=x_0+t·u_0$ as long as these do not cross.
In the second step it is explored where the characteristics cross, and what happens there. The difference between two characteristics is $\Delta x_0+t\Delta u_0$, so the cross-over happens at $t=-\frac{\Delta x_0}{\Delta u_0}$, so in the limit $\Delta x_0\to 0$ at $t=-\rho'(x_0)^{-1}$, if $\rho$ is differentiable with negative derivative around $x_0$.
This happens on the segment $[0,L]$. As $\rho$ is linear there, all the rays from that segment meet at the same point $x_S(t_1)=L$ at the same time $t_1=\frac{L}{a}$. After that from this point on you have a shock that travels with the average velocity $x_S'(t_1)=v_S(t_1)=\frac{a}2$ of the characteristics that meet there.
The characteristic rays from the raising segment on $[L,2L]$ move slower than the rays from $x_0<0$, so they will cross at the shock. At the cross point $x_S(t)$ at time $t$ will meet rays from $x_{0,1}=x_S(t)-a·t$ and
$$
x_S(t)=x_{0,2}+(\frac{a}{L}x_{0,2}-a)t
\iff
x_{0,2}=\frac{x_S(t)+at}{1+\frac{a}{L}t}.
$$
The velocity of the shock is again the mean of both, so
$$
x_S'(t)=v_S(t)
=\frac12\left(a+\frac{a}{L}\frac{x_S(t)+at}{1+\frac{a}{L}t}-a\right)
=\frac{a}{2}\frac{x_S(t)+at}{L+at}
\\~\\
\frac{d}{dt}\frac{x_S(t)}{\sqrt{L+at}}=\frac{a^2t}{2(L+at)^{3/2}}
$$
Solving this linear ODE gives
$$
\frac{x_S(t)}{\sqrt{L+at}}=\sqrt{L+at}+\frac{L}{\sqrt{L+at}}+C
\\
x_S(t)=(2L+at)-\sqrt{2L(L+at)}
\\
v_S(t)=a-\frac a2\sqrt{\frac{2L}{L+at}}
$$
Note that $2L+at$ is the characteristic curve starting at $x_0=2L$, so that the shock does not intersect any ray starting at $x_0\ge 2L$.
