Using method of characteristics to solve the p.d.e. $u_t + u_x = \sin(x-t)$ given the initial condition $u(x,0) = \sin(x)$

partial differential equationswave equation

I am taking a numerical method P.D.E. class and want to check my numerical solution against the analytic solution but I am going wrong somewhere. I am using the method of characteristics to solve

$$u_t + u_x = \sin(x-t)$$

$$\frac{d u(x(t),t)}{dt} = u_t + \frac{dx}{dt}u_x$$

$$\frac{dx}{dt} = 1 \implies x = t + x_0$$

$$\frac{d u(x(t),t)}{dt} = \sin(x – t)$$

$$\int d u(x(t),t) = \int \sin(x – t) dt$$

I think this integral is where I am going wrong.

$$u (x(t),t) = \cos(x – t) + B$$

Using the initial condition

$$u(x_0,0) = \sin(x_0) = \cos(x_0) + B$$

$$B = \sin(x_0) – \cos(x_0)$$

$$u(x,t) = \cos(x – t) + \sin(x-t) – \cos(x – t)$$

$$u(x,t) = \sin(x-t)$$

This works for the initial condition but the problem also states for the numerical approximation that $u(0,t) = -(1 +t)\sin(t)$ which does not work with my solution.

Best Answer

You are close. Parameterize the line $t=0$ by the initial position parameter $x_0$. Then the characteristic equation for $x$ reads

$$ \frac{dx}{dt} =1, \quad x(0) = x_0 \implies x(t) = t + x_0. $$

Now the characteristic equation for $u$ reads $$ \begin{aligned} \frac{du(x(t),t)}{dt} &= \sin(x(t) - t) = \sin(x_0) \\ u(x(0,0)) &= \sin(x_0). \end{aligned} $$

Notice that everything involving $x_0$ here is independent of $t$; $x_0$ is just an independent parameter that describes where a single characteristic trajectory starts. Solving this ODE yields $u(x(t),t) = (t+1)\sin(x_0)$. To get things in terms of just $x$ and $t$, we solve for $x_0$ and substitute. Indeed, $x_0 = x-t$, so we have $u(x,t) = (1+t)\sin(x-t)$, as desired.