Solve this PDE equation

partial differential equations

(I never had a PDE course unfortunately, but this problem came up from some physical problem.)

Solve for $g(x,t)$, where:
$$\frac{\partial{g(x,t)}}{\partial t} + \frac{\partial}{\partial x}\left(g(x,t)\frac{-x}{a}\right)=0$$
with some initial condition $g(x,0) = f(x)$, and constant $a$.

Mathematica tells me its solution should be $g(x,t)=e^{t/a} f(x e^{t/a})$, but I would like to know how to solve it myself too. How to do it? Or can you point me in the right direction?

Edit: you suggested separating variables $g(x,t)=\psi(x)\phi(t)$. This gives the following:
$$\frac{\partial\ln{\phi(t)}}{\partial t} = \frac{\partial}{\partial x} \left(\psi(x) \frac{x}{a}\right)$$
How to continue from here then? The final answer does not look immediately separable to me either…

Best Answer

$$\frac{\partial{g(x,t)}}{\partial t} + \frac{\partial}{\partial x}\left(g(x,t)\frac{-x}{a}\right)=0$$ $$\frac{\partial{g(x,t)}}{\partial t}-\frac{x}{a}\frac{\partial{g(x,t)}}{\partial x}=\frac{1}{a}g(x,t)$$ By luck, the method of separation of variables is perfect in this case, according to the initial condition $g(x,0)=f(x)$. But this is not always so simple.

Alternatively one can use the method of characteristics in order to find not only some particular solutions, but the general solution.

The Charpit-Lagrange system of equations is: https://en.wikipedia.org/wiki/Method_of_characteristics

$$\frac{dt}{1}=\frac{dx}{-x/a}=\frac{dg}{g/a}$$ This easily leads to two characteristic equations : $$\frac{dt}{a}+\frac{dx}{x}=0\qquad\to\qquad xe^{t/a}=c_1$$ $$\frac{dt}{a}-\frac{dg}{g}=0\qquad\to\qquad ge^{-t/a}=c_2$$ The general solution is : $\quad ge^{-t/a}=F(xe^{t/a})\quad$ where $F$ is an arbitrary function. $$g(x,t)=e^{t/a}F(xe^{t/a})$$ The arbitrary function $F$ is no longer arbitrary when the initial condition is specified : $$g(x,0)=f(x)=e^{0/a}F(xe^{0/a})=F(x)$$ This is why this case is so simple $F(x)=f(x)$ and the result is $$g(x,t)=e^{t/a}f(xe^{t/a})$$