Transport equation $u_t + xu_x + u = 0$ with $u(x_0, 0) = \cos(x_0)$ 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. 
 A: Let us apply the method of characteristics. We get the characteristic equations
$$
\frac{\text{d} t}{\text{d} s} = 1 \, , \qquad
\frac{\text{d} x}{\text{d} s} = x \, , \qquad
\frac{\text{d} u}{\text{d} s} = -u \, .
$$
Letting $t(0) = 0$, we know $t=s$. Letting $x(0) = x_0$, we get $x(t) = x_0\, e^t$. Since $u(0) = \cos(x_0)$, we have $u(t) = \cos(x_0)\, e^{-t}$. Finally,
$$
u(x,t) = \cos(x\, e^{-t})\, e^{-t} \, .
$$
A: $$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})$$
A: Note that
\begin{align}
\frac{\rm d}{{\rm d}t}u(e^t,t+t_0)&=\frac{\partial u}{\partial t}(e^t,t+t_0)+e^t\frac{\partial u}{\partial x}(e^t,t+t_0)\\
&=\left(\frac{\partial u}{\partial t}+x\frac{\partial u}{\partial x}\right)(e^t,t+t_0)\\
&=-u(e^t,t+t_0)
\end{align}
holds for all $t$ and $t_0$. Thus
$$
\frac{\rm d}{{\rm d}t}u(e^t,t+t_0)+u(e^t,t+t_0)=0,
$$
or equivalently,
$$
\frac{\rm d}{{\rm d}t}\left(e^tu(e^t,t+t_0)\right)=0.
$$
Therefore,
$$
e^tu(e^t,t+t_0)=e^{-t_0}u(e^{-t_0},-t_0+t_0)=e^{-t_0}u(e^{-t_0},0)=e^{-t_0}\cos e^{-t_0},
$$
or equivalently,
$$
u(e^t,t+t_0)=e^{-t-t_0}\cos e^{-t_0}.
$$
Finally, let $x=e^t>0$ and $\tau=t+t_0$. This gives $t=\log x$ and $t_0=\tau-\log x$. Hence
$$
u(x,\tau)=e^{-\log x-\tau+\log x}\cos e^{-\tau+\log x}=e^{-\tau}\cos\left(e^{-\tau}x\right).
$$
