3

I'm trying to plot the characteristics for the following PDE with initial conditions:

$$u_t +uu_x =0$$ where $$u(x,0)= \begin{cases} a \quad \text{for}\quad x<-1,\\ b \quad \text{for}\quad {-1}<x<1,\\ c \quad \text{for}\quad x>1. \end{cases}$$

I'm first trying to plot for the case where $a>b>c$. I understand what the plot should look like, however, I've so far been unable to produce it in MAPLE. Does anyone have any help to do this?

Arctic Char
  • 16,972
user45503
  • 209
  • 2
  • 11

1 Answers1

1

In the present case, the method of characteristics leads to the curves $x = x_0 + \phi(x_0) t$, where $\phi = u(\cdot,0)$ is the initial data. Along these curves, we have $u = \phi(x_0)$. Let us plot those curves for several values of $x_0$:

phi := x -> piecewise(x<-1, 3, -1<x and x<1, 2, 1<x, 1);
xmin,xmax,tmax,n := -2, 2, 1.2, 30:
x0 := k -> xmin + (xmax-xmin)*(k-1)/(n-1):
plot({seq([x, (x-x0(k))/(phi(x0(k))+1e-14), x=xmin..xmax], k=1..n)}, x=xmin..xmax, t=0..tmax, color=["Black"], labels=["x","t"]);

Output:

characteristics

See also the Matlab version in this post.

EditPiAf
  • 21,328