# Correctly solving this PDE using the method of characteristics

I am trying to solve

$$PDE: - \frac{\partial f}{\partial t} + x \frac{\partial f}{\partial x} = x \\ IC : f(t_{max},x) = h(x)$$ using the method of characteristics. I attempted to follow the usual steps. First, parametrize the initial condition $$(t,x) \rightarrow (s, \tau), t=t_{max}, s=0, x=\tau, f(0,\tau) = h(\tau)$$ Second, convert the PDE to the system of ODEs by taking $$\frac{\mathrm{d}f}{\mathrm{d}s} = \frac{\partial f}{\partial t} \frac{\mathrm{d} t }{\mathrm{d} s} + \frac{\partial f}{\partial x} \frac{\mathrm{d} x }{\mathrm{d} s}$$ and identify the ODEs to be $$\frac{\mathrm{d} t }{\mathrm{d} s} = -1, \hspace{3pt} \frac{\mathrm{d} x }{\mathrm{d} s} = x, \hspace{3pt} \frac{\mathrm{d}f}{\mathrm{d}s} = x$$ Third, solve the ODEs using the parametrized initial conditions $$t = -s + \psi(\tau) \implies t = -s + t_{max} \\ \ln(x) = s + \psi(\tau) \implies x = \tau e^s \\ f = \tau e^s + \psi(\tau) \implies f(s,\tau) = \tau e^s - \tau + h(\tau)$$ Lastly, go back to the original coordinates via $$s = t - t_{max}, \hspace{3pt} \tau = x \exp\left(-(t-t_{max})\right) \\ f(t,x) = x \exp\left(-(t-t_{max})\right) \exp(t - t_{max}) - x \exp\left(-(t-t_{max})\right) + h(x \exp\left(-(t-t_{max})\right)) \implies \\ f(t,x) = x \left[1 - \exp(-(t-t_{max})\right] + h(x \exp\left(-(t-t_{max})\right))$$ Inserting $$t=t_{max}$$ in this solution does result in the initial condition of $$h(x)$$. However, setting the initial condition to be $$h(x)=x^2$$, taking the derivatives w.r.t. $$t$$ and $$x$$ of the found solution and introducing them back into the original PDE does not result in a correct equality.

Thus, my question is how do I correctly solve this PDE using the method of characteristics (or some other method such as eigenfunction expansion)?

$$- \frac{\partial f}{\partial t} + x \frac{\partial f}{\partial x} = x$$ Lagrange-Charpit characteristic ODEs : https://en.wikipedia.org/wiki/Method_of_characteristics $$\frac{dt}{-1}=\frac{dx}{x}=\frac{df}{x}=ds\qquad\Leftrightarrow\qquad\begin{cases} \frac{dt}{ds}=-1\\ \frac{dx}{ds}=x\\ \frac{df}{ds}=x \end{cases}$$ A first characteristic equation comes from solving $$\frac{dt}{-1}=\frac{dx}{x}$$: $$x\:e^t=c_1$$ A second characteristic equation comes from solving $$\frac{dx}{x}=\frac{df}{x}$$ : $$f-x=c_2$$ The general solution of the PDE expressed on the form of implicit equation $$c_2=F(c_1)$$ is : $$f-x=F(x\:e^t)$$ $$F$$ is an arbitrary function (to be determined according to the initial condition). $$\boxed{f(t,x)=x+F(x\:e^t)}$$ Initial condition : $$f(t_{max},x) = h(x)$$
$$f(t_{max},x)=x+F(x\:e^{t_{max}})=h(x)$$ Let $$\quad X=x\:e^{t_{max}} \quad\implies\quad x=X\:e^{-t_{max}}$$ $$X\:e^{-t_{max}}+F(X)=h(X\:e^{-t_{max}})$$ $$F(X)=h(X\:e^{-t_{max}})-X\:e^{-t_{max}}$$ Now the function $$F(X)$$ is known. We put it into the above general solution where $$X=x\:e^t$$ . Thus $$F(x\:e^t)=h(x\:e^t\:e^{-t_{max}})-x\:e^t\:e^{-t_{max}}=h(x\:e^{t-t_{max}})-x\:e^{t-t_{max}}$$ $$f(x,t)=x+\big(h(x\:e^{t-t_{max}})-x\:e^{t-t_{max}}\big)$$ $$\boxed{f(x,t)=h(x\:e^{t-t_{max}})+\left(1-e^{t-t_{max}}\right)x}$$ This is the function which satisfies both the PDE and the IC.