I have been studying PDEs using Peter Olver's textbook. I have learnt how to solve equations such as $u_t + 2u_x = \sin(x)$ subject to an initial condition such as $u(0,x) = \sin x$. Letting $\epsilon = x - 2t$ and $u(t,x) = v(t,\epsilon)$, I then plug this into the transport equation.
However, I am not sure how to define a characteristic to solve the following equation
$$u_t + xu_x + u = 0, \qquad u(x_0, 0) = \cos(x_0)$$
because it has a variable 'speed' term $x$ and it is also not homogenous because of the term $u$.
A solution would be very helpful so I can see how to approach these problems.
$$u_t + xu_x = -u$$ $\frac{dt}{1}=\frac{dx}{x}=\frac{du}{-u}$
First characteristics, from $\quad \frac{dt}{1}=\frac{dx}{x}$ :
$$x\,e^{-t}=c_1$$
Second characteristics, from $\quad\frac{dx}{x}=\frac{du}{-u}$ : $$x\,u=c_2$$ General solution of the PDE : $\quad x\,u=F(x\,e^{-t})$
$$u(x,t)=\frac{1}{x}F(x\,e^{-t})$$ $F$ is an arbitrary function, to be determined according to the boundary condition.
Condition : $\quad u(x_0, 0) = \cos(x_0)=\frac{1}{x_0}F(x_0\,e^{0})$
$F(x_0)=x_0\cos(x_0)$. Now the function $F$ is determined, i.e.: $F(X)=X\cos(X)$.
We put it into the above general solution , where $X=x\,e^{-t}$ , thus $F(x\,e^{-t})=(x\,e^{-t})\cos(x\,e^{-t})$ :
$$u(x,t)=\frac{1}{x}(x\,e^{-t})\cos(x\,e^{-t})=e^{-t}\cos(x\,e^{-t})$$