# Behavior of the solution to the inviscid Burgers' equation

Consider the inviscid Burgers' equation $$u_t+uu_x=0$$ with the initial condition $$u_0=\begin{cases} 0, & x<0\\ x, & 0\leq x \leq 1\\ 1, & x>1 \end{cases}$$

I tried to implement numerical method to solve this and I got this solution:

Can somebody pls explain the behavior of this solution? I got the following characteristics:

The method of characteristics gives the solution $$u = u_0(x-ut)$$, where $$u_0$$ is the initial data. In the present case, we have
• $$u=0$$ if $$x-0\cdot t\leq 0$$;
• $$u=1$$ if $$x-1\cdot t\geq 1$$;
• $$u=x-ut$$ i.e. $$u=x/(1+t)$$ otherwise;
so that u(x,t) = \left\lbrace \begin{aligned} &0 & & \text{if}\quad x \leq 0 ,\\ &\tfrac{x}{1+t} & & \text{if}\quad 0 \leq x \leq 1+ t ,\\ &1 & & \text{if}\quad 1+ t \leq x . \end{aligned} \right. The previous analysis seems consistent with the numerical results in OP, up to the right boundary $$x=3$$ where a Dirichlet boundary condition may have been implemented. An outflow boundary condition would be more appropriate.