I'm trying to solve Burgers' inviscid equation with these initial conditions:
$$u(0,x)= \begin{cases} a, & \text{if $x<0$} \\ b, & \text{if $x>0$} \end{cases}$$
Here is my work so far: $$u(0,x)= \begin{cases} a, & \text{if $x<0$} \\ b, & \text{if $x>0$} \end{cases}$$ $$x(t)= u(0, x(0))t+x(0)$$ $$x(t)=\begin{cases} at+x(0), & \text{if $x<0$} \\ bt+x(0), & \text{if $x>0$} \end{cases}$$
$$t= \begin{cases} \frac1a (x-x(0)), & \text{if $x(0)<0$} \\ \frac1b(x-x(0)), & \text{if $x(0)>0$} \end{cases}$$
If all this is correct, I am a bit confused as to how to put them all together, this was my attempt:
$$u(t,x) = \begin{cases} a, & \text{if $x<at$} \\ \frac xt, & \text{if $at<x<bt$} \\ b, & \text{if $x>bt$} \end{cases}$$
Your solution is correct, assuming $a\le b$. The situation becomes transparent once one sketches the characteristic lines:
However, if $a>b$, the above does not apply. In this case one must be aware that a shock wave forms at the discontinuity, and propagates with the velocity $(a+b)/2$. Hence,
with the solution being discontinuous at $x=(a+b)t/2$.