Can you help me to solve this problem and explain the method used?
$u\equiv u(x,t)$ with $x\in\mathbb{R}$
$$ u_t+\left( \frac{1}{2}u^2\right)_x=0 $$ with initial data
$$u_0(x)=u(x,0)= \begin{cases} 1-x^2, &\text{for } x\in [-1,1] \\\\ 0, &\text{else} \end{cases} $$
I tried to find $u$ using $u=u_0(x-ut)$ but I don't get the solution. In particular with the boundary conditions.
Thanks for your help.
EDIT: Solving with the characteristics method I find this solution $$u(x,t)=1-\left( \frac{1\pm \sqrt{(1-4\chi t (x-\chi t)}}{2\chi t} \right)^2$$ where $\chi\equiv\chi_{[-1,1](x)}$ Solving with Upwind scheme for Burgers's equation the solution does not agree with the numerical one.


I will be using method of characteristics (which is described in Wikipedia article for Burger's euqation in detail).
Writing down the equation:
$$\frac{\partial u}{\partial t}+u\frac{\partial u}{\partial x}=0$$
This has the form of a full time derivative for some function:
$$\frac{du}{dt}=\frac{\partial u}{\partial t}+\frac{\partial u}{\partial x} \frac{dx}{dt}$$
Which gives us the following system of ODEs:
$$\frac{du}{dt}=0 \\ \frac{dx}{dt}=u$$
The solutions have the form:
$$u=u_0 \\ x=x_0+u_0 t$$
This seems surprising, but actually this means that for any $x$:
Now we want to get an explicit solution using our initial conditions.
Let's make a substitution:
$$x+(1-x^2)t=y$$
We need to find $x(y,t)$ now to substitute on the right hand side of $(1)$:
$$t x^2-x+y-t=0$$
Which makes our solution in this range to be:
$$u(y,t)=1-\frac{1}{4t^2} (1 \pm \sqrt{1+4t(t-y)})^2$$
Or, simply renaming the variable again, we have:
You can directly check (by taking the derivatives) that the original equation is satisfied by this function.
One thing we need to account for is the range $|x| \leq 1$ which separates the first solution from the second one. Not sure if we just can set the same condition on $y$ or not.
Let's consider the condition on $x$:
$$\left| \frac{1}{2t} (1 - \sqrt{1+4t(t-y)}) \right| \leq 1$$
Assume $t>0$:
$$\left| 1 - \sqrt{1+4t(t-y)} \right| \leq 2t$$
The solution is quite interesting:
$$-1 \leq y \leq 1, \qquad t \leq \frac12$$
$$-1 \leq y \leq \frac{4t^2+1}{4t}, \qquad t > \frac12$$
The latter case contradicts the initial condition on $x$ which we used to get our first, zero solution.
When plotting the solution in Mathematica for different times we see a 'crashing wave', which initially, doesn't go beyond $x=1$.
However, for larger times, it does go beyond the initial boundary: