Solving $tu_t + u_x = x$, $u(t,0) = t^2$ I wish to solve
$$tu_t + u_x = x, \quad u(t,0) = t^2.$$
Using the method of characteristics, I parameterize each variable by $r$ and $s$ to obtain the following system of ODEs:
$$\frac{dt(r,s)}{ds} = t\\
\frac{dx(r,s)}{ds} = 1\\
\frac{du(r,s)}{ds} = x$$
with initial conditions
$$x(r,0) = 0\\
t(r,0) = r\\
u(r,0) = r^2.$$
Solving the system of ODEs I have
$$t = c_1e^s\\
x = s+c_2\\
u = xs + c_3$$
which after accounting for the initial conditions results in
$$x = s\\
t = re^s = re^x\\
u = xs+ r^2 = x^2 + (te^{-x})^2.$$
However, plugging in my solution $u$ into the original PDE I do not retrieve $x$ and I am off by a factor of 2.
Should I not be solving these systems concurrently? I noticed if I solve the first two systems before approaching the last one I will instead have
$$\frac{du(r,s)}{ds} = x = s\\
\implies u = \frac{s^2}{2} + c_3$$
and so that
$$u = \frac{x^2}{2} + (te^{-x})^2$$
which satisfies the original problem.
My issue is this solution of solving the first two systems seems a little heuristic. Is this the standard approach, and should the variables in the integration always be expressed in terms of parameterized variables $r$ and $s$ instead?
 A: Another approach consists in using Laplace transform.
Let $U(t,s)$ be the LT of $u(t,x)$.
The eq. writes in Laplace domain
$$
tU_t(t,s)+
[s U(t,s)- U(t,0)] = 
\frac{1}{s^2}
$$
Rearranging terms, and denoting
$y(t)=U(t,s)$,
we obtain the first order differential equation with non constant coefficients
$$
y' + \frac{s}{t} y
= 
\frac{1}{s^2 t} + t 
$$
After multiplying on both sides by the
integrating factor
$\mu
=e^{\int \frac{s}{t} dt}
=t^s$, we obtain
$$
t^s y' + st^{s-1} y
= 
[t^s y]'
=
\frac{t^{s-1}}{s^2} + t^{s+1} 
$$
this gives after integration
$$
t^s y
=
\frac{t^s}{s^3} 
+ \frac{t^{s+2}}{s+2} 
+ C
$$
Finally the solution is
$$
y(t)
=U(t,s)
=\frac{1}{s^3} 
+ \frac{t^2}{s+2}
$$
The constant is null
because of the finite initial condition.
Back in space, we finally obtain
$$
U(t,x)=
\frac{x^2}{2}+t^2 e^{-2x}
$$
A: The error here comes from solving the third equation "simultaneously". TDLR - The third equation should be understood as $x$ is an undetermined function (ie not fixed). (What you did was to assume that $x$ is fixed and did the integration directly.)
Details:
For the third equation,
$$\frac{\mathrm{d}u(r,s)}{ds} = x$$
should be understood as
$$\frac{\mathrm{d}u(r,s)}{ds} = x(r,s)$$
as we are looking at a system of ordinary differential equations here. In fact, to be understood as ODEs, this does not even make sense unless we treat $r$ as a constant.
The way in which I understand how the method of characteristic works is that it is basically a result of the multivariate chain rule. Since $u = u(t,x)$ is assumed to take such a form, we parameterize $t$ and $x$ by a common parameter (say $s$). This implies that $t(s)$ and $x(s)$ (that is, $t$ and $x$ both depends on a single variable, $s$). Looking back at our $u$ dependence explicitly, we have
$$u = u(t(s),x(s)).$$
Now, we proceed to apply the multivariate chain rule as we differentiate $u$ with respect to $s$ as follows.
$$\frac{\mathrm{d}}{\mathrm{d}s}u(t(s),x(s)) = \frac{\partial u(x,s)}{\partial t}\frac{\mathrm{d}t(s)}{\mathrm{d}s} + \frac{\partial u(x,s)}{\partial x}\frac{\mathrm{d}x(s)}{\mathrm{d}s}.$$
In the equation above, I have explicitly written the "correct" dependence of each of the functions on their corresponding variables. Now, under such a method, we hope that the left-hand side of the PDE can be written as $\frac{\mathrm{d}}{\mathrm{d}s}u(t(s),x(s))$. This implies that we should have
$$\begin{aligned} \frac{\mathrm{d}t(s)}{\mathrm{d}s} &= t \\  \frac{\mathrm{d}x(s)}{\mathrm{d}s} &= 1 \end{aligned}$$
such that the left-hand side of the given PDE is now
$$\frac{\mathrm{d}u(s)}{\mathrm{d}s} =\frac{\mathrm{d}u(x(s),t(s))}{\mathrm{d}s} = x(s). $$
The redundant equality above is to emphasize that we can view $u$ as a function of $s$, which is obtained by viewing $u$ as a function of $x$ and $t$, each as a function of $s$. From this equation above, it is clear that
$$u = xs + c_3 $$
as you have suggested would not have been the solution (as that is not the correct way to solve this ODE).
