# Inviscid Burgers' equation solution

I managed to understand the method of characteristics to get the solution of the transport equation. However, I am getting stucked finding the final solution for the Burgers' equation $u_t + u u_x = 0$ given the following initial solution

$$u_0(x) = \begin{cases} 0, & x < -1 \\ 1+x, & -1 < x < 0 \\ 1-x, & 0 < x < 1 \\ 0, & 1 < x \\ \end{cases}$$

The solution I get is of the form

$$u(x,t) = u(x-u_0(x)t)$$

and according to my calculations this gives

$$u(x,t) = \begin{cases} 0, & x < -1 \\ (1+x)(1-t), & -1 < x < \frac{t}{1-t} \\ (1-x)(1+t) & \frac{t}{1+t} < x < 1 \\ 0, & 1 < x \\ \end{cases}$$

which does not matches with the correct answer in my notes. Can anyone explain me how to do this correctly?

The peak at height $$u=1$$ travels with speed equal to $$1$$, so you should have $$u(x,t)=1$$ when $$x=t$$, and since the inviscid Burgers equation has the property that a piecewise linear wave profile stays piecewise linear (as can be seen by looking at the characteristic curves), the wave profile $$u(x,t)$$ for a fixed $$t \in (0,1)$$ (before shock formation) is simply given by connecting the point $$(x,u)=(-1,0)$$ with a straight line to $$(x,u)=(t,1)$$, and from there to $$(x,u)=(1,0)$$ with a straight line. (And $$u=0$$ outside the interval $$-1, of course.)